[][src]Struct grin_p2p::Peers

pub struct Peers {
    pub adapter: Arc<dyn ChainAdapter>,
    // some fields omitted
}

Fields

Methods

impl Peers
[src]

Adds the peer to our internal peer mapping. Note that the peer is still returned so the server can run it.

Get vec of peers we are currently connected to.

Get a peer we're connected to by address.

Number of peers we're currently connected to.

Returns single random peer with more work than us.

Return vec of connected peers that currently have the most worked branch, showing the highest total difficulty.

Returns single random peer with the most worked branch, showing the highest total difficulty.

Ban a peer, disconnecting it if we're currently connected

Unban a peer, checks if it exists and banned then unban

Broadcasts the provided compact block to PEER_MAX_COUNT of our peers. This is only used when initially broadcasting a newly mined block from a mining node so we want to broadcast it far and wide. A peer implementation may drop the broadcast request if it knows the remote peer already has the block.

Broadcasts the provided header to PEER_PREFERRED_COUNT of our peers. We may be connected to PEER_MAX_COUNT peers so we only want to broadcast to a random subset of peers. A peer implementation may drop the broadcast request if it knows the remote peer already has the header.

Broadcasts the provided stem transaction to our peer relay.

Broadcasts the provided transaction to PEER_PREFERRED_COUNT of our peers. We may be connected to PEER_MAX_COUNT peers so we only want to broadcast to a random subset of peers. A peer implementation may drop the broadcast request if it knows the remote peer already has the transaction.

Ping all our connected peers. Always automatically expects a pong back or disconnects. This acts as a liveness test.

All peer information we have in storage

Find peers in store (not necessarily connected) and return their data

Get peer in store by address

Whether we've already seen a peer with the provided address

Saves updated information about a peer

Updates the state of a peer in store

Iterate over the peer list and prune all peers we have lost connection to or have been deemed problematic. Also avoid connected peer count getting too high.

Removes those peers that seem to have expired

Trait Implementations

impl ChainAdapter for Peers
[src]

Current total difficulty on our chain

Current total height

A valid transaction has been received from one of our peers

A block has been received from one of our peers. Returns true if the block could be handled properly and is not deemed defective by the chain. Returning false means the block will never be valid and may result in the peer being banned. Read more

A set of block header has been received, typically in response to a block header request. Read more

Finds a list of block headers based on the provided locator. Tries to identify the common chain and gets the headers that follow it immediately. Read more

Gets a full block by its hash.

Provides a reading view into the current txhashset state as well as the required indexes for a consumer to rewind to a consistant state at the provided block hash. Read more

Whether the node is ready to accept a new txhashset. If this isn't the case, the archive is provided without being requested and likely an attack attempt. This should be checked before downloading the whole state data. Read more

Writes a reading view on a txhashset state that's been provided to us. If we're willing to accept that new state, the data stream will be read as a zip file, unzipped and the resulting state files should be rewound to the provided indexes. Read more

Update txhashset downloading progress

impl NetAdapter for Peers
[src]

Find good peers we know with the provided capability and return their addresses.

A list of peers has been received from one of our peers.

Heard total_difficulty from a connected peer (via ping/pong).

Is this peer currently banned?

impl Sync for Peers
[src]

impl Send for Peers
[src]

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

Performs the conversion.

impl<T> From for T
[src]

Performs the conversion.

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Borrow for T where
    T: ?Sized
[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut for T where
    T: ?Sized
[src]

Mutably borrows from an owned value. Read more

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

🔬 This is a nightly-only experimental API. (get_type_id)

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more

impl<T> SafeBorrow for T where
    T: ?Sized

Given ptr, which was obtained from a prior call to Self::borrow(), return a value with the same nominal lifetime which is guaranteed to survive mutations to Self. Read more

impl<T> UnsafeAny for T where
    T: Any

impl<T> Erased for T

impl<T> Same for T

Should always be Self