Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 126 Lines • ▼ Show 20 Lines | struct COrphanTx { | ||||
int64_t nTimeExpire; | int64_t nTimeExpire; | ||||
}; | }; | ||||
static CCriticalSection g_cs_orphans; | static CCriticalSection g_cs_orphans; | ||||
std::map<uint256, COrphanTx> mapOrphanTransactions GUARDED_BY(g_cs_orphans); | std::map<uint256, COrphanTx> mapOrphanTransactions GUARDED_BY(g_cs_orphans); | ||||
void EraseOrphansFor(NodeId peer); | void EraseOrphansFor(NodeId peer); | ||||
/** | |||||
* Average delay between local address broadcasts in seconds. | |||||
*/ | |||||
static constexpr unsigned int AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL = | |||||
24 * 60 * 60; | |||||
/** | |||||
* Average delay between peer address broadcasts in seconds. | |||||
*/ | |||||
static const unsigned int AVG_ADDRESS_BROADCAST_INTERVAL = 30; | |||||
/** | |||||
* Average delay between trickled inventory transmissions in seconds. | |||||
* Blocks and whitelisted receivers bypass this, outbound peers get half this | |||||
* delay. | |||||
*/ | |||||
static const unsigned int INVENTORY_BROADCAST_INTERVAL = 5; | |||||
/** | |||||
* Maximum number of inventory items to send per transmission. | |||||
* Limits the impact of low-fee transaction floods. | |||||
*/ | |||||
static constexpr unsigned int INVENTORY_BROADCAST_MAX_PER_MB = | |||||
7 * INVENTORY_BROADCAST_INTERVAL; | |||||
/** | |||||
* Average delay between feefilter broadcasts in seconds. | |||||
*/ | |||||
static constexpr unsigned int AVG_FEEFILTER_BROADCAST_INTERVAL = 10 * 60; | |||||
/** | |||||
* Maximum feefilter broadcast delay after significant change. | |||||
*/ | |||||
static constexpr unsigned int MAX_FEEFILTER_CHANGE_DELAY = 5 * 60; | |||||
// Internal stuff | // Internal stuff | ||||
namespace { | namespace { | ||||
/** Number of nodes with fSyncStarted. */ | /** Number of nodes with fSyncStarted. */ | ||||
int nSyncStarted GUARDED_BY(cs_main) = 0; | int nSyncStarted GUARDED_BY(cs_main) = 0; | ||||
/** | /** | ||||
* Sources of received blocks, saved to be able to send them reject messages or | * Sources of received blocks, saved to be able to send them reject messages or | ||||
* ban them when processing happens afterwards. | * ban them when processing happens afterwards. | ||||
▲ Show 20 Lines • Show All 4,208 Lines • ▼ Show 20 Lines | std::vector<CInv> vInv; | ||||
} | } | ||||
} | } | ||||
pto->vInventoryBlockToSend.clear(); | pto->vInventoryBlockToSend.clear(); | ||||
// Check whether periodic sends should happen | // Check whether periodic sends should happen | ||||
bool fSendTrickle = pto->fWhitelisted; | bool fSendTrickle = pto->fWhitelisted; | ||||
if (pto->nNextInvSend < nNow) { | if (pto->nNextInvSend < nNow) { | ||||
fSendTrickle = true; | fSendTrickle = true; | ||||
// Use half the delay for outbound peers, as there is less privacy | if (pto->fInbound) { | ||||
// concern for them. | pto->nNextInvSend = connman->PoissonNextSendInbound( | ||||
pto->nNextInvSend = PoissonNextSend( | nNow, INVENTORY_BROADCAST_INTERVAL); | ||||
nNow, INVENTORY_BROADCAST_INTERVAL >> !pto->fInbound); | } else { | ||||
// Use half the delay for outbound peers, as there is less | |||||
// privacy concern for them. | |||||
pto->nNextInvSend = | |||||
PoissonNextSend(nNow, INVENTORY_BROADCAST_INTERVAL >> 1); | |||||
} | |||||
} | } | ||||
// Time to send but the peer has requested we not relay transactions. | // Time to send but the peer has requested we not relay transactions. | ||||
if (fSendTrickle) { | if (fSendTrickle) { | ||||
LOCK(pto->cs_filter); | LOCK(pto->cs_filter); | ||||
if (!pto->fRelayTxes) { | if (!pto->fRelayTxes) { | ||||
pto->setInventoryTxToSend.clear(); | pto->setInventoryTxToSend.clear(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 361 Lines • Show Last 20 Lines |