Juvix preamble
module arch.node.engines.ticker;
import prelude open;
import arch.node.types.engine_environment open;
import arch.node.types.engine_behaviour open;
import arch.node.types.engine open;
import arch.node.engines.ticker_config open public;
import arch.node.engines.ticker_messages open public;
import arch.node.engines.ticker_environment open public;
import arch.node.engines.ticker_behaviour open public;
import arch.node.types.anoma as Anoma open;
open ticker_config_example;
open ticker_environment_example;
Ticker Engine¶
The Ticker engine provides a simple counter functionality, allowing clients to increment a counter and retrieve its current value.
Purpose¶
A ticker engine maintains a counter in its local state. It increases the counter
when it receives an Increment message and provides the updated result upon
receiving a Count message. The initial state initializes the counter.
Components¶
Useful links¶
Type¶
TickerEngine : Type :=
  Engine
    TickerLocalCfg
    TickerLocalState
    TickerMailboxState
    TickerTimerHandle
    TickerActionArguments
    Anoma.Msg
    Anoma.Cfg
    Anoma.Env;
Example of a ticker engine¶
exampleTickerEngine : TickerEngine :=
  mkEngine@{
    cfg := tickerCfg;
    env := tickerEnv;
    behaviour := tickerBehaviour;
  };
where tickerCfg is defined as follows:
tickerCfg : TickerCfg :=
  mkEngineCfg@{
    node := Curve25519PubKey "0xabcd1234";
    name := "ticker";
    cfg := mkTickerLocalCfg;
  };
tickerEnv is defined as follows:
tickerEnv : TickerEnv :=
  mkEngineEnv@{
    localState :=
      mkTickerLocalState@{
        counter := 0;
      };
    mailboxCluster := Map.empty;
    acquaintances := Set.empty;
    timers := [];
  };
and tickerBehaviour is defined as follows:
tickerBehaviour : TickerBehaviour :=
  mkEngineBehaviour@{
    guards := First [incrementGuard; countReplyGuard];
  };