Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 267 Lines • ▼ Show 20 Lines | |||||
* getcfilters. See BIP 157. | * getcfilters. See BIP 157. | ||||
*/ | */ | ||||
static constexpr uint32_t MAX_GETCFILTERS_SIZE = 1000; | static constexpr uint32_t MAX_GETCFILTERS_SIZE = 1000; | ||||
/** | /** | ||||
* Maximum number of cf hashes that may be requested with one getcfheaders. See | * Maximum number of cf hashes that may be requested with one getcfheaders. See | ||||
* BIP 157. | * BIP 157. | ||||
*/ | */ | ||||
static constexpr uint32_t MAX_GETCFHEADERS_SIZE = 2000; | static constexpr uint32_t MAX_GETCFHEADERS_SIZE = 2000; | ||||
/** | |||||
* the maximum percentage of addresses from our addrman to return in response | |||||
* to a getaddr message. | |||||
*/ | |||||
static constexpr size_t MAX_PCT_ADDR_TO_SEND = 23; | |||||
/// How many non standard orphan do we consider from a node before ignoring it. | /// How many non standard orphan do we consider from a node before ignoring it. | ||||
static constexpr uint32_t MAX_NON_STANDARD_ORPHAN_PER_NODE = 5; | static constexpr uint32_t MAX_NON_STANDARD_ORPHAN_PER_NODE = 5; | ||||
struct COrphanTx { | struct COrphanTx { | ||||
// When modifying, adapt the copy of this definition in tests/DoS_tests. | // When modifying, adapt the copy of this definition in tests/DoS_tests. | ||||
CTransactionRef tx; | CTransactionRef tx; | ||||
NodeId fromPeer; | NodeId fromPeer; | ||||
▲ Show 20 Lines • Show All 4,207 Lines • ▼ Show 20 Lines | if (msg_type == NetMsgType::GETADDR) { | ||||
pfrom.GetId()); | pfrom.GetId()); | ||||
return; | return; | ||||
} | } | ||||
pfrom.fSentAddr = true; | pfrom.fSentAddr = true; | ||||
pfrom.vAddrToSend.clear(); | pfrom.vAddrToSend.clear(); | ||||
std::vector<CAddress> vAddr; | std::vector<CAddress> vAddr; | ||||
if (pfrom.HasPermission(PF_ADDR)) { | if (pfrom.HasPermission(PF_ADDR)) { | ||||
vAddr = m_connman.GetAddresses(); | vAddr = | ||||
m_connman.GetAddresses(MAX_ADDR_TO_SEND, MAX_PCT_ADDR_TO_SEND); | |||||
} else { | } else { | ||||
vAddr = m_connman.GetAddresses(pfrom.addr.GetNetwork()); | vAddr = | ||||
m_connman.GetAddresses(pfrom.addr.GetNetwork(), | |||||
MAX_ADDR_TO_SEND, MAX_PCT_ADDR_TO_SEND); | |||||
} | } | ||||
FastRandomContext insecure_rand; | FastRandomContext insecure_rand; | ||||
for (const CAddress &addr : vAddr) { | for (const CAddress &addr : vAddr) { | ||||
pfrom.PushAddress(addr, insecure_rand); | pfrom.PushAddress(addr, insecure_rand); | ||||
} | } | ||||
return; | return; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,437 Lines • Show Last 20 Lines |