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

source

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

source

pub fn get_addr_local(&self) -> Service

source

pub fn connection_type_as_string(&self) -> String

Trait Implementations§

source§

impl AddKnownTx for Node

source§

fn add_known_tx(&mut self, hash: &u256)

source§

impl AddrBind for Node

source§

impl AddrName for Node

source§

fn addr_name(&self) -> &str

source§

impl CloseSocketDisconnect for Node

source§

impl ConnType for Node

source§

impl ConnectedThroughNetwork for Node

source§

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 CopyStats for Node

source§

fn copy_stats(&mut self, stats: &mut NodeStats)

source§

impl DecrementNProcessQueueSize for Node

source§

impl Default for Node

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl DisconnectOnStall for Node

source§

impl Drop for Node

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl ExpectServicesFromConn for Node

source§

impl GetAddrMut for Node

source§

fn addr_mut(&mut self) -> &mut Address

source§

impl GetAddrRef for Node

source§

fn addr(&self) -> &Address

source§

impl GetCommonVersion for Node

source§

impl GetLocalNonce for Node

source§

impl GetLocalServices for Node

source§

impl GetNProcessQueueSize for Node

source§

impl GetNTimeConnected for Node

source§

fn get_n_time_connected(&self) -> OffsetDateTime

source§

impl GetNodeId for Node

source§

fn get_id(&self) -> NodeId

source§

impl GetRefCount for Node

source§

impl GetServiceMut for Node

source§

fn service_mut(&mut self) -> &mut Service

source§

impl GetServiceRef for Node

source§

fn service(&self) -> &Service

source§

impl GetTransportSerializer for Node

source§

impl GetTransportSerializerMut for Node

source§

impl GetTxRelay for Node

source§

impl GetTxRelayMut for Node

source§

impl GrantOutbound for Node

source§

impl HasPermission for Node

source§

impl HasTxRelay for Node

source§

impl IncrementNProcessQueueSize for Node

source§

impl IsAddrFetchConn for Node

source§

impl IsBlockOnlyConn for Node

source§

impl IsClient for Node

source§

fn is_client(&self) -> bool

source§

impl IsFeelerConn for Node

source§

impl IsFullOutboundConn for Node

source§

impl IsInboundConn for Node

source§

impl IsLimitedNode for Node

source§

impl IsManualConn for Node

source§

impl IsOutboundOrBlockRelayConn for Node

source§

impl IsSuccessfullyConnected for Node

source§

impl LockHSocket for Node

source§

fn lock_h_socket(&self) -> MutexGuard<'_, NodeHSocket>

source§

impl LockRecvMsg for Node

source§

fn lock_recv_msg(&self) -> MutexGuard<'_, Vec<NetMessage>>

source§

impl LockSendProcessing for Node

source§

impl LockVProcessMsg for Node

source§

fn lock_v_process_msg(&self) -> MutexGuard<'_, NodeVProcessMsg>

source§

impl LockVSend for Node

source§

fn lock_v_send(&self) -> MutexGuard<'_, NodeVSend>

source§

impl MarkForDisconnect for Node

source§

fn mark_for_disconnect(&self)

| Disconnect the handler. |
source§

impl MarkedForDisconnect for Node

source§

impl MinPingTime for Node

source§

fn min_ping_time(&self) -> Option<Duration>

source§

impl NKeyedNetGroup for Node

source§

impl NLastBlockTime for Node

source§

fn n_last_block_time(&self) -> Option<OffsetDateTime>

source§

impl NLastRecv for Node

source§

fn n_last_recv(&self) -> Option<OffsetDateTime>

source§

impl NLastSend for Node

source§

fn n_last_send(&self) -> Option<OffsetDateTime>

source§

impl NLastTxTime for Node

source§

fn n_last_tx_time(&self) -> Option<OffsetDateTime>

source§

impl NProcessQueueSize for Node

source§

impl NServices for Node

source§

impl NTimeConnected for Node

source§

fn n_time_connected(&self) -> Option<OffsetDateTime>

source§

impl NVersion for Node

source§

fn n_version(&self) -> i32

source§

impl NodeInterfaceAddRef for Node

source§

fn add_ref(&mut self) -> *mut dyn NodeInterface

source§

impl PartialEq<Node> for Node

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PauseRecv for Node

source§

impl PongReceived for Node

source§

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

source§

impl PushTxInventory for Node

source§

fn push_tx_inventory(&mut self, hash: &u256)

source§

impl ReceiveMsgBytes for Node

source§

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 Release for Node

source§

fn release(&mut self)

source§

impl ReleaseGrantOutbound for Node

source§

impl SendPaused for Node

source§

impl SetAddrLocal for Node

source§

fn set_addr_local(&mut self, addr_local_in: &Service)

| May not be called more than once |

source§

impl SetBip152HighBandwidthFrom for Node

source§

impl SetBip152HighBandwidthTo for Node

source§

impl SetCleanSubVer for Node

source§

fn set_clean_sub_ver(&mut self, x: &str)

source§

impl SetCommonVersion for Node

source§

fn set_common_version(&mut self, greatest_common_version: i32)

source§

impl SetIsClient for Node

source§

fn set_is_client(&mut self, x: bool)

source§

impl SetLimitedNode for Node

source§

fn set_limited_node(&mut self, x: bool)

source§

impl SetNLastBlockTime for Node

source§

fn set_n_last_block_time(&mut self, x: Option<OffsetDateTime>)

source§

impl SetNLastTxTime for Node

source§

fn set_n_last_tx_time(&mut self, x: Option<OffsetDateTime>)

source§

impl SetNServices for Node

source§

impl SetNTimeOffset for Node

source§

fn set_n_time_offset(&mut self, x: Option<Duration>)

source§

impl SetNVersion for Node

source§

fn set_n_version(&mut self, x: i32)

source§

impl SetPauseRecv for Node

source§

impl SetPauseSend for Node

source§

impl SetPermissionFlags for Node

source§

impl SetPreferEvict for Node

source§

fn set_prefer_evict(&mut self, x: bool)

source§

impl SetSuccessfullyConnected for Node

source§

impl SuccessfullyConnected for Node

source§

impl UnlockSendProcessing for Node

source§

impl Eq for Node

source§

impl Send for Node

source§

impl Sync for Node

Auto Trait Implementations§

§

impl !RefUnwindSafe for Node

§

impl Unpin for Node

§

impl !UnwindSafe for Node

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T, U> CastInto<U> for Twhere U: CastFrom<T>,

§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> StaticUpcast<T> for T

§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V