Struct bitcoin_peerman::Peer
source · pub struct Peer {Show 20 fields
pub id: NodeId,
pub misbehavior: Arc<Mutex<PeerMisbehavior>>,
pub block_inv_mutex: Arc<Mutex<PeerBlockInv>>,
pub starting_height: Atomic<i32>,
pub ping_nonce_sent: Atomic<u64>,
pub ping_start: Atomic<OffsetDateTime>,
pub ping_queued: AtomicBool,
pub addrs_to_send: Arc<Mutex<Vec<Address>>>,
pub addr_known: Option<RollingBloomFilter>,
pub addr_relay_enabled: AtomicBool,
pub getaddr_sent: bool,
pub addr_send_times_mutex: Arc<Mutex<PeerAddrSendTimes>>,
pub wants_addrv2: AtomicBool,
pub getaddr_recvd: bool,
pub addr_token_bucket: f64,
pub addr_token_timestamp: OffsetDateTime,
pub addr_rate_limited: Atomic<u64>,
pub addr_processed: Atomic<u64>,
pub orphan_work_set: PeerOrphans,
pub getdata_requests: Arc<Mutex<VecDeque<Inv>>>,
}Expand description
| Data structure for an individual peer. | This struct is not protected by CS_MAIN | since it does not contain validation-critical | data. | | Memory is owned by shared pointers and | this object is destructed when the refcount | drops to zero. | | Mutexes inside this struct must not | be held when locking m_peer_mutex. | | TODO: move most members from NodeState | to this structure. | | TODO: move remaining application-layer | data members from Node to this structure. |
Fields§
§id: NodeId| Same id as the Node object for this peer |
misbehavior: Arc<Mutex<PeerMisbehavior>>| Protects misbehavior data members |
block_inv_mutex: Arc<Mutex<PeerBlockInv>>| Protects block inventory data members |
starting_height: Atomic<i32>| This peer’s reported block height when | we connected |
ping_nonce_sent: Atomic<u64>| The pong reply we’re expecting, or 0 | if no pong expected. |
ping_start: Atomic<OffsetDateTime>| When the last ping was sent, or 0 if no | ping was ever sent |
ping_queued: AtomicBool| Whether a ping has been requested by | the user |
addrs_to_send: Arc<Mutex<Vec<Address>>>| A vector of addresses to send to the peer, | limited to MAX_ADDR_TO_SEND. |
addr_known: Option<RollingBloomFilter>| Probabilistic filter to track recent | addr messages relayed with this peer. | Used to avoid relaying redundant addresses | to this peer. | | We initialize this filter for outbound | peers (other than block-relay-only | connections) or when an inbound peer | sends us an address related message | (ADDR, ADDRV2, GETADDR). | | Presence of this filter must correlate | with m_addr_relay_enabled. |
addr_relay_enabled: AtomicBool| Whether we are participating in address | relay with this connection. | | We set this bool to true for outbound | peers (other than block-relay-only | connections), or when an inbound peer | sends us an address related message | (ADDR, ADDRV2, GETADDR). | | We use this bool to decide whether a peer | is eligible for gossiping addr messages. | This avoids relaying to peers that are | unlikely to forward them, effectively | blackholing self announcements. Reasons | peers might support addr relay on the | link include that they connected to | us as a block-relay-only peer or they | are a light client. | | This field must correlate with whether | m_addr_known has been initialized. |
getaddr_sent: bool| Whether a getaddr request to this peer | is outstanding. |
addr_send_times_mutex: Arc<Mutex<PeerAddrSendTimes>>| Guards address sending timers. |
wants_addrv2: AtomicBool| Whether the peer has signaled support | for receiving ADDRv2 (BIP155) messages, | indicating a preference to receive | ADDRv2 instead of ADDR ones. |
getaddr_recvd: bool| Whether this peer has already sent us | a getaddr message. |
addr_token_bucket: f64| Number of addresses that can be processed | from this peer. Start at 1 to permit self-announcement. |
addr_token_timestamp: OffsetDateTime| When m_addr_token_bucket was last | updated |
addr_rate_limited: Atomic<u64>| Total number of addresses that were | dropped due to rate limiting. |
addr_processed: Atomic<u64>| Total number of addresses that were | processed (excludes rate-limited | ones). |
orphan_work_set: PeerOrphans§getdata_requests: Arc<Mutex<VecDeque<Inv>>>| Work queue of items requested by this | peer |
Implementations§
source§impl Peer
impl Peer
pub fn add_address_known(&mut self, addr: &Address)
sourcepub fn is_addr_compatible(&self, addr: &Address) -> bool
pub fn is_addr_compatible(&self, addr: &Address) -> bool
| Whether the peer supports the address. | For example, a peer that does not implement | BIP155 cannot receive Tor v3 addresses | because it requires | | ADDRv2 (BIP155) encoding. |