Module libp2p_peerbook

Data Types

opt()


opt() = {stale_time, pos_integer()} | {peer_time, pos_integer()}

peerbook()


peerbook() = #peerbook{tid = ets:tab(), store = rocksdb:db_handle(), stale_time = pos_integer()}

Function Index

add_association/3Adds an association under the given type to for the swarm this peerbook is part of.
blacklist_listen_addr/3
changed_listener/1
get/2
handle_call/3
handle_cast/2
handle_gossip_data/2
handle_info/2
init/1
init_gossip_data/1
is_key/2
join_notify/2
keys/1
lookup_association/3Look up all the peers that have a given association type AssocTyp and address AssocAddress in their associations.
put/2
register_session/3
remove/2
stale_time/1
start_link/2
terminate/2
unregister_session/2
update_nat_type/2
values/1

Function Details

add_association/3


add_association(Peerbook::peerbook(), AssocType::string(), Assoc::libp2p_peer:association()) -> ok


Adds an association under the given type to for the swarm this peerbook is part of. Note that the association must have its signature be valid for the address of the swarm this peerbook is part of.

Associations are gossiped with the peer record for the swarm.

Note that the given association will replace an existing association with the given type and address of the association.

blacklist_listen_addr/3


blacklist_listen_addr(Handle::peerbook(), ID::libp2p_crypto:pubkey_bin(), ListenAddr::string()) -> ok | {error, not_found}


changed_listener/1

changed_listener(Peerbook) -> any()

get/2


get(Peerbook::peerbook(), ID::libp2p_crypto:pubkey_bin()) -> {ok, libp2p_peer:peer()} | {error, term()}


handle_call/3

handle_call(Msg, From, State) -> any()

handle_cast/2

handle_cast(Msg, State) -> any()

handle_gossip_data/2


handle_gossip_data(Data::binary(), Handle::peerbook()) -> ok


handle_info/2

handle_info(Msg, State) -> any()

init/1

init(X1) -> any()

init_gossip_data/1


init_gossip_data(Handle::peerbook()) -> libp2p_group_gossip_handler:init_result()


is_key/2


is_key(Handle::peerbook(), ID::libp2p_crypto:pubkey_bin()) -> boolean()


join_notify/2


join_notify(Peerbook::peerbook(), Joiner::pid()) -> ok


keys/1


keys(Handle::peerbook()) -> [libp2p_crypto:pubkey_bin()]


lookup_association/3


lookup_association(Handle::peerbook(), AssocType::string(), AssocAddress::libp2p_crypto:pubkey_bin()) -> [libp2p_peer:peer()]


Look up all the peers that have a given association type AssocTyp and address AssocAddress in their associations.

put/2


put(Peerbook::peerbook(), PeerList::[libp2p_peer:peer()]) -> ok | {error, term()}


register_session/3


register_session(Peerbook::peerbook(), SessionPid::pid(), Identify::libp2p_identify:identify()) -> ok


remove/2


remove(Peerbook::peerbook(), ID::libp2p_crypto:pubkey_bin()) -> ok | {error, no_delete}


stale_time/1


stale_time(Peerbook::peerbook()) -> pos_integer()


start_link/2

start_link(TID, SigFun) -> any()

terminate/2

terminate(Reason, State) -> any()

unregister_session/2


unregister_session(Peerbook::peerbook(), SessionPid::pid()) -> ok


update_nat_type/2


update_nat_type(Peerbook::peerbook(), NatType::libp2p_peer:nat_type()) -> ok


values/1


values(Handle::peerbook()) -> [libp2p_peer:peer()]