Skip to content
Juvix preamble

module arch.node.engines.wall_clock;

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.wall_clock_config open public;
import arch.node.engines.wall_clock_messages open public;
import arch.node.engines.wall_clock_environment open public;
import arch.node.engines.wall_clock_behaviour open public;
import arch.node.types.anoma as Anoma open;

open wall_clock_config_example;
open wall_clock_environment_example;

Wall Clock Engine

Purpose

The Wall Clock Engine provides a mechanism for tracking and managing time locally on the physical machine that the Anoma node is running. It abstracts away the details of the underlying hardware and provides an interface for getting real-time clock functionality.

Components

Type

WallClockEngine : Type :=
Engine
WallClockCfg
WallClockLocalState
WallClockMailboxState
WallClockTimerHandle
WallClockActionArguments
Anoma.Msg
Anoma.Cfg
Anoma.Env;

Example of a wall clock engine

exampleWallClockEngine : WallClockEngine :=
mkEngine@{
cfg := wallClockCfg;
env := wallClockEnv;
behaviour := wallClockBehaviour;
};

where wallClockCfg is defined as follows:

wallClockCfg : EngineCfg WallClockCfg :=
mkEngineCfg@{
node := Curve25519PubKey "0xabcd1234";
name := "wall clock";
cfg := mkWallClockCfg;
};

wallClockEnv is defined as follows:

wallClockEnv : WallClockEnv :=
mkEngineEnv@{
localState :=
mkWallClockLocalState@{
currentTime := 0;
};
mailboxCluster := Map.empty;
acquaintances := Set.empty;
timers := [];
};

and wallClockBehaviour is defined as follows:

wallClockBehaviour : WallClockBehaviour :=
mkEngineBehaviour@{
guards := First [getTimeGuard];
};