Store

Trait Store 

Source
pub trait Store {
Show 14 methods // Required methods fn get(&self, id: &PublicKey) -> Result<Option<Node>, Error>; fn addresses_of(&self, node: &PublicKey) -> Result<Vec<KnownAddress>, Error>; fn insert( &mut self, node: &PublicKey, version: u8, features: Features, alias: &Alias, pow: u32, agent: &UserAgent, timestamp: Timestamp, addrs: impl IntoIterator<Item = KnownAddress>, ) -> Result<bool, Error>; fn remove(&mut self, id: &PublicKey) -> Result<bool, Error>; fn len(&self) -> Result<usize, Error>; fn nodes(&self) -> Result<usize, Error>; fn is_addr_banned(&self, addr: &Address) -> Result<bool, Error>; fn is_ip_banned(&self, ip: IpAddr) -> Result<bool, Error>; fn entries(&self) -> Result<Box<dyn Iterator<Item = AddressEntry>>, Error>; fn attempted( &self, nid: &PublicKey, addr: &Address, time: Timestamp, ) -> Result<(), Error>; fn connected( &self, nid: &PublicKey, addr: &Address, time: Timestamp, ) -> Result<(), Error>; fn record_ip( &self, nid: &PublicKey, ip: IpAddr, time: Timestamp, ) -> Result<(), Error>; fn disconnected( &mut self, nid: &PublicKey, addr: &Address, severity: Severity, ) -> Result<(), Error>; // Provided method fn is_empty(&self) -> Result<bool, Error> { ... }
}
Expand description

Address store.

Used to store node addresses and metadata.

Required Methods§

Source

fn get(&self, id: &PublicKey) -> Result<Option<Node>, Error>

Get the information we have about a node.

Source

fn addresses_of(&self, node: &PublicKey) -> Result<Vec<KnownAddress>, Error>

Get the addresses of a node.

Source

fn insert( &mut self, node: &PublicKey, version: u8, features: Features, alias: &Alias, pow: u32, agent: &UserAgent, timestamp: Timestamp, addrs: impl IntoIterator<Item = KnownAddress>, ) -> Result<bool, Error>

Insert a node with associated addresses into the store.

Returns true if the node or addresses were updated, and false otherwise.

Source

fn remove(&mut self, id: &PublicKey) -> Result<bool, Error>

Remove a node from the store.

Source

fn len(&self) -> Result<usize, Error>

Returns the number of addresses.

Source

fn nodes(&self) -> Result<usize, Error>

Return the number of nodes.

Source

fn is_addr_banned(&self, addr: &Address) -> Result<bool, Error>

Check if an address is banned. Also returns true if the node this address belongs to is banned.

Source

fn is_ip_banned(&self, ip: IpAddr) -> Result<bool, Error>

Check if an IP is banned.

Source

fn entries(&self) -> Result<Box<dyn Iterator<Item = AddressEntry>>, Error>

Get the address entries in the store.

Source

fn attempted( &self, nid: &PublicKey, addr: &Address, time: Timestamp, ) -> Result<(), Error>

Mark a node as attempted at a certain time.

Source

fn connected( &self, nid: &PublicKey, addr: &Address, time: Timestamp, ) -> Result<(), Error>

Mark a node as successfully connected at a certain time.

Source

fn record_ip( &self, nid: &PublicKey, ip: IpAddr, time: Timestamp, ) -> Result<(), Error>

Record a node IP address and connection time.

Source

fn disconnected( &mut self, nid: &PublicKey, addr: &Address, severity: Severity, ) -> Result<(), Error>

Mark a node as disconnected.

Provided Methods§

Source

fn is_empty(&self) -> Result<bool, Error>

Returns true if there are no addresses.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§