[−][src]Struct grin_p2p::Peers
Fields
adapter: Arc<dyn ChainAdapter>
Methods
impl Peers
[src]
pub fn new(
store: PeerStore,
adapter: Arc<dyn ChainAdapter>,
config: P2PConfig
) -> Peers
[src]
store: PeerStore,
adapter: Arc<dyn ChainAdapter>,
config: P2PConfig
) -> Peers
pub fn add_connected(&self, peer: Arc<Peer>) -> Result<(), Error>
[src]
Adds the peer to our internal peer mapping. Note that the peer is still returned so the server can run it.
pub fn add_banned(
&self,
addr: PeerAddr,
ban_reason: ReasonForBan
) -> Result<(), Error>
[src]
&self,
addr: PeerAddr,
ban_reason: ReasonForBan
) -> Result<(), Error>
Add a peer as banned to block future connections, usually due to failed handshake
pub fn is_known(&self, addr: PeerAddr) -> bool
[src]
pub fn connected_peers(&self) -> Vec<Arc<Peer>>
[src]
Get vec of peers we are currently connected to.
pub fn outgoing_connected_peers(&self) -> Vec<Arc<Peer>>
[src]
pub fn get_connected_peer(&self, addr: PeerAddr) -> Option<Arc<Peer>>
[src]
Get a peer we're connected to by address.
pub fn peer_count(&self) -> u32
[src]
Number of peers currently connected to.
pub fn peer_outbound_count(&self) -> u32
[src]
Number of outbound peers currently connected to.
pub fn more_work_peers(&self) -> Result<Vec<Arc<Peer>>, Error>
[src]
pub fn more_or_same_work_peers(&self) -> Result<usize, Error>
[src]
pub fn more_work_peer(&self) -> Option<Arc<Peer>>
[src]
Returns single random peer with more work than us.
pub fn most_work_peers(&self) -> Vec<Arc<Peer>>
[src]
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]
Returns single random peer with the most worked branch, showing the highest total difficulty.
pub fn is_banned(&self, peer_addr: PeerAddr) -> bool
[src]
pub fn ban_peer(&self, peer_addr: PeerAddr, ban_reason: ReasonForBan)
[src]
Ban a peer, disconnecting it if we're currently connected
pub fn unban_peer(&self, peer_addr: PeerAddr)
[src]
Unban a peer, checks if it exists and banned then unban
pub fn broadcast_compact_block(&self, b: &CompactBlock)
[src]
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]
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_transaction(&self, tx: &Transaction)
[src]
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]
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]
All peer information we have in storage
pub fn find_peers(
&self,
state: State,
cap: Capabilities,
count: usize
) -> Vec<PeerData>
[src]
&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: PeerAddr) -> Result<PeerData, Error>
[src]
Get peer in store by address
pub fn exists_peer(&self, peer_addr: PeerAddr) -> Result<bool, Error>
[src]
Whether we've already seen a peer with the provided address
pub fn save_peer(&self, p: &PeerData) -> Result<(), Error>
[src]
Saves updated information about a peer
pub fn update_state(
&self,
peer_addr: PeerAddr,
new_state: State
) -> Result<(), Error>
[src]
&self,
peer_addr: PeerAddr,
new_state: State
) -> Result<(), Error>
Updates the state of a peer in store
pub fn clean_peers(&self, max_count: usize)
[src]
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 enough_peers(&self) -> bool
[src]
pub fn healthy_peers_mix(&self) -> bool
[src]
We have enough peers, both total connected and outbound connected
pub fn remove_expired(&self)
[src]
Removes those peers that seem to have expired
Trait Implementations
impl ChainAdapter for Peers
[src]
fn total_difficulty(&self) -> Result<Difficulty, Error>
[src]
fn total_height(&self) -> Result<u64, Error>
[src]
fn get_transaction(&self, kernel_hash: Hash) -> Option<Transaction>
[src]
fn tx_kernel_received(
&self,
kernel_hash: Hash,
peer_info: &PeerInfo
) -> Result<bool, Error>
[src]
&self,
kernel_hash: Hash,
peer_info: &PeerInfo
) -> Result<bool, Error>
fn transaction_received(
&self,
tx: Transaction,
stem: bool
) -> Result<bool, Error>
[src]
&self,
tx: Transaction,
stem: bool
) -> Result<bool, Error>
fn block_received(
&self,
b: Block,
peer_info: &PeerInfo,
was_requested: bool
) -> Result<bool, Error>
[src]
&self,
b: Block,
peer_info: &PeerInfo,
was_requested: bool
) -> Result<bool, Error>
fn compact_block_received(
&self,
cb: CompactBlock,
peer_info: &PeerInfo
) -> Result<bool, Error>
[src]
&self,
cb: CompactBlock,
peer_info: &PeerInfo
) -> Result<bool, Error>
fn header_received(
&self,
bh: BlockHeader,
peer_info: &PeerInfo
) -> Result<bool, Error>
[src]
&self,
bh: BlockHeader,
peer_info: &PeerInfo
) -> Result<bool, Error>
fn headers_received(
&self,
headers: &[BlockHeader],
peer_info: &PeerInfo
) -> Result<bool, Error>
[src]
&self,
headers: &[BlockHeader],
peer_info: &PeerInfo
) -> Result<bool, Error>
fn locate_headers(&self, hs: &[Hash]) -> Result<Vec<BlockHeader>, Error>
[src]
fn get_block(&self, h: Hash) -> Option<Block>
[src]
fn kernel_data_read(&self) -> Result<File, Error>
[src]
fn kernel_data_write(&self, reader: &mut dyn Read) -> Result<bool, Error>
[src]
fn txhashset_read(&self, h: Hash) -> Option<TxHashSetRead>
[src]
fn txhashset_receive_ready(&self) -> bool
[src]
fn txhashset_write(
&self,
h: Hash,
txhashset_data: File,
peer_info: &PeerInfo
) -> Result<bool, Error>
[src]
&self,
h: Hash,
txhashset_data: File,
peer_info: &PeerInfo
) -> Result<bool, Error>
fn txhashset_download_update(
&self,
start_time: DateTime<Utc>,
downloaded_size: u64,
total_size: u64
) -> bool
[src]
&self,
start_time: DateTime<Utc>,
downloaded_size: u64,
total_size: u64
) -> bool
fn get_tmp_dir(&self) -> PathBuf
[src]
fn get_tmpfile_pathname(&self, tmpfile_name: String) -> PathBuf
[src]
impl NetAdapter for Peers
[src]
fn find_peer_addrs(&self, capab: Capabilities) -> Vec<PeerAddr>
[src]
Find good peers we know with the provided capability and return their addresses.
fn peer_addrs_received(&self, peer_addrs: Vec<PeerAddr>)
[src]
A list of peers has been received from one of our peers.
fn peer_difficulty(&self, addr: PeerAddr, diff: Difficulty, height: u64)
[src]
fn is_banned(&self, addr: PeerAddr) -> bool
[src]
Auto Trait Implementations
impl Send for Peers
impl Unpin for Peers
impl Sync for Peers
impl !UnwindSafe for Peers
impl !RefUnwindSafe for Peers
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> UnsafeAny for T where
T: Any,
T: Any,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> Erased for T
impl<T> SafeBorrow<T> for T where
T: ?Sized,
T: ?Sized,
fn borrow_replacement(ptr: &T) -> &T
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,