Struct bitcoin_node::Node

source ·
pub struct Node {
Show 44 fields pub deserializer: Option<Box<dyn TransportDeserializer>>, pub serializer: Option<Box<dyn TransportSerializer>>, pub permission_flags: NetPermissionFlags, pub n_services: Atomic<ServiceFlags>, pub cs_v_send: Arc<Mutex<NodeVSend>>, pub cs_h_socket: Arc<Mutex<NodeHSocket>>, pub cs_v_recv: Arc<Mutex<NodeVRecv>>, pub cs_v_process_msg: Arc<Mutex<NodeVProcessMsg>>, pub n_process_queue_size: AtomicUsize, pub cs_send_processing: RawMutex, pub n_last_send: Atomic<Option<OffsetDateTime>>, pub n_last_recv: Atomic<Option<OffsetDateTime>>, pub n_time_connected: Atomic<Option<OffsetDateTime>>, pub n_time_offset: Atomic<Option<Duration>>, pub addr: Address, pub addr_bind: Address, pub addr_name: String, pub inbound_onion: bool, pub n_version: AtomicI32, pub clean_sub_ver: Arc<Mutex<String>>, pub prefer_evict: bool, pub client: bool, pub limited_node: bool, pub successfully_connected: AtomicBool, pub disconnect: AtomicBool, pub grant_outbound: SemaphoreGrant, pub n_ref_count: AtomicI32, pub n_keyed_net_group: u64, pub pause_recv: AtomicBool, pub pause_send: AtomicBool, pub bip152_highbandwidth_to: AtomicBool, pub bip152_highbandwidth_from: AtomicBool, pub tx_relay: Amo<NodeTxRelay>, pub n_last_block_time: Atomic<Option<OffsetDateTime>>, pub n_last_tx_time: Atomic<Option<OffsetDateTime>>, pub last_ping_time: Atomic<Option<Instant>>, pub min_ping_time: Atomic<Option<Duration>>, pub id: NodeId, pub n_local_host_nonce: u64, pub conn_type: Option<ConnectionType>, pub greatest_common_version: AtomicI32, pub n_local_services: ServiceFlags, pub recv_msg: Arc<Mutex<Vec<NetMessage>>>, pub cs_addr_local: Arc<Mutex<NodeAddrLocal>>,
}
Expand description

| Information about a peer |

Fields§

§deserializer: Option<Box<dyn TransportDeserializer>>§serializer: Option<Box<dyn TransportSerializer>>§permission_flags: NetPermissionFlags§n_services: Atomic<ServiceFlags>§cs_v_send: Arc<Mutex<NodeVSend>>§cs_h_socket: Arc<Mutex<NodeHSocket>>§cs_v_recv: Arc<Mutex<NodeVRecv>>§cs_v_process_msg: Arc<Mutex<NodeVProcessMsg>>§n_process_queue_size: AtomicUsize§cs_send_processing: RawMutex§n_last_send: Atomic<Option<OffsetDateTime>>§n_last_recv: Atomic<Option<OffsetDateTime>>§n_time_connected: Atomic<Option<OffsetDateTime>>

| Unix epoch time at peer connection, | in seconds. |

§n_time_offset: Atomic<Option<Duration>>§addr: Address

| Address of this peer |

§addr_bind: Address

| Bind address of our side of the connection |

§addr_name: String§inbound_onion: bool

| Whether this peer is an inbound onion, | i.e. connected via our Tor onion service. |

§n_version: AtomicI32§clean_sub_ver: Arc<Mutex<String>>

| cleanSubVer is a sanitized string of | the user agent byte array we read from | the wire. This cleaned string can safely | be logged or displayed. |

§prefer_evict: bool

| This peer is preferred for eviction. |

§client: bool

| set by version message |

§limited_node: bool

| after BIP159, set by version message |

§successfully_connected: AtomicBool

| fSuccessfullyConnected is set to true | on receiving VERACK from the peer. |

§disconnect: AtomicBool

| Setting fDisconnect to true will cause | the node to be disconnected the next | time | | DisconnectNodes() runs |

§grant_outbound: SemaphoreGrant§n_ref_count: AtomicI32§n_keyed_net_group: u64§pause_recv: AtomicBool§pause_send: AtomicBool§bip152_highbandwidth_to: AtomicBool

| We selected peer as (compact blocks) | high-bandwidth peer (BIP152) |

§bip152_highbandwidth_from: AtomicBool

| Peer selected us as (compact blocks) | high-bandwidth peer (BIP152) |

§tx_relay: Amo<NodeTxRelay>

| m_tx_relay == nullptr if we’re not relaying | transactions with this peer |

§n_last_block_time: Atomic<Option<OffsetDateTime>>

| UNIX epoch time of the last block received | from this peer that we had not yet seen | (e.g. not already received from another | peer), that passed preliminary validity | checks and was saved to disk, even if | we don’t connect the block or it eventually | fails connection. Used as an inbound | peer eviction criterium in Connman::AttemptToEvictConnection. |

§n_last_tx_time: Atomic<Option<OffsetDateTime>>

| UNIX epoch time of the last transaction | received from this peer that we had not | yet seen (e.g. not already received | from another peer) and that was accepted | into our mempool. Used as an inbound | peer eviction criterium in Connman::AttemptToEvictConnection. |

§last_ping_time: Atomic<Option<Instant>>

| Last measured round-trip time. Used | only for RPC/GUI stats/debugging. |

§min_ping_time: Atomic<Option<Duration>>

| Lowest measured round-trip time. Used | as an inbound peer eviction criterium | in Connman::AttemptToEvictConnection. |

§id: NodeId§n_local_host_nonce: u64§conn_type: Option<ConnectionType>§greatest_common_version: AtomicI32§n_local_services: ServiceFlags

| Services offered to this peer. | | This is supplied by the parent Connman | during peer connection | (Connman::ConnectNode()) from its | attribute of the same name. | | This is const because there is no protocol | defined for renegotiating services | initially offered to a peer. The set of | local services we offer should not change | after initialization. | | An interesting example of this is | NODE_NETWORK and initial block download: | a node which starts up from scratch | doesn’t have any blocks to serve, but | still advertises NODE_NETWORK because it | will eventually fulfill this role after | IBD completes. P2P code is written in such | a way that it can gracefully handle peers | who don’t make good on their service | advertisements.

§recv_msg: Arc<Mutex<Vec<NetMessage>>>

| Used only by SocketHandler thread |

§cs_addr_local: Arc<Mutex<NodeAddrLocal>>

Implementations§

Trait Implementations§

| Get network the peer connected through. | | Returns Network::NET_ONION for inbound | onion connections, and CNetAddr::GetNetClass() | otherwise. The latter cannot be used | directly because it doesn’t detect | the former, and it’s not the responsibility | of the CNetAddr class to know the actual | network a peer is connected through. | | | ———– | @return | | network the peer connected through. |

Returns the “default value” for a type. Read more
Executes the destructor for this type. Read more
| Disconnect the handler. |
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

| A ping-pong round trip has completed | successfully. Update latest and minimum | ping times. |

| Receive bytes from the buffer and deserialize | them into messages. | | ———– | @param[in] msg_bytes | | The raw data | ––––– | @param[out] complete | | Set True if at least one message has been | deserialized and is ready to be processed | | ———– | @return | | True if the peer should stay connected, | | False if the peer should be disconnected | from. |

| May not be called more than once |

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Performs the conversion. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Convert type of a const pointer. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.