Search documentation of macula

# macula_host_identity (macula v4.4.9)

View Source

Hosted-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

## Types

attach_conn/0
config/0

## Functions

attach(DaemonAddr, DaemonPubkey, Delegation, AttachConn)

Register a daemon as hosted by this station.

code_change(OldVsn, State, Extra)
detach(DaemonAddr)
handle_call(Other, From, State)
handle_cast(Msg, State)
handle_info(Other, State)
hosted(DaemonAddr)
hosted_addresses()
hosted_records()

Snapshot the current set of hosted_address_map records (signed).

init(Config)
lookup(DaemonAddr)
refresh_now()
start_link(Config)
stop()
terminate(Reason, State)

# Types

# attach_conn/0

    -type attach_conn() :: term().

# config/0

    -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

# attach(DaemonAddr, DaemonPubkey, Delegation, AttachConn)

    -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.

# code_change(OldVsn, State, Extra)

# detach(DaemonAddr)

    -spec detach(<<_:128>>) -> ok.

# handle_call(Other, From, State)

# handle_cast(Msg, State)

# handle_info(Other, State)

# hosted(DaemonAddr)

    -spec hosted(<<_:128>>) -> boolean().

# hosted_addresses()

    -spec hosted_addresses() -> [<<_:128>>].

# hosted_records()

    -spec hosted_records() -> [macula_record:record()].

Snapshot the current set of hosted_address_map records (signed).

# init(Config)

# lookup(DaemonAddr)

    -spec lookup(<<_:128>>) -> {ok, attach_conn()} | not_found.

# refresh_now()

    -spec refresh_now() -> ok.

# start_link(Config)

    -spec start_link(config()) -> {ok, pid()} | {error, term()}.

# stop()

    -spec stop() -> ok.

# terminate(Reason, State)