LocalAgent

Trait LocalAgent 

Source
pub trait LocalAgent:
    Signer
    + 'static
    + Send
    + Sync
    + Debug {
    // Required methods
    fn agent(&self) -> &AgentId;
    fn register_cb(&self, cb: Arc<dyn Fn() + Send + Sync + 'static>);
    fn invoke_cb(&self);
    fn get_cur_storage_arc(&self) -> DhtArc;
    fn set_cur_storage_arc(&self, arc: DhtArc);
    fn get_tgt_storage_arc(&self) -> DhtArc;
    fn set_tgt_storage_arc_hint(&self, arc: DhtArc);
}
Expand description

A “Local” agent is an agent that is connected to the local Kitsune2 node, and is able to sign messages and agent infos.

Required Methods§

Source

fn agent(&self) -> &AgentId

The AgentId of this local agent.

Source

fn register_cb(&self, cb: Arc<dyn Fn() + Send + Sync + 'static>)

Register a callback to be invoked when Self::invoke_cb is called. Implementations need only track a single cb. If this is called again, use only the new one.

Source

fn invoke_cb(&self)

Invoke the registered cb if one has been set. This can be treated as a no-op rather than an error if Self::register_cb has not yet been called.

Source

fn get_cur_storage_arc(&self) -> DhtArc

Access the current storage arc for this local agent.

This will be used by the space module to construct AgentInfoSigned.

Source

fn set_cur_storage_arc(&self, arc: DhtArc)

Set the current storage arc for this local agent. This will be initially set to zero on space join. The gossip module will update this as data is collected.

Source

fn get_tgt_storage_arc(&self) -> DhtArc

This is a chance for the implementor to influence how large a storage arc should be for this agent. The gossip module will attempt to collect enough data for claiming storage authority over this range.

Source

fn set_tgt_storage_arc_hint(&self, arc: DhtArc)

The sharding module will attempt to determine an ideal target arc for this agent. An implementation is free to use or discard this information when returning the arc in Self::get_tgt_storage_arc. This will initially be set to zero on join, but the sharding module may later update this to FULL or a true target value.

Implementors§