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§
Sourcefn prune(&mut self, cutoff: Timestamp) -> Result<usize, Error>
fn prune(&mut self, cutoff: Timestamp) -> Result<usize, Error>
Prune announcements older than the cutoff time.
Sourcefn last(&self) -> Result<Option<Timestamp>, Error>
fn last(&self) -> Result<Option<Timestamp>, Error>
Get the timestamp of the last announcement in the store.
Sourcefn announced(
&mut self,
nid: &NodeId,
ann: &Announcement,
) -> Result<Option<AnnouncementId>, Error>
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.
Sourcefn set_relay(
&mut self,
id: AnnouncementId,
relay: RelayStatus,
) -> Result<(), Error>
fn set_relay( &mut self, id: AnnouncementId, relay: RelayStatus, ) -> Result<(), Error>
Set whether a message should be relayed or not.
Sourcefn relays(
&mut self,
now: Timestamp,
) -> Result<Vec<(AnnouncementId, Announcement)>, Error>
fn relays( &mut self, now: Timestamp, ) -> Result<Vec<(AnnouncementId, Announcement)>, Error>
Return messages that should be relayed.