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§
source§impl Node
impl Node
pub fn new( id_in: NodeId, n_local_services_in: ServiceFlags, h_socket_in: CSocket, addr_in: &Address, n_keyed_net_group_in: u64, n_local_host_nonce_in: u64, addr_bind_in: &Address, addr_name_in: &String, conn_type_in: ConnectionType, inbound_onion: bool ) -> Self
pub fn get_addr_local(&self) -> Service
pub fn connection_type_as_string(&self) -> String
Trait Implementations§
source§impl AddKnownTx for Node
impl AddKnownTx for Node
fn add_known_tx(&mut self, hash: &u256)
source§impl CloseSocketDisconnect for Node
impl CloseSocketDisconnect for Node
fn close_socket_disconnect(&mut self)
source§impl ConnectedThroughNetwork for Node
impl ConnectedThroughNetwork for Node
source§fn connected_through_network(&self) -> Network
fn connected_through_network(&self) -> Network
| 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. |
source§impl DecrementNProcessQueueSize for Node
impl DecrementNProcessQueueSize for Node
fn decrement_n_process_queue_size(&self, val: usize)
source§impl DisconnectOnStall for Node
impl DisconnectOnStall for Node
fn disconnect_on_stall(&self)
source§impl ExpectServicesFromConn for Node
impl ExpectServicesFromConn for Node
fn expect_services_from_conn(&self) -> bool
source§impl GetCommonVersion for Node
impl GetCommonVersion for Node
fn get_common_version(&self) -> i32
source§impl GetLocalNonce for Node
impl GetLocalNonce for Node
fn get_local_nonce(&self) -> u64
source§impl GetLocalServices for Node
impl GetLocalServices for Node
fn get_local_services(&self) -> ServiceFlags
source§impl GetNProcessQueueSize for Node
impl GetNProcessQueueSize for Node
fn get_n_process_queue_size(&self) -> usize
source§impl GetNTimeConnected for Node
impl GetNTimeConnected for Node
fn get_n_time_connected(&self) -> OffsetDateTime
source§impl GetRefCount for Node
impl GetRefCount for Node
fn get_ref_count(&self) -> i32
source§impl GetServiceMut for Node
impl GetServiceMut for Node
fn service_mut(&mut self) -> &mut Service
source§impl GetTransportSerializer for Node
impl GetTransportSerializer for Node
fn get_transport_serializer(&self) -> &Box<dyn TransportSerializer>
source§impl GetTransportSerializerMut for Node
impl GetTransportSerializerMut for Node
fn get_transport_serializer_mut(&mut self) -> &mut Box<dyn TransportSerializer>
source§impl GetTxRelay for Node
impl GetTxRelay for Node
fn get_tx_relay(&self) -> AmoReadGuard<'_, NodeTxRelay>
source§impl GetTxRelayMut for Node
impl GetTxRelayMut for Node
fn get_tx_relay_mut(&self) -> AmoWriteGuard<'_, NodeTxRelay>
source§impl GrantOutbound for Node
impl GrantOutbound for Node
fn grant_outbound(&self) -> SemaphoreGrant
source§impl HasPermission for Node
impl HasPermission for Node
fn has_permission(&self, permission: NetPermissionFlags) -> bool
source§impl HasTxRelay for Node
impl HasTxRelay for Node
fn has_tx_relay(&self) -> bool
source§impl IncrementNProcessQueueSize for Node
impl IncrementNProcessQueueSize for Node
fn increment_n_process_queue_size(&self, x: usize)
source§impl IsAddrFetchConn for Node
impl IsAddrFetchConn for Node
fn is_addr_fetch_conn(&self) -> bool
source§impl IsBlockOnlyConn for Node
impl IsBlockOnlyConn for Node
fn is_block_only_conn(&self) -> bool
source§impl IsFeelerConn for Node
impl IsFeelerConn for Node
fn is_feeler_conn(&self) -> bool
source§impl IsFullOutboundConn for Node
impl IsFullOutboundConn for Node
fn is_full_outbound_conn(&self) -> bool
source§impl IsInboundConn for Node
impl IsInboundConn for Node
fn is_inbound_conn(&self) -> bool
source§impl IsLimitedNode for Node
impl IsLimitedNode for Node
fn is_limited_node(&self) -> bool
source§impl IsManualConn for Node
impl IsManualConn for Node
fn is_manual_conn(&self) -> bool
source§impl IsOutboundOrBlockRelayConn for Node
impl IsOutboundOrBlockRelayConn for Node
fn is_outbound_or_block_relay_conn(&self) -> bool
source§impl IsSuccessfullyConnected for Node
impl IsSuccessfullyConnected for Node
fn is_successfully_connected(&self) -> bool
source§impl LockHSocket for Node
impl LockHSocket for Node
fn lock_h_socket(&self) -> MutexGuard<'_, NodeHSocket>
source§impl LockRecvMsg for Node
impl LockRecvMsg for Node
fn lock_recv_msg(&self) -> MutexGuard<'_, Vec<NetMessage>>
source§impl LockSendProcessing for Node
impl LockSendProcessing for Node
unsafe fn lock_send_processing(&self)
source§impl LockVProcessMsg for Node
impl LockVProcessMsg for Node
fn lock_v_process_msg(&self) -> MutexGuard<'_, NodeVProcessMsg>
source§impl MarkForDisconnect for Node
impl MarkForDisconnect for Node
source§fn mark_for_disconnect(&self)
fn mark_for_disconnect(&self)
source§impl MarkedForDisconnect for Node
impl MarkedForDisconnect for Node
fn marked_for_disconnect(&self) -> bool
source§impl MinPingTime for Node
impl MinPingTime for Node
fn min_ping_time(&self) -> Option<Duration>
source§impl NKeyedNetGroup for Node
impl NKeyedNetGroup for Node
fn n_keyed_net_group(&self) -> u64
source§impl NLastBlockTime for Node
impl NLastBlockTime for Node
fn n_last_block_time(&self) -> Option<OffsetDateTime>
source§impl NLastTxTime for Node
impl NLastTxTime for Node
fn n_last_tx_time(&self) -> Option<OffsetDateTime>
source§impl NProcessQueueSize for Node
impl NProcessQueueSize for Node
fn n_process_queue_size(&self) -> usize
source§impl NServices for Node
impl NServices for Node
fn n_services(&self) -> ServiceFlags
source§impl NTimeConnected for Node
impl NTimeConnected for Node
fn n_time_connected(&self) -> Option<OffsetDateTime>
source§impl NodeInterfaceAddRef for Node
impl NodeInterfaceAddRef for Node
fn add_ref(&mut self) -> *mut dyn NodeInterface
source§impl PartialEq<Node> for Node
impl PartialEq<Node> for Node
source§impl PongReceived for Node
impl PongReceived for Node
source§fn pong_received(&mut self, ping_time: Duration)
fn pong_received(&mut self, ping_time: Duration)
| A ping-pong round trip has completed | successfully. Update latest and minimum | ping times. |
source§impl PreferEvict for Node
impl PreferEvict for Node
fn prefer_evict(&self) -> bool
source§impl PushTxInventory for Node
impl PushTxInventory for Node
fn push_tx_inventory(&mut self, hash: &u256)
source§impl ReceiveMsgBytes for Node
impl ReceiveMsgBytes for Node
source§fn receive_msg_bytes(&mut self, msg_bytes: &[u8], complete: &mut bool) -> bool
fn receive_msg_bytes(&mut self, msg_bytes: &[u8], complete: &mut bool) -> bool
| 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. |
source§impl ReleaseGrantOutbound for Node
impl ReleaseGrantOutbound for Node
fn release_grant_outbound(&mut self)
source§impl SendPaused for Node
impl SendPaused for Node
fn send_paused(&self) -> bool
source§impl SetAddrLocal for Node
impl SetAddrLocal for Node
source§fn set_addr_local(&mut self, addr_local_in: &Service)
fn set_addr_local(&mut self, addr_local_in: &Service)
| May not be called more than once |
source§impl SetBip152HighBandwidthFrom for Node
impl SetBip152HighBandwidthFrom for Node
fn set_bip152_highbandwidth_from(&mut self, x: bool)
source§impl SetBip152HighBandwidthTo for Node
impl SetBip152HighBandwidthTo for Node
fn set_bip152_highbandwidth_to(&mut self, x: bool)
source§impl SetCleanSubVer for Node
impl SetCleanSubVer for Node
fn set_clean_sub_ver(&mut self, x: &str)
source§impl SetCommonVersion for Node
impl SetCommonVersion for Node
fn set_common_version(&mut self, greatest_common_version: i32)
source§impl SetIsClient for Node
impl SetIsClient for Node
fn set_is_client(&mut self, x: bool)
source§impl SetLimitedNode for Node
impl SetLimitedNode for Node
fn set_limited_node(&mut self, x: bool)
source§impl SetNLastBlockTime for Node
impl SetNLastBlockTime for Node
fn set_n_last_block_time(&mut self, x: Option<OffsetDateTime>)
source§impl SetNLastTxTime for Node
impl SetNLastTxTime for Node
fn set_n_last_tx_time(&mut self, x: Option<OffsetDateTime>)
source§impl SetNServices for Node
impl SetNServices for Node
fn set_n_services(&mut self, x: ServiceFlags)
source§impl SetNTimeOffset for Node
impl SetNTimeOffset for Node
fn set_n_time_offset(&mut self, x: Option<Duration>)
source§impl SetNVersion for Node
impl SetNVersion for Node
fn set_n_version(&mut self, x: i32)
source§impl SetPauseRecv for Node
impl SetPauseRecv for Node
fn set_pause_recv(&self, x: bool)
source§impl SetPauseSend for Node
impl SetPauseSend for Node
fn set_pause_send(&self, x: bool)
source§impl SetPermissionFlags for Node
impl SetPermissionFlags for Node
fn set_permission_flags(&mut self, x: NetPermissionFlags)
source§impl SetPreferEvict for Node
impl SetPreferEvict for Node
fn set_prefer_evict(&mut self, x: bool)
source§impl SetSuccessfullyConnected for Node
impl SetSuccessfullyConnected for Node
fn set_successfully_connected(&self, val: bool)
source§impl SuccessfullyConnected for Node
impl SuccessfullyConnected for Node
fn successfully_connected(&self) -> bool
source§impl UnlockSendProcessing for Node
impl UnlockSendProcessing for Node
unsafe fn unlock_send_processing(&self)
impl Eq for Node
impl Send for Node
impl Sync for Node
Auto Trait Implementations§
Blanket Implementations§
§impl<T, U> CastInto<U> for Twhere
U: CastFrom<T>,
impl<T, U> CastInto<U> for Twhere U: CastFrom<T>,
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.