Bitcoin
Classes | Typedefs | Functions | Variables
anonymous_namespace{net_processing.cpp} Namespace Reference

Classes

struct  CBlockReject
 
struct  CNodeState
 
class  CompareInvMempoolOrder
 
struct  IteratorComparator
 
struct  QueuedBlock
 

Typedefs

typedef std::map< uint256, CTransactionRefMapRelay
 

Functions

int nSyncStarted GUARDED_BY (cs_main)=0
 
std::atomic< int64_tg_last_tip_update (0)
 
std::map< COutPoint, std::set< std::map< uint256, COrphanTx >::iterator, IteratorComparator > > mapOrphanTransactionsByPrev GUARDED_BY (g_cs_orphans)=0
 For random eviction. More...
 
static CNodeStateState (NodeId pnode) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
static void UpdatePreferredDownload (CNode *node, CNodeState *state) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
static void PushNodeVersion (CNode *pnode, CConnman *connman, int64_t nTime)
 
static bool MarkBlockAsReceived (const uint256 &hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
static bool MarkBlockAsInFlight (NodeId nodeid, const uint256 &hash, const CBlockIndex *pindex=nullptr, std::list< QueuedBlock >::iterator **pit=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
static void ProcessBlockAvailability (NodeId nodeid) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
static void UpdateBlockAvailability (NodeId nodeid, const uint256 &hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
static void MaybeSetPeerAsAnnouncingHeaderAndIDs (NodeId nodeid, CConnman *connman) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
static bool TipMayBeStale (const Consensus::Params &consensusParams) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
static bool CanDirectFetch (const Consensus::Params &consensusParams) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
static bool PeerHasHeader (CNodeState *state, const CBlockIndex *pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
static void FindNextBlocksToDownload (NodeId nodeid, unsigned int count, std::vector< const CBlockIndex * > &vBlocks, NodeId &nodeStaller, const Consensus::Params &consensusParams) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
void EraseTxRequest (const uint256 &txid) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
int64_t GetTxRequestTime (const uint256 &txid) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
void UpdateTxRequestTime (const uint256 &txid, int64_t request_time) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
int64_t CalculateTxGetDataTime (const uint256 &txid, int64_t current_time, bool use_inbound_delay) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
void RequestTx (CNodeState *state, const uint256 &txid, int64_t nNow) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 

Variables

limitedmap< uint256, int64_t > g_already_asked_for GUARDED_BY() cs_main (MAX_INV_SZ)
 

Typedef Documentation

◆ MapRelay

typedef std::map<uint256, CTransactionRef> anonymous_namespace{net_processing.cpp}::MapRelay

Relay map

Function Documentation

◆ CalculateTxGetDataTime()

int64_t anonymous_namespace{net_processing.cpp}::CalculateTxGetDataTime ( const uint256 txid,
int64_t  current_time,
bool  use_inbound_delay 
)

◆ CanDirectFetch()

static bool anonymous_namespace{net_processing.cpp}::CanDirectFetch ( const Consensus::Params consensusParams)
static

◆ EraseTxRequest()

void anonymous_namespace{net_processing.cpp}::EraseTxRequest ( const uint256 txid)

◆ FindNextBlocksToDownload()

static void anonymous_namespace{net_processing.cpp}::FindNextBlocksToDownload ( NodeId  nodeid,
unsigned int  count,
std::vector< const CBlockIndex * > &  vBlocks,
NodeId nodeStaller,
const Consensus::Params consensusParams 
)
static

Update pindexLastCommonBlock and add not-in-flight missing successors to vBlocks, until it has at most count entries.

◆ g_last_tip_update()

std::atomic<int64_t> anonymous_namespace{net_processing.cpp}::g_last_tip_update ( )

When our tip was last updated.

◆ GetTxRequestTime()

int64_t anonymous_namespace{net_processing.cpp}::GetTxRequestTime ( const uint256 txid)

◆ GUARDED_BY() [1/2]

MapRelay mapRelay anonymous_namespace{net_processing.cpp}::GUARDED_BY ( cs_main  )
pure virtual

Number of nodes with fSyncStarted.

Sources of received blocks, saved to be able to send them reject messages or ban them when processing happens afterwards. Set mapBlockSource[hash].second to false if the node should not be punished if the block is invalid.

Filter for transactions that were recently rejected by AcceptToMemoryPool. These are not rerequested until the chain tip changes, at which point the entire filter is reset.

Without this filter we'd be re-requesting txs from each of our peers, increasing bandwidth consumption considerably. For instance, with 100 peers, half of which relay a tx we don't accept, that might be a 50x bandwidth increase. A flooding attacker attempting to roll-over the filter using minimum-sized, 60byte, transactions might manage to send 1000/sec if we have fast peers, so we pick 120,000 to give our peers a two minute window to send invs to us.

Decreasing the false positive rate is fairly cheap, so we pick one in a million to make it highly unlikely for users to have issues with this filter.

Memory used: 1.3 MB

Stack of nodes which we have set to announce using compact blocks

Number of preferable block download peers.

Number of peers from which we're downloading blocks.

Number of outbound peers with m_chain_sync.m_protect.

Expiration-time ordered list of (expire time, relay map entry) pairs.

Map maintaining per-node state.

◆ GUARDED_BY() [2/2]

static std::vector< std::pair< uint256, CTransactionRef > > vExtraTxnForCompact anonymous_namespace{net_processing.cpp}::GUARDED_BY ( g_cs_orphans  )

For random eviction.

◆ MarkBlockAsInFlight()

static bool anonymous_namespace{net_processing.cpp}::MarkBlockAsInFlight ( NodeId  nodeid,
const uint256 hash,
const CBlockIndex pindex = nullptr,
std::list< QueuedBlock >::iterator **  pit = nullptr 
)
static

◆ MarkBlockAsReceived()

static bool anonymous_namespace{net_processing.cpp}::MarkBlockAsReceived ( const uint256 hash)
static

◆ MaybeSetPeerAsAnnouncingHeaderAndIDs()

static void anonymous_namespace{net_processing.cpp}::MaybeSetPeerAsAnnouncingHeaderAndIDs ( NodeId  nodeid,
CConnman connman 
)
static

When a peer sends us a valid block, instruct it to announce blocks to us using CMPCTBLOCK if possible by adding its nodeid to the end of lNodesAnnouncingHeaderAndIDs, and keeping that list under a certain size by removing the first element if necessary.

◆ PeerHasHeader()

static bool anonymous_namespace{net_processing.cpp}::PeerHasHeader ( CNodeState state,
const CBlockIndex pindex 
)
static

◆ ProcessBlockAvailability()

static void anonymous_namespace{net_processing.cpp}::ProcessBlockAvailability ( NodeId  nodeid)
static

Check whether the last unknown block a peer advertised is not yet known.

◆ PushNodeVersion()

static void anonymous_namespace{net_processing.cpp}::PushNodeVersion ( CNode pnode,
CConnman connman,
int64_t  nTime 
)
static

◆ RequestTx()

void anonymous_namespace{net_processing.cpp}::RequestTx ( CNodeState state,
const uint256 txid,
int64_t  nNow 
)

◆ State()

static CNodeState* anonymous_namespace{net_processing.cpp}::State ( NodeId  pnode)
static

◆ TipMayBeStale()

static bool anonymous_namespace{net_processing.cpp}::TipMayBeStale ( const Consensus::Params consensusParams)
static

◆ UpdateBlockAvailability()

static void anonymous_namespace{net_processing.cpp}::UpdateBlockAvailability ( NodeId  nodeid,
const uint256 hash 
)
static

Update tracking information about which blocks a peer is assumed to have.

◆ UpdatePreferredDownload()

static void anonymous_namespace{net_processing.cpp}::UpdatePreferredDownload ( CNode node,
CNodeState state 
)
static

◆ UpdateTxRequestTime()

void anonymous_namespace{net_processing.cpp}::UpdateTxRequestTime ( const uint256 txid,
int64_t  request_time 
)

Variable Documentation

◆ cs_main

limitedmap<uint256, int64_t> g_already_asked_for GUARDED_BY() anonymous_namespace{net_processing.cpp}::cs_main(MAX_INV_SZ)