macula_host_identity (macula v4.1.0)
View SourceHosted-identity table for a macula-net station.
PLAN_MACULA_NET_PHASE3.md §6.1. Tracks daemons that have attached to *this* station. On attach/4, verifies the delegation, records the daemon, builds a signed hosted_address_map record and pushes it through the configured put_fn. On detach/1, drops the entry; the record expires by TTL (Phase 4 may publish an explicit tombstone).
The slice is a gen_server so it can refresh the hosted records on a timer at the same cadence macula_advertise_station uses for the station's own records.
Summary
Functions
Register a daemon as hosted by this station.
Snapshot the current set of hosted_address_map records (signed).
Types
-type attach_conn() :: term().
-type config() :: #{realm_pubkey := <<_:256>>, host_pubkey := <<_:256>>, host_privkey := macula_identity:key_pair() | macula_identity:privkey(), put_fn := macula_advertise_station:put_fn(), refresh_ms => pos_integer()}.
Functions
-spec attach(DaemonAddr :: <<_:128>>, DaemonPubkey :: <<_:256>>, Delegation :: macula_record:host_delegation(), AttachConn :: attach_conn()) -> ok | {error, term()}.
Register a daemon as hosted by this station.
Delegation must already be signed by the daemon (i.e. macula_record:sign_host_delegation/2). The station verifies the delegation and that its fields agree with the station's identity + realm; any mismatch yields an error and the daemon is NOT registered.
-spec detach(<<_:128>>) -> ok.
-spec hosted(<<_:128>>) -> boolean().
-spec hosted_addresses() -> [<<_:128>>].
-spec hosted_records() -> [macula_record:record()].
Snapshot the current set of hosted_address_map records (signed).
-spec lookup(<<_:128>>) -> {ok, attach_conn()} | not_found.
-spec refresh_now() -> ok.
-spec stop() -> ok.