mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 15:19:07 +01:00
scripted-diff: rename NetPermissionFlags enumerators
- drop redundant PF_ permission flags prefixes - drop ALL_CAPS naming per https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Renum-caps - rename IsImplicit to Implicit -BEGIN VERIFY SCRIPT- s() { git grep -l "$1" src | xargs sed -i "s/$1/$2/g"; } s 'PF_NONE' 'None' s 'PF_BLOOMFILTER' 'BloomFilter' s 'PF_RELAY' 'Relay' s 'PF_FORCERELAY' 'ForceRelay' s 'PF_DOWNLOAD' 'Download' s 'PF_NOBAN' 'NoBan' s 'PF_MEMPOOL' 'Mempool' s 'PF_ADDR' 'Addr' s 'PF_ISIMPLICIT' 'Implicit' s 'PF_ALL' 'All' -END VERIFY SCRIPT-
This commit is contained in:
@@ -680,7 +680,7 @@ static void UpdatePreferredDownload(const CNode& node, CNodeState* state) EXCLUS
|
||||
nPreferredDownload -= state->fPreferredDownload;
|
||||
|
||||
// Whether this node should be marked as a preferred download node.
|
||||
state->fPreferredDownload = (!node.IsInboundConn() || node.HasPermission(NetPermissionFlags::PF_NOBAN)) && !node.IsAddrFetchConn() && !node.fClient;
|
||||
state->fPreferredDownload = (!node.IsInboundConn() || node.HasPermission(NetPermissionFlags::NoBan)) && !node.IsAddrFetchConn() && !node.fClient;
|
||||
|
||||
nPreferredDownload += state->fPreferredDownload;
|
||||
}
|
||||
@@ -960,24 +960,24 @@ void PeerManagerImpl::AddTxAnnouncement(const CNode& node, const GenTxid& gtxid,
|
||||
{
|
||||
AssertLockHeld(::cs_main); // For m_txrequest
|
||||
NodeId nodeid = node.GetId();
|
||||
if (!node.HasPermission(NetPermissionFlags::PF_RELAY) && m_txrequest.Count(nodeid) >= MAX_PEER_TX_ANNOUNCEMENTS) {
|
||||
if (!node.HasPermission(NetPermissionFlags::Relay) && m_txrequest.Count(nodeid) >= MAX_PEER_TX_ANNOUNCEMENTS) {
|
||||
// Too many queued announcements from this peer
|
||||
return;
|
||||
}
|
||||
const CNodeState* state = State(nodeid);
|
||||
|
||||
// Decide the TxRequestTracker parameters for this announcement:
|
||||
// - "preferred": if fPreferredDownload is set (= outbound, or NetPermissionFlags::PF_NOBAN permission)
|
||||
// - "preferred": if fPreferredDownload is set (= outbound, or NetPermissionFlags::NoBan permission)
|
||||
// - "reqtime": current time plus delays for:
|
||||
// - NONPREF_PEER_TX_DELAY for announcements from non-preferred connections
|
||||
// - TXID_RELAY_DELAY for txid announcements while wtxid peers are available
|
||||
// - OVERLOADED_PEER_TX_DELAY for announcements from peers which have at least
|
||||
// MAX_PEER_TX_REQUEST_IN_FLIGHT requests in flight (and don't have NetPermissionFlags::PF_RELAY).
|
||||
// MAX_PEER_TX_REQUEST_IN_FLIGHT requests in flight (and don't have NetPermissionFlags::Relay).
|
||||
auto delay = std::chrono::microseconds{0};
|
||||
const bool preferred = state->fPreferredDownload;
|
||||
if (!preferred) delay += NONPREF_PEER_TX_DELAY;
|
||||
if (!gtxid.IsWtxid() && m_wtxid_relay_peers > 0) delay += TXID_RELAY_DELAY;
|
||||
const bool overloaded = !node.HasPermission(NetPermissionFlags::PF_RELAY) &&
|
||||
const bool overloaded = !node.HasPermission(NetPermissionFlags::Relay) &&
|
||||
m_txrequest.CountInFlight(nodeid) >= MAX_PEER_TX_REQUEST_IN_FLIGHT;
|
||||
if (overloaded) delay += OVERLOADED_PEER_TX_DELAY;
|
||||
m_txrequest.ReceivedInv(nodeid, gtxid, preferred, current_time + delay);
|
||||
@@ -1637,14 +1637,14 @@ void PeerManagerImpl::ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv&
|
||||
// disconnect node in case we have reached the outbound limit for serving historical blocks
|
||||
if (m_connman.OutboundTargetReached(true) &&
|
||||
(((pindexBestHeader != nullptr) && (pindexBestHeader->GetBlockTime() - pindex->GetBlockTime() > HISTORICAL_BLOCK_AGE)) || inv.IsMsgFilteredBlk()) &&
|
||||
!pfrom.HasPermission(NetPermissionFlags::PF_DOWNLOAD) // nodes with the download permission may exceed target
|
||||
!pfrom.HasPermission(NetPermissionFlags::Download) // nodes with the download permission may exceed target
|
||||
) {
|
||||
LogPrint(BCLog::NET, "historical block serving limit reached, disconnect peer=%d\n", pfrom.GetId());
|
||||
pfrom.fDisconnect = true;
|
||||
return;
|
||||
}
|
||||
// Avoid leaking prune-height by never sending blocks below the NODE_NETWORK_LIMITED threshold
|
||||
if (!pfrom.HasPermission(NetPermissionFlags::PF_NOBAN) && (
|
||||
if (!pfrom.HasPermission(NetPermissionFlags::NoBan) && (
|
||||
(((pfrom.GetLocalServices() & NODE_NETWORK_LIMITED) == NODE_NETWORK_LIMITED) && ((pfrom.GetLocalServices() & NODE_NETWORK) != NODE_NETWORK) && (m_chainman.ActiveChain().Tip()->nHeight - pindex->nHeight > (int)NODE_NETWORK_LIMITED_MIN_BLOCKS + 2 /* add two blocks buffer extension for possible races */) )
|
||||
)) {
|
||||
LogPrint(BCLog::NET, "Ignore block request below NODE_NETWORK_LIMITED threshold, disconnect peer=%d\n", pfrom.GetId());
|
||||
@@ -2738,7 +2738,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
||||
bool fBlocksOnly = m_ignore_incoming_txs || (pfrom.m_tx_relay == nullptr);
|
||||
|
||||
// Allow peers with relay permission to send data other than blocks in blocks only mode
|
||||
if (pfrom.HasPermission(NetPermissionFlags::PF_RELAY)) {
|
||||
if (pfrom.HasPermission(NetPermissionFlags::Relay)) {
|
||||
fBlocksOnly = false;
|
||||
}
|
||||
|
||||
@@ -2952,7 +2952,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
||||
}
|
||||
|
||||
LOCK(cs_main);
|
||||
if (m_chainman.ActiveChainstate().IsInitialBlockDownload() && !pfrom.HasPermission(NetPermissionFlags::PF_DOWNLOAD)) {
|
||||
if (m_chainman.ActiveChainstate().IsInitialBlockDownload() && !pfrom.HasPermission(NetPermissionFlags::Download)) {
|
||||
LogPrint(BCLog::NET, "Ignoring getheaders from peer=%d because node is in initial block download\n", pfrom.GetId());
|
||||
return;
|
||||
}
|
||||
@@ -3011,7 +3011,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
||||
// Stop processing the transaction early if
|
||||
// 1) We are in blocks only mode and peer has no relay permission
|
||||
// 2) This peer is a block-relay-only peer
|
||||
if ((m_ignore_incoming_txs && !pfrom.HasPermission(NetPermissionFlags::PF_RELAY)) || (pfrom.m_tx_relay == nullptr))
|
||||
if ((m_ignore_incoming_txs && !pfrom.HasPermission(NetPermissionFlags::Relay)) || (pfrom.m_tx_relay == nullptr))
|
||||
{
|
||||
LogPrint(BCLog::NET, "transaction sent in violation of protocol peer=%d\n", pfrom.GetId());
|
||||
pfrom.fDisconnect = true;
|
||||
@@ -3056,7 +3056,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
||||
// (older than our recency filter) if trying to DoS us, without any need
|
||||
// for witness malleation.
|
||||
if (AlreadyHaveTx(GenTxid(/* is_wtxid=*/true, wtxid))) {
|
||||
if (pfrom.HasPermission(NetPermissionFlags::PF_FORCERELAY)) {
|
||||
if (pfrom.HasPermission(NetPermissionFlags::ForceRelay)) {
|
||||
// Always relay transactions received from peers with forcerelay
|
||||
// permission, even if they were already in the mempool, allowing
|
||||
// the node to function as a gateway for nodes hidden behind it.
|
||||
@@ -3585,7 +3585,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
||||
|
||||
pfrom.vAddrToSend.clear();
|
||||
std::vector<CAddress> vAddr;
|
||||
if (pfrom.HasPermission(NetPermissionFlags::PF_ADDR)) {
|
||||
if (pfrom.HasPermission(NetPermissionFlags::Addr)) {
|
||||
vAddr = m_connman.GetAddresses(MAX_ADDR_TO_SEND, MAX_PCT_ADDR_TO_SEND);
|
||||
} else {
|
||||
vAddr = m_connman.GetAddresses(pfrom, MAX_ADDR_TO_SEND, MAX_PCT_ADDR_TO_SEND);
|
||||
@@ -3598,9 +3598,9 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
||||
}
|
||||
|
||||
if (msg_type == NetMsgType::MEMPOOL) {
|
||||
if (!(pfrom.GetLocalServices() & NODE_BLOOM) && !pfrom.HasPermission(NetPermissionFlags::PF_MEMPOOL))
|
||||
if (!(pfrom.GetLocalServices() & NODE_BLOOM) && !pfrom.HasPermission(NetPermissionFlags::Mempool))
|
||||
{
|
||||
if (!pfrom.HasPermission(NetPermissionFlags::PF_NOBAN))
|
||||
if (!pfrom.HasPermission(NetPermissionFlags::NoBan))
|
||||
{
|
||||
LogPrint(BCLog::NET, "mempool request with bloom filters disabled, disconnect peer=%d\n", pfrom.GetId());
|
||||
pfrom.fDisconnect = true;
|
||||
@@ -3608,9 +3608,9 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_connman.OutboundTargetReached(false) && !pfrom.HasPermission(NetPermissionFlags::PF_MEMPOOL))
|
||||
if (m_connman.OutboundTargetReached(false) && !pfrom.HasPermission(NetPermissionFlags::Mempool))
|
||||
{
|
||||
if (!pfrom.HasPermission(NetPermissionFlags::PF_NOBAN))
|
||||
if (!pfrom.HasPermission(NetPermissionFlags::NoBan))
|
||||
{
|
||||
LogPrint(BCLog::NET, "mempool request with bandwidth limit reached, disconnect peer=%d\n", pfrom.GetId());
|
||||
pfrom.fDisconnect = true;
|
||||
@@ -3825,7 +3825,7 @@ bool PeerManagerImpl::MaybeDiscourageAndDisconnect(CNode& pnode, Peer& peer)
|
||||
peer.m_should_discourage = false;
|
||||
} // peer.m_misbehavior_mutex
|
||||
|
||||
if (pnode.HasPermission(NetPermissionFlags::PF_NOBAN)) {
|
||||
if (pnode.HasPermission(NetPermissionFlags::NoBan)) {
|
||||
// We never disconnect or discourage peers for bad behavior if they have the NOBAN permission flag
|
||||
LogPrintf("Warning: not punishing noban peer %d!\n", peer.m_id);
|
||||
return false;
|
||||
@@ -4463,7 +4463,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
|
||||
if (pto->m_tx_relay != nullptr) {
|
||||
LOCK(pto->m_tx_relay->cs_tx_inventory);
|
||||
// Check whether periodic sends should happen
|
||||
bool fSendTrickle = pto->HasPermission(NetPermissionFlags::PF_NOBAN);
|
||||
bool fSendTrickle = pto->HasPermission(NetPermissionFlags::NoBan);
|
||||
if (pto->m_tx_relay->nNextInvSend < current_time) {
|
||||
fSendTrickle = true;
|
||||
if (pto->IsInboundConn()) {
|
||||
@@ -4625,7 +4625,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
|
||||
// Note: If all our peers are inbound, then we won't
|
||||
// disconnect our sync peer for stalling; we have bigger
|
||||
// problems if we can't get any outbound peers.
|
||||
if (!pto->HasPermission(NetPermissionFlags::PF_NOBAN)) {
|
||||
if (!pto->HasPermission(NetPermissionFlags::NoBan)) {
|
||||
LogPrintf("Timeout downloading headers from peer=%d, disconnecting\n", pto->GetId());
|
||||
pto->fDisconnect = true;
|
||||
return true;
|
||||
@@ -4712,7 +4712,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
|
||||
!m_ignore_incoming_txs &&
|
||||
pto->GetCommonVersion() >= FEEFILTER_VERSION &&
|
||||
gArgs.GetBoolArg("-feefilter", DEFAULT_FEEFILTER) &&
|
||||
!pto->HasPermission(NetPermissionFlags::PF_FORCERELAY) // peers with the forcerelay permission should not filter txs to us
|
||||
!pto->HasPermission(NetPermissionFlags::ForceRelay) // peers with the forcerelay permission should not filter txs to us
|
||||
) {
|
||||
CAmount currentFilter = m_mempool.GetMinFee(gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000).GetFeePerK();
|
||||
static FeeFilterRounder g_filter_rounder{CFeeRate{DEFAULT_MIN_RELAY_TX_FEE}};
|
||||
|
||||
Reference in New Issue
Block a user