Struct plumtree::Node [−][src]
pub struct Node<T: System> { /* fields omitted */ }
Plumtree node.
User's responsibility
For running a node correctly, you have to call the following methods appropriately:
poll_action
forget_message
handle_protocol_message
handle_neighbor_up
handle_neighbor_down
clock_mut
For details, refer to the document of each method.
Methods
impl<T: System> Node<T>
[src]
impl<T: System> Node<T>
pub fn new(node_id: T::NodeId) -> Self
[src]
pub fn new(node_id: T::NodeId) -> Self
Makes a new Node
instance.
pub fn with_options(node_id: T::NodeId, options: NodeOptions) -> Self
[src]
pub fn with_options(node_id: T::NodeId, options: NodeOptions) -> Self
Makes a new Node
instance with the given options.
pub fn id(&self) -> &T::NodeId
[src]
pub fn id(&self) -> &T::NodeId
Returns the identifier of the node.
pub fn options(&self) -> &NodeOptions
[src]
pub fn options(&self) -> &NodeOptions
Returns the options of the node.
pub fn options_mut(&mut self) -> &mut NodeOptions
[src]
pub fn options_mut(&mut self) -> &mut NodeOptions
Returns a mutable reference to the options of the node.
pub fn eager_push_peers(&self) -> &HashSet<T::NodeId>
[src]
pub fn eager_push_peers(&self) -> &HashSet<T::NodeId>
Returns the peers with which the node uses eager push gossip for diffusing application messages.
pub fn lazy_push_peers(&self) -> &HashSet<T::NodeId>
[src]
pub fn lazy_push_peers(&self) -> &HashSet<T::NodeId>
Returns the peers with which the node uses lazy push gossip for diffusing application messages.
pub fn broadcast_message(&mut self, message: Message<T>)
[src]
pub fn broadcast_message(&mut self, message: Message<T>)
Broadcasts the given message.
pub fn messages(&self) -> &HashMap<T::MessageId, T::MessagePayload>
[src]
pub fn messages(&self) -> &HashMap<T::MessageId, T::MessagePayload>
Returns a reference to the messages kept by the node.
pub fn waiting_messages(&self) -> usize
[src]
pub fn waiting_messages(&self) -> usize
Returns the number of messages waiting to be received.
Roughly speaking, it indicates the approximate number of IHAVE
messages held by the node.
pub fn forget_message(&mut self, message_id: &T::MessageId) -> bool
[src]
pub fn forget_message(&mut self, message_id: &T::MessageId) -> bool
Forgets the specified message.
If the node does not have the target message, this method will return false
.
For preventing memory shortage, this method needs to be called appropriately.
pub fn poll_action(&mut self) -> Option<Action<T>>
[src]
pub fn poll_action(&mut self) -> Option<Action<T>>
Polls the next action that the node wants to execute.
pub fn handle_protocol_message(&mut self, message: ProtocolMessage<T>) -> bool
[src]
pub fn handle_protocol_message(&mut self, message: ProtocolMessage<T>) -> bool
Handles the given incoming message.
This method will return false
if the sender of the message is not a neighbor of this node.
pub fn handle_neighbor_up(&mut self, neighbor_node_id: &T::NodeId)
[src]
pub fn handle_neighbor_up(&mut self, neighbor_node_id: &T::NodeId)
Accepts new neighbor.
pub fn handle_neighbor_down(&mut self, neighbor_node_id: &T::NodeId)
[src]
pub fn handle_neighbor_down(&mut self, neighbor_node_id: &T::NodeId)
Removes downed neighbor.
pub fn clock(&self) -> &Clock
[src]
pub fn clock(&self) -> &Clock
Returns a reference to the clock of the node.
pub fn clock_mut(&mut self) -> &mut Clock
[src]
pub fn clock_mut(&mut self) -> &mut Clock
Returns a mutable reference to the clock of the node.
Note that for handling IHAVE
messages correctly,
you have to proceed the time of the node by calling Clock::tick
method.
pub fn next_expiry_time(&self) -> Option<NodeTime>
[src]
pub fn next_expiry_time(&self) -> Option<NodeTime>
Returns the nearest time when the timeout of a IHAVE
message expires.
If the node has no IHAVE
messages to be handled, this method will return None
.
Trait Implementations
impl<T: System> Debug for Node<T> where
T::NodeId: Debug,
T::MessageId: Debug,
T::MessagePayload: Debug,
[src]
impl<T: System> Debug for Node<T> where
T::NodeId: Debug,
T::MessageId: Debug,
T::MessagePayload: Debug,