pub struct IterativeLookup<N: LookupNode> { /* private fields */ }Expand description
Pull-based, transport-independent Kademlia lookup state machine.
Implementations§
Source§impl<N: LookupNode> IterativeLookup<N>
impl<N: LookupNode> IterativeLookup<N>
Sourcepub fn new(target: LookupKey, config: LookupConfig) -> Result<Self, LookupError>
pub fn new(target: LookupKey, config: LookupConfig) -> Result<Self, LookupError>
Construct an empty lookup for target.
Sourcepub const fn config(&self) -> LookupConfig
pub const fn config(&self) -> LookupConfig
Active lookup configuration.
Sourcepub const fn iterations(&self) -> usize
pub const fn iterations(&self) -> usize
Number of rounds begun so far.
Sourcepub const fn termination(&self) -> Option<LookupTermination>
pub const fn termination(&self) -> Option<LookupTermination>
Current terminal state, if the lookup has stopped.
Sourcepub const fn round_active(&self) -> bool
pub const fn round_active(&self) -> bool
Whether a transport round is currently active.
Sourcepub fn peer_state(&self, peer: &LookupKey) -> Option<LookupPeerState>
pub fn peer_state(&self, peer: &LookupKey) -> Option<LookupPeerState>
State currently assigned to a peer.
Sourcepub fn is_contactable(&self, peer: &LookupKey) -> bool
pub fn is_contactable(&self, peer: &LookupKey) -> bool
Whether the peer has never been contacted by this lookup.
Sourcepub fn queried_peers(&self) -> &[LookupKey] ⓘ
pub fn queried_peers(&self) -> &[LookupKey] ⓘ
Peers selected for a transport query, in query order.
Sourcepub fn add_known_result(&mut self, node: N)
pub fn add_known_result(&mut self, node: N)
Add a successful result that must never be queried, such as the local node competing in a native lookup’s final XOR ordering.
Sourcepub fn add_candidate(&mut self, node: N) -> CandidateInsertion
pub fn add_candidate(&mut self, node: N) -> CandidateInsertion
Add or update an unqueried candidate.
Sourcepub fn begin_round(&mut self) -> Result<LookupProgress, LookupError>
pub fn begin_round(&mut self) -> Result<LookupProgress, LookupError>
Begin the next α-query round.
Sourcepub fn take_next_candidate(&mut self) -> Result<Option<N>, LookupError>
pub fn take_next_candidate(&mut self) -> Result<Option<N>, LookupError>
Remove and return the closest candidate for the active round.
The driver must either call Self::mark_waiting for the returned
node or discard it as temporarily ineligible before asking for another.
Sourcepub fn mark_waiting(&mut self, node: N) -> Result<(), LookupError>
pub fn mark_waiting(&mut self, node: N) -> Result<(), LookupError>
Mark a selected node as an in-flight query in the active round.
Sourcepub fn record_success(&mut self, peer: &LookupKey) -> Result<(), LookupError>
pub fn record_success(&mut self, peer: &LookupKey) -> Result<(), LookupError>
Record a successful response and retain the queried peer as a result.
Sourcepub fn record_failure(&mut self, peer: &LookupKey) -> Result<(), LookupError>
pub fn record_failure(&mut self, peer: &LookupKey) -> Result<(), LookupError>
Record an explicit query or transport failure.
Sourcepub fn record_unresponsive(
&mut self,
peer: &LookupKey,
) -> Result<(), LookupError>
pub fn record_unresponsive( &mut self, peer: &LookupKey, ) -> Result<(), LookupError>
Record a query abandoned after the transport’s round grace period.
Sourcepub fn waiting_peers(&self) -> Vec<LookupKey> ⓘ
pub fn waiting_peers(&self) -> Vec<LookupKey> ⓘ
Peers still waiting in the active round, in XOR order.
Sourcepub fn complete_round(&mut self) -> Result<LookupProgress, LookupError>
pub fn complete_round(&mut self) -> Result<LookupProgress, LookupError>
Complete the current round and evaluate native Saorsa convergence.