[][src]Trait snowball::traits::network::Network

pub trait Network {
    type Node: Node;
    fn node_ids(&self) -> Vec<u64>;
fn node(&self, id: u64) -> Option<&Self::Node>;
fn execute_query(
        &mut self,
        sample_nodes: Vec<u64>,
        query: <Self::Node as Node>::Query
    ) -> Result<Vec<<Self::Node as Node>::QueryResponse>, <Self::Node as Node>::Error>;
fn register_query_filter(
        &mut self,
        filter: fn(query: <Self::Node as Node>::Query, originating_node: &Self::Node) -> bool
    ) -> Result<(), <Self::Node as Node>::Error>;
fn update_preferred_candidate(
        &mut self,
        candidate: <<Self::Node as Node>::QueryResponse as QueryResponse>::Candidate
    ); }

Object that provides view of the network

Associated Types

type Node: Node

Loading content...

Required methods

fn node_ids(&self) -> Vec<u64>

Returns list of node ids we have discovered this list can be constantly updated as nodes comes up or shuts down.

fn node(&self, id: u64) -> Option<&Self::Node>

Returns node object against the id passed

fn execute_query(
    &mut self,
    sample_nodes: Vec<u64>,
    query: <Self::Node as Node>::Query
) -> Result<Vec<<Self::Node as Node>::QueryResponse>, <Self::Node as Node>::Error>

Executes our query on all sample nodes and returns array of response for the same.

fn register_query_filter(
    &mut self,
    filter: fn(query: <Self::Node as Node>::Query, originating_node: &Self::Node) -> bool
) -> Result<(), <Self::Node as Node>::Error>

Registers query filter that decides whether or not to respond incoming query. Can be used to blacklist nodes which are sending too many queries in short amount of time.

fn update_preferred_candidate(
    &mut self,
    candidate: <<Self::Node as Node>::QueryResponse as QueryResponse>::Candidate
)

Informs network query executor that our node's preferred candidate is updated. This method must not trigger any network operation and cannot fail.

Loading content...

Implementors

Loading content...