Copyright © Helium Systems, Inc.
metadata() = [{string(), binary()}]
nat_type() = libp2p_peer_pb:nat_type()
peer() = #libp2p_signed_peer_pb{}
peer_map() = #{pubkey_bin => libp2p_crypto:pubkey_bin(), listen_addrs => [string()], connected => [binary()], nat_type => nat_type(), network_id => binary(), signed_metadata => #{binary() => binary()}}
blacklist/1 | Gets the blacklist for this peer. |
blacklist_add/2 | Add a given listen address to the blacklist for the given peer. |
blacklist_set/2 | Sets the blacklist for a given peer. |
cleared_listen_addrs/1 | Returns the listen addrs for this peer filtered using the blacklist for the peer, if one is present. |
connected_peers/1 | Gets the list of peer crypto addresses that the given peer was last known to be connected to. |
decode/1 | Decodes a given binary into a peer. |
encode/2 | Encodes the given peer into its binary form. |
from_map/2 | Create a signed peer from a given map of fields. |
is_blacklisted/2 | Returns whether a given listen address is blacklisted. |
is_stale/2 | Returns whether a given peer is stale relative to a given stale delta time in milliseconds. |
listen_addrs/1 | Gets the list of peer multiaddrs that the given peer is listening on. |
metadata/1 | Gets the metadata map from the given peer. |
metadata_get/3 | Gets the value for a stored Key in metadata. |
metadata_put/3 | Updates the metadata for a given peer with the given key/value pair. |
metadata_set/2 | Replaces the full metadata for a given peer. |
nat_type/1 | Gets the NAT type of the given peer. |
network_id/1 | Returns the declared network id for the peer, if any. |
network_id_allowable/2 | Returns whether a givne network id is compatible with this peer. |
pubkey_bin/1 | Gets the public key for the given peer. |
signed_metadata/1 | Gets the signed metadata of the given peer. |
signed_metadata_get/3 | Gets a key from the signed metadata of the given peer. |
supersedes/2 | Returns whether a given Target is more recent than Other |
timestamp/1 | Gets the timestamp of the given peer. |
verify/1 | Cryptographically verifies a given peer and it's associations. |
blacklist(Peer::peer()) -> [string()]
Gets the blacklist for this peer. This is a metadata based feature that enables listen addresses to be blacklisted so they will not be connected to until that address is removed from the blacklist.
blacklist_add(Libp2p_signed_peer_pb::#libp2p_signed_peer_pb{}, ListenAddr::string()) -> {ok, peer()} | {error, term()}
Add a given listen address to the blacklist for the given peer.
Sets the blacklist for a given peer. Note that currently no validation is done against the existing listen addresses stored in the peer. Blacklisting an address that the peer is not listening to will have no effect anyway.
cleared_listen_addrs(Peer::peer()) -> [string()]
Returns the listen addrs for this peer filtered using the blacklist for the peer, if one is present. This is just a convenience function to clear the listen adddresses for a peer with the blacklist stored in metadata.
connected_peers(Libp2p_signed_peer_pb::peer()) -> [libp2p_crypto:pubkey_bin()]
Gets the list of peer crypto addresses that the given peer was last known to be connected to.
decode(Bin::binary()) -> {ok, peer()} | {error, term()}
Decodes a given binary into a peer. Note that a decoded peer
may not verify, so ensure to call verify
before actually using
peer content
encode(Msg::peer(), Strip::boolean()) -> binary()
Encodes the given peer into its binary form. The peer is
stripped from its metadata before encoding if Strip
is true
.
from_map(Map::peer_map(), SigFun::fun((binary()) -> binary())) -> {ok, peer()} | {error, term()}
Create a signed peer from a given map of fields.
is_blacklisted(Peer::peer(), ListenAddr::string()) -> boolean()
Returns whether a given listen address is blacklisted. Note that a blacklisted address may not actually appear in the listen_addrs for this peer.
is_stale(Libp2p_signed_peer_pb::peer(), StaleMS::integer()) -> boolean()
Returns whether a given peer is stale relative to a given stale delta time in milliseconds.
listen_addrs(Libp2p_signed_peer_pb::peer()) -> [string()]
Gets the list of peer multiaddrs that the given peer is listening on.
metadata(Libp2p_signed_peer_pb::peer()) -> metadata()
Gets the metadata map from the given peer. The metadata for a
peer is NOT
part of the signed peer since it can be read and
updated by anyone to annotate the given peer with extra information
metadata_get(Peer::peer(), Key::string(), Default::any()) -> any()
Gets the value for a stored Key
in metadata. If not found,
the Default
is returned.
Updates the metadata for a given peer with the given key/value
pair. The Key
is expected to be a string, while Value
is
expected to be a binary.
metadata_set(Peer::peer(), Metadata::metadata()) -> {ok, peer()} | {error, term()}
Replaces the full metadata for a given peer
nat_type(Libp2p_signed_peer_pb::peer()) -> nat_type()
Gets the NAT type of the given peer.
network_id(Libp2p_signed_peer_pb::peer()) -> binary() | undefined
Returns the declared network id for the peer, if any
network_id_allowable(Peer, MyNetworkID) -> any()
Returns whether a givne network id is compatible with this peer.
A network id is compatible with the network id of this peer if they are equal or if either of them isundefined
pubkey_bin(Libp2p_signed_peer_pb::peer()) -> libp2p_crypto:pubkey_bin()
Gets the public key for the given peer.
signed_metadata(Libp2p_signed_peer_pb::peer()) -> map()
Gets the signed metadata of the given peer
signed_metadata_get(Peer::peer(), Key::binary(), Default::any()) -> any()
Gets a key from the signed metadata of the given peer
Returns whether a given Target
is more recent than Other
timestamp(Libp2p_signed_peer_pb::peer()) -> integer()
Gets the timestamp of the given peer.
verify(Msg::peer()) -> boolean()
Cryptographically verifies a given peer and it's associations. Returns true if the given peer can be verified, false otherwise.
Generated by EDoc