Store

Trait Store 

Source
pub trait Store {
    // Required methods
    fn prune(&mut self, cutoff: Timestamp) -> Result<usize, Error>;
    fn last(&self) -> Result<Option<Timestamp>, Error>;
    fn announced(
        &mut self,
        nid: &NodeId,
        ann: &Announcement,
    ) -> Result<Option<AnnouncementId>, Error>;
    fn set_relay(
        &mut self,
        id: AnnouncementId,
        relay: RelayStatus,
    ) -> Result<(), Error>;
    fn relays(
        &mut self,
        now: Timestamp,
    ) -> Result<Vec<(AnnouncementId, Announcement)>, Error>;
    fn filtered<'a>(
        &'a self,
        filter: &'a Filter,
        from: Timestamp,
        to: Timestamp,
    ) -> Result<Box<dyn Iterator<Item = Result<Announcement, Error>> + 'a>, Error>;
}
Expand description

A database that has access to historical gossip messages. Keeps track of the latest received gossip messages for each node. Grows linearly with the number of nodes on the network.

Required Methods§

Source

fn prune(&mut self, cutoff: Timestamp) -> Result<usize, Error>

Prune announcements older than the cutoff time.

Source

fn last(&self) -> Result<Option<Timestamp>, Error>

Get the timestamp of the last announcement in the store.

Source

fn announced( &mut self, nid: &NodeId, ann: &Announcement, ) -> Result<Option<AnnouncementId>, Error>

Process an announcement for the given node. Returns true if the timestamp was updated or the announcement wasn’t there before.

Source

fn set_relay( &mut self, id: AnnouncementId, relay: RelayStatus, ) -> Result<(), Error>

Set whether a message should be relayed or not.

Source

fn relays( &mut self, now: Timestamp, ) -> Result<Vec<(AnnouncementId, Announcement)>, Error>

Return messages that should be relayed.

Source

fn filtered<'a>( &'a self, filter: &'a Filter, from: Timestamp, to: Timestamp, ) -> Result<Box<dyn Iterator<Item = Result<Announcement, Error>> + 'a>, Error>

Get all the latest gossip messages of all nodes, filtered by inventory filter and announcement timestamps.

§Panics

Panics if from > to.

Implementations on Foreign Types§

Source§

impl Store for Database

Source§

fn prune(&mut self, cutoff: Timestamp) -> Result<usize, Error>

Source§

fn last(&self) -> Result<Option<Timestamp>, Error>

Source§

fn announced( &mut self, nid: &NodeId, ann: &Announcement, ) -> Result<Option<AnnouncementId>, Error>

Source§

fn set_relay( &mut self, id: AnnouncementId, relay: RelayStatus, ) -> Result<(), Error>

Source§

fn relays( &mut self, now: Timestamp, ) -> Result<Vec<(AnnouncementId, Announcement)>, Error>

Source§

fn filtered<'a>( &'a self, filter: &'a Filter, from: Timestamp, to: Timestamp, ) -> Result<Box<dyn Iterator<Item = Result<Announcement, Error>> + 'a>, Error>

Implementors§