| An announcement. This is the data we
| track for each txid or wtxid that is announced
| to us by each peer.
|
| Data type for the main data structure
| (Announcement objects with ByPeer/ByTxHash/ByTime
| indexes).
|
| using Index = boost::multi_index_container<
| Announcement,
| boost::multi_index::indexed_by<
| boost::multi_index::ordered_unique< boost::multi_index::tag, ByPeerViewExtractor>,
| boost::multi_index::ordered_non_unique<boost::multi_index::tag, ByTxHashViewExtractor>,
| boost::multi_index::ordered_non_unique<boost::multi_index::tag, ByTimeViewExtractor>
| >
| >;
| Global flag to indicate we should check
| to see if there are block/undo files
| that should be deleted. Set on startup
| or if we allocate more file space when
| we’re in prune mode
|
| True if any block files have ever been
| pruned.
|
| Number of MiB of block files that we’re
| trying to stay below.
|
| Maintain validation-specific state
| about nodes, protected by CS_MAIN,
| instead by Node’s own locks. This simplifies
| asynchronous operation, where processing
| of incoming data is done after the ProcessMessage
| call returns, and we’re no longer holding
| the node’s locks.
|
| State used to enforce CHAIN_SYNC_TIMEOUT
| and EXTRA_PEER_CHECK_INTERVAL logic.
|
| Both are only in effect for outbound,
| non-manual, non-protected connections.
|
| Any peer protected (m_protect = true)
| is not chosen for eviction. A peer is
| marked as protected if all of these are
| true:
|
| - its connection type is IsBlockOnlyConn() == false
|
| - it gave us a valid connecting header
|
| - we haven’t reached MAX_OUTBOUND_PEERS_TO_PROTECT_FROM_DISCONNECT
| yet
|
| - its chain tip has at least as much work
| as ours
|
| CHAIN_SYNC_TIMEOUT: if a peer’s best
| known block has less work than our tip,
| set a timeout CHAIN_SYNC_TIMEOUT seconds
| in the future:
|
| - If at timeout their best known block
| now has more work than our tip when the
| timeout was set, then either reset the
| timeout or clear it (after comparing
| against our current tip’s work)
|
| - If at timeout their best known block
| still has less work than our tip did when
| the timeout was set, then send a getheaders
| message, and set a shorter timeout,
| HEADERS_RESPONSE_TIME seconds in
| future.
|
| If their best known block is still behind
| when that new timeout is reached, disconnect.
|
| EXTRA_PEER_CHECK_INTERVAL: after
| each interval, if we have too many outbound
| peers, drop the outbound one that least
| recently announced us a new block.
|
| True if we’re running in -prune mode.
|
| 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.
|
| Per-peer statistics object.
|
| A functor with embedded salt that computes
| priority of an announcement.
|
| Higher priorities are selected first.
|
| Blocks that are in flight, and that are
| in the queue to be downloaded.
|
| Dirty block index entries.
|
| Dirty block file entries.
|
| Per-txhash statistics object. Only
| used for sanity checking.
|
| A class to track orphan transactions
| (failed on TX_MISSING_INPUTS)
|
| Since we cannot distinguish orphans
| from bad transactions with non-existent
| inputs, we heavily limit the number
| of orphans we keep and the duration we
| keep them for.
|
| Data structure to keep track of, and schedule,
| transaction downloads from peers.
|
| === Specification ===
|
| We keep track of which peers have announced
| which transactions, and use that to determine
| which requests should go to which peer, when,
| and in what order.
|
| The following information is tracked per
| peer/tx combination (“announcement”):
|
| - Which peer announced it (through their
| NodeId)
|
| - The txid or wtxid of the transaction
| (collectively called “txhash” in what follows)
|
| - Whether it was a tx or wtx announcement (see
| BIP339).
|
| - What the earliest permitted time is that that
| transaction can be requested from that peer
| (called “reqtime”).
|
| - Whether it’s from a “preferred” peer or
| not. Which announcements get this flag is
| determined by the caller, but this is
| designed for outbound peers, or other peers
| that we have a higher level of trust in. Even
| when the peers’ preferredness changes, the
| preferred flag of existing announcements from
| that peer won’t change.
|
| - Whether or not the transaction was requested
| already, and if so, when it times out (called
| “expiry”).
|
| - Whether or not the transaction request failed
| already (timed out, or invalid transaction or
| NOTFOUND was received).
|
| Actual implementation for TxRequestTracker’s
| data structure.
|