pub struct HoprNodeDb { /* private fields */ }
Implementations§
Source§impl HoprNodeDb
impl HoprNodeDb
pub async fn new( directory: &Path, chain_key: ChainKeypair, cfg: HoprNodeDbConfig, ) -> Result<Self, NodeDbError>
pub async fn new_in_memory(chain_key: ChainKeypair) -> Result<Self, NodeDbError>
pub async fn invalidate_unrealized_value(&self, channel: &ChannelEntry)
pub fn config(&self) -> &HoprNodeDbConfig
Source§impl HoprNodeDb
impl HoprNodeDb
Sourcepub async fn upsert_ticket(
&self,
acknowledged_ticket: AcknowledgedTicket,
) -> Result<(), NodeDbError>
pub async fn upsert_ticket( &self, acknowledged_ticket: AcknowledgedTicket, ) -> Result<(), NodeDbError>
Used only by non-SQLite code and tests.
Source§impl HoprNodeDb
impl HoprNodeDb
Sourcepub fn start_ticket_processing<S>(
&self,
ticket_notifier: Option<S>,
) -> Result<(), NodeDbError>
pub fn start_ticket_processing<S>( &self, ticket_notifier: Option<S>, ) -> Result<(), NodeDbError>
Starts ticket processing by the TicketManager
with an optional new ticket notifier.
Without calling this method, tickets will not be persisted into the DB.
If the notifier is given, it will receive notifications once a new ticket has been persisted into the Tickets DB.
Trait Implementations§
Source§impl Clone for HoprNodeDb
impl Clone for HoprNodeDb
Source§fn clone(&self) -> HoprNodeDb
fn clone(&self) -> HoprNodeDb
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl HoprDbPeersOperations for HoprNodeDb
impl HoprDbPeersOperations for HoprNodeDb
type Error = NodeDbError
Source§fn add_network_peer<'life0, 'life1, 'async_trait>(
&'life0 self,
peer: &'life1 PeerId,
origin: PeerOrigin,
mas: Vec<Multiaddr>,
backoff: f64,
quality_window: u32,
) -> Pin<Box<dyn Future<Output = Result<(), NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn add_network_peer<'life0, 'life1, 'async_trait>(
&'life0 self,
peer: &'life1 PeerId,
origin: PeerOrigin,
mas: Vec<Multiaddr>,
backoff: f64,
quality_window: u32,
) -> Pin<Box<dyn Future<Output = Result<(), NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Adds a peer to the backend. Read more
Source§fn remove_network_peer<'life0, 'life1, 'async_trait>(
&'life0 self,
peer: &'life1 PeerId,
) -> Pin<Box<dyn Future<Output = Result<(), NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn remove_network_peer<'life0, 'life1, 'async_trait>(
&'life0 self,
peer: &'life1 PeerId,
) -> Pin<Box<dyn Future<Output = Result<(), NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Removes the peer from the backend. Read more
Source§fn update_network_peer<'life0, 'async_trait>(
&'life0 self,
new_status: PeerStatus,
) -> Pin<Box<dyn Future<Output = Result<(), NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn update_network_peer<'life0, 'async_trait>(
&'life0 self,
new_status: PeerStatus,
) -> Pin<Box<dyn Future<Output = Result<(), NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Updates stored information about the peer.
Should fail if the peer does not exist in the store.
Source§fn get_network_peer<'life0, 'life1, 'async_trait>(
&'life0 self,
peer: &'life1 PeerId,
) -> Pin<Box<dyn Future<Output = Result<Option<PeerStatus>, NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_network_peer<'life0, 'life1, 'async_trait>(
&'life0 self,
peer: &'life1 PeerId,
) -> Pin<Box<dyn Future<Output = Result<Option<PeerStatus>, NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Gets stored information about the peer. Read more
Source§fn get_network_peers<'a, 'async_trait>(
&'a self,
selector: PeerSelector,
sort_last_seen_asc: bool,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'a, PeerStatus>, NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
fn get_network_peers<'a, 'async_trait>(
&'a self,
selector: PeerSelector,
sort_last_seen_asc: bool,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'a, PeerStatus>, NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
Returns a stream of all stored peers, optionally matching the given
PeerSelector
filter. Read moreSource§fn network_peer_stats<'life0, 'async_trait>(
&'life0 self,
quality_threshold: f64,
) -> Pin<Box<dyn Future<Output = Result<Stats, NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn network_peer_stats<'life0, 'async_trait>(
&'life0 self,
quality_threshold: f64,
) -> Pin<Box<dyn Future<Output = Result<Stats, NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns the statistics on the stored peers.
Source§impl HoprDbProtocolOperations for HoprNodeDb
impl HoprDbProtocolOperations for HoprNodeDb
type Error = NodeDbError
Source§fn handle_acknowledgement<'life0, 'life1, 'async_trait, R>(
&'life0 self,
ack: VerifiedAcknowledgement,
resolver: &'life1 R,
) -> Pin<Box<dyn Future<Output = Result<(), NodeDbError>> + Send + 'async_trait>>where
R: ChainReadChannelOperations + ChainValues + Send + Sync + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle_acknowledgement<'life0, 'life1, 'async_trait, R>(
&'life0 self,
ack: VerifiedAcknowledgement,
resolver: &'life1 R,
) -> Pin<Box<dyn Future<Output = Result<(), NodeDbError>> + Send + 'async_trait>>where
R: ChainReadChannelOperations + ChainValues + Send + Sync + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Processes the acknowledgements for the pending tickets Read more
Source§fn find_surb<'life0, 'async_trait>(
&'life0 self,
matcher: SurbMatcher,
) -> Pin<Box<dyn Future<Output = Result<FoundSurb, NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn find_surb<'life0, 'async_trait>(
&'life0 self,
matcher: SurbMatcher,
) -> Pin<Box<dyn Future<Output = Result<FoundSurb, NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Attempts to find SURB and its ID given the
SurbMatcher
.Source§fn get_surb_config(&self) -> SurbCacheConfig
fn get_surb_config(&self) -> SurbCacheConfig
Returns the SURB cache configuration.
Source§fn to_send_no_ack<'life0, 'life1, 'async_trait, R>(
&'life0 self,
data: Box<[u8]>,
destination: OffchainPublicKey,
resolver: &'life1 R,
) -> Pin<Box<dyn Future<Output = Result<OutgoingPacket, NodeDbError>> + Send + 'async_trait>>where
R: ChainKeyOperations + ChainValues + Send + Sync + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn to_send_no_ack<'life0, 'life1, 'async_trait, R>(
&'life0 self,
data: Box<[u8]>,
destination: OffchainPublicKey,
resolver: &'life1 R,
) -> Pin<Box<dyn Future<Output = Result<OutgoingPacket, NodeDbError>> + Send + 'async_trait>>where
R: ChainKeyOperations + ChainValues + Send + Sync + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Process the data into an outgoing packet that is not going to be acknowledged.
Source§fn to_send<'life0, 'life1, 'async_trait, R>(
&'life0 self,
data: Box<[u8]>,
routing: ResolvedTransportRouting,
outgoing_ticket_win_prob: Option<WinningProbability>,
outgoing_ticket_price: Option<HoprBalance>,
signals: PacketSignals,
resolver: &'life1 R,
) -> Pin<Box<dyn Future<Output = Result<OutgoingPacket, NodeDbError>> + Send + 'async_trait>>where
R: ChainReadChannelOperations + ChainKeyOperations + ChainValues + Send + Sync + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn to_send<'life0, 'life1, 'async_trait, R>(
&'life0 self,
data: Box<[u8]>,
routing: ResolvedTransportRouting,
outgoing_ticket_win_prob: Option<WinningProbability>,
outgoing_ticket_price: Option<HoprBalance>,
signals: PacketSignals,
resolver: &'life1 R,
) -> Pin<Box<dyn Future<Output = Result<OutgoingPacket, NodeDbError>> + Send + 'async_trait>>where
R: ChainReadChannelOperations + ChainKeyOperations + ChainValues + Send + Sync + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Process the data into an outgoing packet
Source§fn from_recv<'life0, 'life1, 'life2, 'async_trait, R>(
&'life0 self,
data: Box<[u8]>,
pkt_keypair: &'life1 OffchainKeypair,
sender: OffchainPublicKey,
outgoing_ticket_win_prob: Option<WinningProbability>,
outgoing_ticket_price: Option<HoprBalance>,
resolver: &'life2 R,
) -> Pin<Box<dyn Future<Output = Result<IncomingPacket, IncomingPacketError<NodeDbError>>> + Send + 'async_trait>>where
R: ChainReadChannelOperations + ChainKeyOperations + ChainValues + Send + Sync + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn from_recv<'life0, 'life1, 'life2, 'async_trait, R>(
&'life0 self,
data: Box<[u8]>,
pkt_keypair: &'life1 OffchainKeypair,
sender: OffchainPublicKey,
outgoing_ticket_win_prob: Option<WinningProbability>,
outgoing_ticket_price: Option<HoprBalance>,
resolver: &'life2 R,
) -> Pin<Box<dyn Future<Output = Result<IncomingPacket, IncomingPacketError<NodeDbError>>> + Send + 'async_trait>>where
R: ChainReadChannelOperations + ChainKeyOperations + ChainValues + Send + Sync + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Process the incoming packet into data
Source§impl HoprDbTicketOperations for HoprNodeDb
impl HoprDbTicketOperations for HoprNodeDb
type Error = NodeDbError
Source§fn stream_tickets<'c, 'async_trait>(
&'c self,
selector: Option<TicketSelector>,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'c, AcknowledgedTicket>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'c: 'async_trait,
fn stream_tickets<'c, 'async_trait>(
&'c self,
selector: Option<TicketSelector>,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'c, AcknowledgedTicket>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'c: 'async_trait,
Retrieve acknowledged winning tickets, according to the given
selector
. Read moreSource§fn mark_tickets_as<'life0, 'async_trait>(
&'life0 self,
selector: TicketSelector,
mark_as: TicketMarker,
) -> Pin<Box<dyn Future<Output = Result<usize, NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn mark_tickets_as<'life0, 'async_trait>(
&'life0 self,
selector: TicketSelector,
mark_as: TicketMarker,
) -> Pin<Box<dyn Future<Output = Result<usize, NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Marks tickets as the given
TicketMarker
, removing them from the DB and updating the
ticket statistics for each ticket’s channel. Read moreSource§fn mark_unsaved_ticket_rejected<'life0, 'life1, 'async_trait>(
&'life0 self,
ticket: &'life1 Ticket,
) -> Pin<Box<dyn Future<Output = Result<(), NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn mark_unsaved_ticket_rejected<'life0, 'life1, 'async_trait>(
&'life0 self,
ticket: &'life1 Ticket,
) -> Pin<Box<dyn Future<Output = Result<(), NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Updates the ticket statistics according to the fact that the given ticket has
been rejected by the packet processing pipeline. Read more
Source§fn update_ticket_states_and_fetch<'a, 'async_trait>(
&'a self,
selector: TicketSelector,
new_state: AcknowledgedTicketStatus,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'a, AcknowledgedTicket>, NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
fn update_ticket_states_and_fetch<'a, 'async_trait>(
&'a self,
selector: TicketSelector,
new_state: AcknowledgedTicketStatus,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'a, AcknowledgedTicket>, NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
Source§fn update_ticket_states<'life0, 'async_trait>(
&'life0 self,
selector: TicketSelector,
new_state: AcknowledgedTicketStatus,
) -> Pin<Box<dyn Future<Output = Result<usize, NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn update_ticket_states<'life0, 'async_trait>(
&'life0 self,
selector: TicketSelector,
new_state: AcknowledgedTicketStatus,
) -> Pin<Box<dyn Future<Output = Result<usize, NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Updates state of the tickets matching the given
selector
.Source§fn get_ticket_statistics<'life0, 'async_trait>(
&'life0 self,
channel_id: Option<Hash>,
) -> Pin<Box<dyn Future<Output = Result<ChannelTicketStatistics, NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_ticket_statistics<'life0, 'async_trait>(
&'life0 self,
channel_id: Option<Hash>,
) -> Pin<Box<dyn Future<Output = Result<ChannelTicketStatistics, NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Retrieves the ticket statistics for the given channel. Read more
Source§fn reset_ticket_statistics<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn reset_ticket_statistics<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Resets the ticket statistics about neglected, rejected, and redeemed tickets.
Source§fn get_tickets_value<'life0, 'async_trait>(
&'life0 self,
selector: TicketSelector,
) -> Pin<Box<dyn Future<Output = Result<(usize, HoprBalance), NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_tickets_value<'life0, 'async_trait>(
&'life0 self,
selector: TicketSelector,
) -> Pin<Box<dyn Future<Output = Result<(usize, HoprBalance), NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Counts the tickets matching the given
selector
and their total value. Read moreSource§fn compare_and_set_outgoing_ticket_index<'life0, 'async_trait>(
&'life0 self,
channel_id: Hash,
index: u64,
) -> Pin<Box<dyn Future<Output = Result<u64, NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn compare_and_set_outgoing_ticket_index<'life0, 'async_trait>(
&'life0 self,
channel_id: Hash,
index: u64,
) -> Pin<Box<dyn Future<Output = Result<u64, NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sets the stored outgoing ticket index to
index
, only if the currently stored value
is less than index
. This ensures the stored value can only be growing. Read moreSource§fn reset_outgoing_ticket_index<'life0, 'async_trait>(
&'life0 self,
channel_id: Hash,
) -> Pin<Box<dyn Future<Output = Result<u64, NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn reset_outgoing_ticket_index<'life0, 'async_trait>(
&'life0 self,
channel_id: Hash,
) -> Pin<Box<dyn Future<Output = Result<u64, NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Resets the outgoing ticket index to 0 for the given channel id. Read more
Source§fn increment_outgoing_ticket_index<'life0, 'async_trait>(
&'life0 self,
channel_id: Hash,
) -> Pin<Box<dyn Future<Output = Result<u64, NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn increment_outgoing_ticket_index<'life0, 'async_trait>(
&'life0 self,
channel_id: Hash,
) -> Pin<Box<dyn Future<Output = Result<u64, NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Increments the outgoing ticket index in the given channel ID and returns the value before incrementing. Read more
Source§fn get_outgoing_ticket_index<'life0, 'async_trait>(
&'life0 self,
channel_id: Hash,
) -> Pin<Box<dyn Future<Output = Result<Arc<AtomicU64>, NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_outgoing_ticket_index<'life0, 'async_trait>(
&'life0 self,
channel_id: Hash,
) -> Pin<Box<dyn Future<Output = Result<Arc<AtomicU64>, NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Gets the current outgoing ticket index for the given channel id. Read more
Source§fn persist_outgoing_ticket_indices<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<usize, NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn persist_outgoing_ticket_indices<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<usize, NodeDbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Compares outgoing ticket indices in the cache with the stored values
and updates the stored value where changed. Read more
Auto Trait Implementations§
impl Freeze for HoprNodeDb
impl !RefUnwindSafe for HoprNodeDb
impl Send for HoprNodeDb
impl Sync for HoprNodeDb
impl Unpin for HoprNodeDb
impl !UnwindSafe for HoprNodeDb
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more