[−][src]Struct grin_p2p::Peers
Fields
adapter: Arc<dyn ChainAdapter>
Methods
impl Peers
[src]
impl Peers
pub fn new(
store: PeerStore,
adapter: Arc<dyn ChainAdapter>,
config: P2PConfig
) -> Peers
[src]
pub fn new(
store: PeerStore,
adapter: Arc<dyn ChainAdapter>,
config: P2PConfig
) -> Peers
pub fn add_connected(&self, peer: Arc<Peer>) -> Result<(), Error>
[src]
pub fn add_connected(&self, peer: Arc<Peer>) -> Result<(), Error>
Adds the peer to our internal peer mapping. Note that the peer is still returned so the server can run it.
pub fn update_dandelion_relay(&self)
[src]
pub fn update_dandelion_relay(&self)
pub fn get_dandelion_relay(&self) -> HashMap<i64, Arc<Peer>>
[src]
pub fn get_dandelion_relay(&self) -> HashMap<i64, Arc<Peer>>
pub fn is_known(&self, addr: &SocketAddr) -> bool
[src]
pub fn is_known(&self, addr: &SocketAddr) -> bool
pub fn connected_peers(&self) -> Vec<Arc<Peer>>
[src]
pub fn connected_peers(&self) -> Vec<Arc<Peer>>
Get vec of peers we are currently connected to.
pub fn outgoing_connected_peers(&self) -> Vec<Arc<Peer>>
[src]
pub fn outgoing_connected_peers(&self) -> Vec<Arc<Peer>>
pub fn get_connected_peer(&self, addr: &SocketAddr) -> Option<Arc<Peer>>
[src]
pub fn get_connected_peer(&self, addr: &SocketAddr) -> Option<Arc<Peer>>
Get a peer we're connected to by address.
pub fn peer_count(&self) -> u32
[src]
pub fn peer_count(&self) -> u32
Number of peers we're currently connected to.
pub fn more_work_peers(&self) -> Vec<Arc<Peer>>
[src]
pub fn more_work_peers(&self) -> Vec<Arc<Peer>>
pub fn more_work_peer(&self) -> Option<Arc<Peer>>
[src]
pub fn more_work_peer(&self) -> Option<Arc<Peer>>
Returns single random peer with more work than us.
pub fn most_work_peers(&self) -> Vec<Arc<Peer>>
[src]
pub fn most_work_peers(&self) -> Vec<Arc<Peer>>
Return vec of connected peers that currently have the most worked branch, showing the highest total difficulty.
pub fn most_work_peer(&self) -> Option<Arc<Peer>>
[src]
pub fn most_work_peer(&self) -> Option<Arc<Peer>>
Returns single random peer with the most worked branch, showing the highest total difficulty.
pub fn is_banned(&self, peer_addr: SocketAddr) -> bool
[src]
pub fn is_banned(&self, peer_addr: SocketAddr) -> bool
pub fn ban_peer(&self, peer_addr: &SocketAddr, ban_reason: ReasonForBan)
[src]
pub fn ban_peer(&self, peer_addr: &SocketAddr, ban_reason: ReasonForBan)
Ban a peer, disconnecting it if we're currently connected
pub fn unban_peer(&self, peer_addr: &SocketAddr)
[src]
pub fn unban_peer(&self, peer_addr: &SocketAddr)
Unban a peer, checks if it exists and banned then unban
pub fn broadcast_compact_block(&self, b: &CompactBlock)
[src]
pub fn broadcast_compact_block(&self, b: &CompactBlock)
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.
pub fn broadcast_header(&self, bh: &BlockHeader)
[src]
pub fn broadcast_header(&self, bh: &BlockHeader)
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.
pub fn broadcast_stem_transaction(&self, tx: &Transaction) -> Result<(), Error>
[src]
pub fn broadcast_stem_transaction(&self, tx: &Transaction) -> Result<(), Error>
Broadcasts the provided stem transaction to our peer relay.
pub fn broadcast_transaction(&self, tx: &Transaction)
[src]
pub fn broadcast_transaction(&self, tx: &Transaction)
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.
pub fn check_all(&self, total_difficulty: Difficulty, height: u64)
[src]
pub fn check_all(&self, total_difficulty: Difficulty, height: u64)
Ping all our connected peers. Always automatically expects a pong back or disconnects. This acts as a liveness test.
pub fn all_peers(&self) -> Vec<PeerData>
[src]
pub fn all_peers(&self) -> Vec<PeerData>
All peer information we have in storage
pub fn find_peers(
&self,
state: State,
cap: Capabilities,
count: usize
) -> Vec<PeerData>
[src]
pub fn find_peers(
&self,
state: State,
cap: Capabilities,
count: usize
) -> Vec<PeerData>
Find peers in store (not necessarily connected) and return their data
pub fn get_peer(&self, peer_addr: SocketAddr) -> Result<PeerData, Error>
[src]
pub fn get_peer(&self, peer_addr: SocketAddr) -> Result<PeerData, Error>
Get peer in store by address
pub fn exists_peer(&self, peer_addr: SocketAddr) -> Result<bool, Error>
[src]
pub fn exists_peer(&self, peer_addr: SocketAddr) -> Result<bool, Error>
Whether we've already seen a peer with the provided address
pub fn save_peer(&self, p: &PeerData) -> Result<(), Error>
[src]
pub fn save_peer(&self, p: &PeerData) -> Result<(), Error>
Saves updated information about a peer
pub fn update_state(
&self,
peer_addr: SocketAddr,
new_state: State
) -> Result<(), Error>
[src]
pub fn update_state(
&self,
peer_addr: SocketAddr,
new_state: State
) -> Result<(), Error>
Updates the state of a peer in store
pub fn clean_peers(&self, max_count: usize)
[src]
pub fn clean_peers(&self, max_count: usize)
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.
pub fn stop(&self)
[src]
pub fn stop(&self)
pub fn enough_peers(&self) -> bool
[src]
pub fn enough_peers(&self) -> bool
pub fn remove_expired(&self)
[src]
pub fn remove_expired(&self)
Removes those peers that seem to have expired
Trait Implementations
impl ChainAdapter for Peers
[src]
impl ChainAdapter for Peers
fn total_difficulty(&self) -> Difficulty
[src]
fn total_difficulty(&self) -> Difficulty
Current total difficulty on our chain
fn total_height(&self) -> u64
[src]
fn total_height(&self) -> u64
Current total height
fn transaction_received(&self, tx: Transaction, stem: bool)
[src]
fn transaction_received(&self, tx: Transaction, stem: bool)
A valid transaction has been received from one of our peers
fn block_received(&self, b: Block, peer_addr: SocketAddr) -> bool
[src]
fn block_received(&self, b: Block, peer_addr: SocketAddr) -> bool
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
fn compact_block_received(
&self,
cb: CompactBlock,
peer_addr: SocketAddr
) -> bool
[src]
fn compact_block_received(
&self,
cb: CompactBlock,
peer_addr: SocketAddr
) -> bool
fn header_received(&self, bh: BlockHeader, peer_addr: SocketAddr) -> bool
[src]
fn header_received(&self, bh: BlockHeader, peer_addr: SocketAddr) -> bool
fn headers_received(
&self,
headers: Vec<BlockHeader>,
peer_addr: SocketAddr
) -> bool
[src]
fn headers_received(
&self,
headers: Vec<BlockHeader>,
peer_addr: SocketAddr
) -> bool
A set of block header has been received, typically in response to a block header request. Read more
fn locate_headers(&self, hs: Vec<Hash>) -> Vec<BlockHeader>
[src]
fn locate_headers(&self, hs: Vec<Hash>) -> Vec<BlockHeader>
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
fn get_block(&self, h: Hash) -> Option<Block>
[src]
fn get_block(&self, h: Hash) -> Option<Block>
Gets a full block by its hash.
fn txhashset_read(&self, h: Hash) -> Option<TxHashSetRead>
[src]
fn txhashset_read(&self, h: Hash) -> Option<TxHashSetRead>
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
fn txhashset_receive_ready(&self) -> bool
[src]
fn txhashset_receive_ready(&self) -> bool
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
fn txhashset_write(
&self,
h: Hash,
txhashset_data: File,
peer_addr: SocketAddr
) -> bool
[src]
fn txhashset_write(
&self,
h: Hash,
txhashset_data: File,
peer_addr: SocketAddr
) -> bool
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
fn txhashset_download_update(
&self,
start_time: DateTime<Utc>,
downloaded_size: u64,
total_size: u64
) -> bool
[src]
fn txhashset_download_update(
&self,
start_time: DateTime<Utc>,
downloaded_size: u64,
total_size: u64
) -> bool
Update txhashset downloading progress
impl NetAdapter for Peers
[src]
impl NetAdapter for Peers
fn find_peer_addrs(&self, capab: Capabilities) -> Vec<SocketAddr>
[src]
fn find_peer_addrs(&self, capab: Capabilities) -> Vec<SocketAddr>
Find good peers we know with the provided capability and return their addresses.
fn peer_addrs_received(&self, peer_addrs: Vec<SocketAddr>)
[src]
fn peer_addrs_received(&self, peer_addrs: Vec<SocketAddr>)
A list of peers has been received from one of our peers.
fn peer_difficulty(&self, addr: SocketAddr, diff: Difficulty, height: u64)
[src]
fn peer_difficulty(&self, addr: SocketAddr, diff: Difficulty, height: u64)
Heard total_difficulty from a connected peer (via ping/pong).
fn is_banned(&self, addr: SocketAddr) -> bool
[src]
fn is_banned(&self, addr: SocketAddr) -> bool
Is this peer currently banned?
impl Send for Peers
[src]
impl Send for Peers
impl Sync for Peers
[src]
impl Sync for Peers
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 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, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> SafeBorrow for T where
T: ?Sized,
impl<T> SafeBorrow for T where
T: ?Sized,
fn borrow_replacement(ptr: &T) -> &T
fn borrow_replacement(ptr: &T) -> &T
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> UnsafeAny for T where
T: Any,
impl<T> Erased for T
impl<T> Erased for T
impl<T> Same for T
impl<T> Same for T
type Output = T
Should always be Self