Skip to main content

LookupQuery

Trait LookupQuery 

Source
pub trait LookupQuery<N>
where N: LookupNode,
{ type Error; // Required method fn query_batch( &mut self, target: [u8; 32], count: usize, iteration: usize, batch: Vec<N>, ) -> impl Future<Output = Result<Vec<LookupQueryOutcome<N>>, Self::Error>>; // Provided methods fn is_candidate_eligible( &mut self, _candidate: &N, ) -> impl Future<Output = Result<bool, Self::Error>> { ... } fn candidate_evicted( &mut self, _peer: [u8; 32], ) -> impl Future<Output = Result<(), Self::Error>> { ... } }
Expand description

Transport and response-validation boundary used by the shared DHT walk.

Implementations receive a complete α-sized batch so they can execute its queries concurrently using transport-specific cancellation and timeout facilities. Only validated candidates should be returned to the engine. The shared runner may drop any pending adapter future at its overall deadline. Implementations must support cancellation without detached work.

Required Associated Types§

Source

type Error

Error returned by the transport adapter.

Required Methods§

Source

fn query_batch( &mut self, target: [u8; 32], count: usize, iteration: usize, batch: Vec<N>, ) -> impl Future<Output = Result<Vec<LookupQueryOutcome<N>>, Self::Error>>

Execute one concurrent lookup batch and validate its responses.

A missing outcome is treated as LookupQueryOutcome::Unresponsive.

Provided Methods§

Source

fn is_candidate_eligible( &mut self, _candidate: &N, ) -> impl Future<Output = Result<bool, Self::Error>>

Whether the current address view for a candidate is usable.

Returning false discards this representation without assigning a final peer state. A later response may therefore reintroduce the same peer with a usable address.

Source

fn candidate_evicted( &mut self, _peer: [u8; 32], ) -> impl Future<Output = Result<(), Self::Error>>

Observe eviction of a farther queued candidate.

Stateful validators can use this to release per-candidate evidence.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§