Skip to content
Juvix imports

module arch.node.engines.net_registry;

import arch.node.engines.net_registry_messages open public;
import arch.node.engines.net_registry_config open public;
import arch.node.engines.net_registry_environment open public;
import arch.node.engines.net_registry_behaviour open public;
import arch.node.types.basics open;
import arch.node.types.engine open;
import arch.node.types.anoma as Anoma open;

open registry_config_example;
open registry_environment_example;
open registry_behaviour_example;

Network Registry Engine

Purpose

The single Network Registry engine instance maintains a database of NodeAdvert and TopicAdvert messages that arrive from the network on each node. For each known node and topic it spawns a Router Engine or a Pub/Sub Topic Engine instance, respectively.

Engine components

The type for a network registry engine

NetworkRegistryEngine : Type :=
Engine
NetworkRegistryLocalCfg
NetworkRegistryLocalState
NetworkRegistryMailboxState
NetworkRegistryTimerHandle
NetworkRegistryActionArguments
Anoma.Msg
Anoma.Cfg
Anoma.Env;

Example instantiation

exNetworkRegistryEngine : NetworkRegistryEngine :=
mkEngine@{
cfg := exNetworkRegistryCfg;
env := exNetworkRegistryEnv;
behaviour := exNetworkRegistryBehaviour;
};

Where exNetworkRegistryCfg is defined as follows:

exNetworkRegistryCfg : NetworkRegistryCfg :=
mkEngineCfg@{
node := Curve25519PubKey "0xabcd1234";
name := "net-registry";
cfg := mkNetworkRegistryLocalCfg;
};

exNetworkRegistryEnv is defined as follows:

exNetworkRegistryEnv : NetworkRegistryEnv :=
mkEngineEnv@{
localState := mkNetworkRegistryLocalState;
mailboxCluster := Map.empty;
acquaintances := Set.empty;
timers := [];
};

and exNetworkRegistryBehaviour is defined as follows:

module registry_behaviour_example;
exNetworkRegistryBehaviour : NetworkRegistryBehaviour :=
mkEngineBehaviour@{
guards := First [exampleReplyGuard];
};
end;