Crate bitcoin_net

source ·

Structs

Enums

| Different types of connections to a | peer. This enum encapsulates the information | we have available at the time of opening | or accepting the connection. Aside | from INBOUND, all types are initiated | by us. | | If adding or removing types, please | update CONNECTION_TYPE_DOC in src/rpc/net.cpp | and src/qt/rpcconsole.cpp, as well | as the descriptions in src/qt/guiutil.cpp | and src/bitcoin-cli.cpp::NetinfoRequestHandler. |

Constants

| Anchor IP address database file name |
| Average delay between peer address | broadcasts |
| Average delay between feefilter broadcasts | in seconds. |
| Average delay between local address | broadcasts |
| Block download timeout base, expressed | in multiples of the block interval (i.e. | 10 min) |
| Additional block download timeout | per parallel downloading peer (i.e. | 5 min) |
| Size of the “block download window”: | how far ahead of our current height do | we fetch? | | Larger windows tolerate larger download | speed differences between peer, but | increase the potential degree of disordering | of blocks on disk (which make reindexing | and pruning harder). We’ll probably | want to make this a per-peer adaptive | value at some point. |
| Time during which a peer must stall block | download progress before being disconnected. |
| Timeout for (unprotected) outbound | peers to sync to our chainwork, in seconds |
| Default for blocks only |
| Default number of orphan+recently-replaced | txn to keep around for block reconstruction |
| -listen default |
| Default for -maxorphantx, maximum | number of orphan transactions kept | in memory |
| The maximum number of peer connections | to maintain. |
| The default for -maxuploadtarget. | 0 = Unlimited |
| -peertimeout default |
| Default for -whitelistforcerelay. |
| Default for -whitelistrelay. |
| Threshold for marking a node to be discouraged, | e.g. disconnected and added to the discouragement | filter. |
| How long to delay before querying DNS | seeds | | If we have more than THRESHOLD entries | in addrman, then it’s likely that we | got those addresses from having previously | connected to the P2P network, and that | we’ll be able to successfully reconnect | to the P2P network via contacting one | of them. So if that’s the case, spend | a little longer trying to connect to | known peers before querying the | | DNS seeds. |
| Number of DNS seeds to query when the | number of connections is low. |
| How often to dump addresses to peers.dat |
| Run the extra block-relay-only connection | loop once every 5 minutes. * |
| How frequently to check for extra outbound | peers and disconnect, in seconds |
| Run the feeler connection loop once | every 2 minutes. * |
| We add a random period time (0 to 1 seconds) | to feeler connections to prevent synchronization. |
| How long to wait (in microseconds) before | downloading a transaction from an additional | peer |
| Headers download timeout. | | Timeout = base + per_header * (expected | number of headers) |
| Age after which a block is considered | historical for purposes of rate limiting block | relay. Set to one week, denominated in | seconds.
| Average delay between trickled inventory | transmissions for inbound peers. | | Blocks and peers with NetPermissionFlags::NoBan | permission bypass this. |
| Maximum rate of inventory items to send | per second. | | Limits the impact of low-fee transaction | floods. |
| The number of most recently announced | transactions a peer can request. |
| Maximum number of addnode outgoing | nodes |
| The soft limit of the address processing | token bucket (the regular MAX_ADDR_RATE_PER_SECOND | based increments won’t go above this, | but the MAX_ADDR_TO_SEND increment | following GETADDR is exempt from this | limit). |
| The maximum rate of address records | we’re willing to process on average. | Can be bypassed using the NetPermissionFlags::Addr | permission. |
| The maximum number of address records | permitted in an ADDR message. |
| Number of blocks that can be requested | at any given time from a single peer. |
| Maximum number of headers to announce | when relaying blocks with headers message. |
| Maximum depth of blocks we’re willing | to respond to GETBLOCKTXN requests | for. |
| Maximum number of block-relay-only | anchor connections |
| Maximum number of block-relay-only | outgoing connections |
| Maximum depth of blocks we’re willing | to serve as compact blocks to peers when | requested. For older blocks, a regular | BLOCK response will be sent. |
| Maximum feefilter broadcast delay | after significant change. |
| Maximum number of feeler connections |
| Maximum number of cf hashes that may | be requested with one getcfheaders. | See BIP 157. |
| Maximum number of compact filters that | may be requested with one getcfilters. | See BIP 157. |
| Limit to avoid sending big packets. | Not used in processing incoming GETDATA | for compatibility |
| Number of headers sent in one getheaders | result. We rely on the assumption that | if a peer sends less than this number, | we reached its tip. Changing this value | is a protocol upgrade. |
| The maximum number of entries in an ‘inv’ | protocol message |
| The maximum number of entries in a locator |
| Maximum number of automatic outgoing | nodes over which we’ll relay everything | (blocks, tx, addrs, etc) |
| Protect at least this many outbound | peers from disconnection due to slow/ | behind headers chain. |
| the maximum percentage of addresses | from our addrman to return in response | to a getaddr message. |
| Maximum number of transactions to consider | for requesting, per peer. It provides | a reasonable DoS limit to per-peer memory | usage spent on announcements, while | covering peers continuously sending | INVs at the maximum rate (by our own policy, | see INVENTORY_BROADCAST_PER_SECOND) | for several minutes, while not receiving | the actual transaction (from any peer) | in response to requests for them. |
| Maximum number of in-flight transaction | requests from a peer. It is not a hard | limit, but the threshold at which point | the OVERLOADED_PEER_TX_DELAY kicks | in. |
| Maximum length of incoming protocol | messages (no message over 4 MB is currently | acceptable). |
| Maximum length of the user agent string | in version message |
| Maximum number of unconnecting headers | announcements before DoS score |
| The default timeframe for -maxuploadtarget. | 1 day. |
| Minimum time an outbound-peer-eviction | candidate must be connected for, in | order to evict, in seconds |
| Minimum blocks required to signal NODE_NETWORK_LIMITED |
| How long to delay requesting transactions | from non-preferred peers |
| Number of file descriptors required | for message capture * |
| Number of preferable block download | peers. |
| Average delay between trickled inventory | transmissions for outbound peers. | | Use a smaller delay as there is less privacy | concern for them. | | Blocks and peers with NetPermissionFlags::NoBan | permission bypass this. |
| How long to delay requesting transactions | from overloaded peers (see MAX_PEER_TX_REQUEST_IN_FLIGHT). |
| Time between pings automatically sent | out for latency probing and keepalive |
| SHA256(“main address relay”)[0:8] |
| How long to cache transactions in mapRelay | for normal relay |
| The set of sockets cannot be modified while | waiting | | The sleep time needs to be small to avoid new | sockets stalling
| How frequently to check for stale tips, | in seconds |
| Age after which a stale block will no longer | be served if requested as protection against | fingerprinting. Set to one month, denominated | in seconds.
| Time after which to disconnect, after | waiting for a ping response (or inactivity). |
| How long to delay requesting transactions | via txids, if we have wtxid-relaying | peers |
| How long a transaction has to be in the | mempool before it can unconditionally | be relayed (even when not in mapRelay). |

Traits

| The TransportDeserializer takes care | of holding and deserializing the network | receive buffer. It can deserialize | the network buffer into a transport | protocol agnostic CNetMessage (command | & payload) |
| The TransportSerializer prepares | messages for the network transport |

Functions

| learn a new local address |
| Dump binary message to file, with timestamp |
| Convert ConnectionType enum to a string | value |
| Convert the serialized seeds into usable | address objects. |
| Get the bind address for a socket as CAddress |
| find ‘best’ local address for a particular | peer |
| get best local address for a particular peer as | a CAddress Otherwise, return the unroutable | 0.0.0.0 but filled in with the normal | parameters, since the IP may be changed to | a useful one by discovery.
| check whether a given address is potentially | local |
| Return a timestamp in the future (in | microseconds) for exponentially distributed | events. |
| Mark a network as reachable or unreachable | (no automatic connects to it) | | ———– | @note | | Networks are reachable by default |

Type Definitions