Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 160 Lines • ▼ Show 20 Lines | |||||
* Average delay between feefilter broadcasts in seconds. | * Average delay between feefilter broadcasts in seconds. | ||||
*/ | */ | ||||
static constexpr unsigned int AVG_FEEFILTER_BROADCAST_INTERVAL = 10 * 60; | static constexpr unsigned int AVG_FEEFILTER_BROADCAST_INTERVAL = 10 * 60; | ||||
/** | /** | ||||
* Maximum feefilter broadcast delay after significant change. | * Maximum feefilter broadcast delay after significant change. | ||||
*/ | */ | ||||
static constexpr unsigned int MAX_FEEFILTER_CHANGE_DELAY = 5 * 60; | static constexpr unsigned int MAX_FEEFILTER_CHANGE_DELAY = 5 * 60; | ||||
/** Interval between compact filter checkpoints. See BIP 157. */ | |||||
static constexpr int CFCHECKPT_INTERVAL = 1000; | |||||
// 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 punish them when processing | * Sources of received blocks, saved to be able to punish them when processing | ||||
* happens afterwards. | * happens afterwards. | ||||
▲ Show 20 Lines • Show All 2,072 Lines • ▼ Show 20 Lines | |||||
* serviced. | * serviced. | ||||
* @return True if the request can be serviced. | * @return True if the request can be serviced. | ||||
*/ | */ | ||||
static bool PrepareBlockFilterRequest(CNode *pfrom, | static bool PrepareBlockFilterRequest(CNode *pfrom, | ||||
const CChainParams &chain_params, | const CChainParams &chain_params, | ||||
BlockFilterType filter_type, | BlockFilterType filter_type, | ||||
const BlockHash &stop_hash, | const BlockHash &stop_hash, | ||||
const CBlockIndex *&stop_index, | const CBlockIndex *&stop_index, | ||||
const BlockFilterIndex *&filter_index) { | BlockFilterIndex *&filter_index) { | ||||
const bool supported_filter_type = | const bool supported_filter_type = | ||||
(filter_type == BlockFilterType::BASIC && | (filter_type == BlockFilterType::BASIC && | ||||
gArgs.GetBoolArg("-peerblockfilters", DEFAULT_PEERBLOCKFILTERS)); | gArgs.GetBoolArg("-peerblockfilters", DEFAULT_PEERBLOCKFILTERS)); | ||||
if (!supported_filter_type) { | if (!supported_filter_type) { | ||||
LogPrint(BCLog::NET, | LogPrint(BCLog::NET, | ||||
"peer %d requested unsupported block filter type: %d\n", | "peer %d requested unsupported block filter type: %d\n", | ||||
pfrom->GetId(), static_cast<uint8_t>(filter_type)); | pfrom->GetId(), static_cast<uint8_t>(filter_type)); | ||||
pfrom->fDisconnect = true; | pfrom->fDisconnect = true; | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | static void ProcessGetCFCheckPt(CNode *pfrom, CDataStream &vRecv, | ||||
BlockHash stop_hash; | BlockHash stop_hash; | ||||
vRecv >> filter_type_ser >> stop_hash; | vRecv >> filter_type_ser >> stop_hash; | ||||
const BlockFilterType filter_type = | const BlockFilterType filter_type = | ||||
static_cast<BlockFilterType>(filter_type_ser); | static_cast<BlockFilterType>(filter_type_ser); | ||||
const CBlockIndex *stop_index; | const CBlockIndex *stop_index; | ||||
const BlockFilterIndex *filter_index; | BlockFilterIndex *filter_index; | ||||
if (!PrepareBlockFilterRequest(pfrom, chain_params, filter_type, stop_hash, | if (!PrepareBlockFilterRequest(pfrom, chain_params, filter_type, stop_hash, | ||||
stop_index, filter_index)) { | stop_index, filter_index)) { | ||||
return; | return; | ||||
} | } | ||||
std::vector<uint256> headers(stop_index->nHeight / CFCHECKPT_INTERVAL); | std::vector<uint256> headers(stop_index->nHeight / CFCHECKPT_INTERVAL); | ||||
// Populate headers. | // Populate headers. | ||||
▲ Show 20 Lines • Show All 2,777 Lines • Show Last 20 Lines |