@@ -680,7 +680,7 @@ static void UpdatePreferredDownload(const CNode& node, CNodeState* state) EXCLUS
680
680
nPreferredDownload -= state->fPreferredDownload ;
681
681
682
682
// Whether this node should be marked as a preferred download node.
683
- state->fPreferredDownload = (!node.IsInboundConn () || node.HasPermission (PF_NOBAN)) && !node.IsAddrFetchConn () && !node.fClient ;
683
+ state->fPreferredDownload = (!node.IsInboundConn () || node.HasPermission (NetPermissionFlags:: PF_NOBAN)) && !node.IsAddrFetchConn () && !node.fClient ;
684
684
685
685
nPreferredDownload += state->fPreferredDownload ;
686
686
}
@@ -960,24 +960,24 @@ void PeerManagerImpl::AddTxAnnouncement(const CNode& node, const GenTxid& gtxid,
960
960
{
961
961
AssertLockHeld (::cs_main); // For m_txrequest
962
962
NodeId nodeid = node.GetId ();
963
- if (!node.HasPermission (PF_RELAY) && m_txrequest.Count (nodeid) >= MAX_PEER_TX_ANNOUNCEMENTS) {
963
+ if (!node.HasPermission (NetPermissionFlags:: PF_RELAY) && m_txrequest.Count (nodeid) >= MAX_PEER_TX_ANNOUNCEMENTS) {
964
964
// Too many queued announcements from this peer
965
965
return ;
966
966
}
967
967
const CNodeState* state = State (nodeid);
968
968
969
969
// Decide the TxRequestTracker parameters for this announcement:
970
- // - "preferred": if fPreferredDownload is set (= outbound, or PF_NOBAN permission)
970
+ // - "preferred": if fPreferredDownload is set (= outbound, or NetPermissionFlags:: PF_NOBAN permission)
971
971
// - "reqtime": current time plus delays for:
972
972
// - NONPREF_PEER_TX_DELAY for announcements from non-preferred connections
973
973
// - TXID_RELAY_DELAY for txid announcements while wtxid peers are available
974
974
// - OVERLOADED_PEER_TX_DELAY for announcements from peers which have at least
975
- // MAX_PEER_TX_REQUEST_IN_FLIGHT requests in flight (and don't have PF_RELAY).
975
+ // MAX_PEER_TX_REQUEST_IN_FLIGHT requests in flight (and don't have NetPermissionFlags:: PF_RELAY).
976
976
auto delay = std::chrono::microseconds{0 };
977
977
const bool preferred = state->fPreferredDownload ;
978
978
if (!preferred) delay += NONPREF_PEER_TX_DELAY;
979
979
if (!gtxid.IsWtxid () && m_wtxid_relay_peers > 0 ) delay += TXID_RELAY_DELAY;
980
- const bool overloaded = !node.HasPermission (PF_RELAY) &&
980
+ const bool overloaded = !node.HasPermission (NetPermissionFlags:: PF_RELAY) &&
981
981
m_txrequest.CountInFlight (nodeid) >= MAX_PEER_TX_REQUEST_IN_FLIGHT;
982
982
if (overloaded) delay += OVERLOADED_PEER_TX_DELAY;
983
983
m_txrequest.ReceivedInv (nodeid, gtxid, preferred, current_time + delay);
@@ -1637,14 +1637,14 @@ void PeerManagerImpl::ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv&
1637
1637
// disconnect node in case we have reached the outbound limit for serving historical blocks
1638
1638
if (m_connman.OutboundTargetReached (true ) &&
1639
1639
(((pindexBestHeader != nullptr ) && (pindexBestHeader->GetBlockTime () - pindex->GetBlockTime () > HISTORICAL_BLOCK_AGE)) || inv.IsMsgFilteredBlk ()) &&
1640
- !pfrom.HasPermission (PF_DOWNLOAD) // nodes with the download permission may exceed target
1640
+ !pfrom.HasPermission (NetPermissionFlags:: PF_DOWNLOAD) // nodes with the download permission may exceed target
1641
1641
) {
1642
1642
LogPrint (BCLog::NET, " historical block serving limit reached, disconnect peer=%d\n " , pfrom.GetId ());
1643
1643
pfrom.fDisconnect = true ;
1644
1644
return ;
1645
1645
}
1646
1646
// Avoid leaking prune-height by never sending blocks below the NODE_NETWORK_LIMITED threshold
1647
- if (!pfrom.HasPermission (PF_NOBAN) && (
1647
+ if (!pfrom.HasPermission (NetPermissionFlags:: PF_NOBAN) && (
1648
1648
(((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 */ ) )
1649
1649
)) {
1650
1650
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,
2738
2738
bool fBlocksOnly = m_ignore_incoming_txs || (pfrom.m_tx_relay == nullptr );
2739
2739
2740
2740
// Allow peers with relay permission to send data other than blocks in blocks only mode
2741
- if (pfrom.HasPermission (PF_RELAY)) {
2741
+ if (pfrom.HasPermission (NetPermissionFlags:: PF_RELAY)) {
2742
2742
fBlocksOnly = false ;
2743
2743
}
2744
2744
@@ -2952,7 +2952,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
2952
2952
}
2953
2953
2954
2954
LOCK (cs_main);
2955
- if (m_chainman.ActiveChainstate ().IsInitialBlockDownload () && !pfrom.HasPermission (PF_DOWNLOAD)) {
2955
+ if (m_chainman.ActiveChainstate ().IsInitialBlockDownload () && !pfrom.HasPermission (NetPermissionFlags:: PF_DOWNLOAD)) {
2956
2956
LogPrint (BCLog::NET, " Ignoring getheaders from peer=%d because node is in initial block download\n " , pfrom.GetId ());
2957
2957
return ;
2958
2958
}
@@ -3011,7 +3011,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
3011
3011
// Stop processing the transaction early if
3012
3012
// 1) We are in blocks only mode and peer has no relay permission
3013
3013
// 2) This peer is a block-relay-only peer
3014
- if ((m_ignore_incoming_txs && !pfrom.HasPermission (PF_RELAY)) || (pfrom.m_tx_relay == nullptr ))
3014
+ if ((m_ignore_incoming_txs && !pfrom.HasPermission (NetPermissionFlags:: PF_RELAY)) || (pfrom.m_tx_relay == nullptr ))
3015
3015
{
3016
3016
LogPrint (BCLog::NET, " transaction sent in violation of protocol peer=%d\n " , pfrom.GetId ());
3017
3017
pfrom.fDisconnect = true ;
@@ -3056,7 +3056,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
3056
3056
// (older than our recency filter) if trying to DoS us, without any need
3057
3057
// for witness malleation.
3058
3058
if (AlreadyHaveTx (GenTxid (/* is_wtxid=*/ true , wtxid))) {
3059
- if (pfrom.HasPermission (PF_FORCERELAY)) {
3059
+ if (pfrom.HasPermission (NetPermissionFlags:: PF_FORCERELAY)) {
3060
3060
// Always relay transactions received from peers with forcerelay
3061
3061
// permission, even if they were already in the mempool, allowing
3062
3062
// 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,
3585
3585
3586
3586
pfrom.vAddrToSend .clear ();
3587
3587
std::vector<CAddress> vAddr;
3588
- if (pfrom.HasPermission (PF_ADDR)) {
3588
+ if (pfrom.HasPermission (NetPermissionFlags:: PF_ADDR)) {
3589
3589
vAddr = m_connman.GetAddresses (MAX_ADDR_TO_SEND, MAX_PCT_ADDR_TO_SEND);
3590
3590
} else {
3591
3591
vAddr = m_connman.GetAddresses (pfrom, MAX_ADDR_TO_SEND, MAX_PCT_ADDR_TO_SEND);
@@ -3598,19 +3598,19 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
3598
3598
}
3599
3599
3600
3600
if (msg_type == NetMsgType::MEMPOOL) {
3601
- if (!(pfrom.GetLocalServices () & NODE_BLOOM) && !pfrom.HasPermission (PF_MEMPOOL))
3601
+ if (!(pfrom.GetLocalServices () & NODE_BLOOM) && !pfrom.HasPermission (NetPermissionFlags:: PF_MEMPOOL))
3602
3602
{
3603
- if (!pfrom.HasPermission (PF_NOBAN))
3603
+ if (!pfrom.HasPermission (NetPermissionFlags:: PF_NOBAN))
3604
3604
{
3605
3605
LogPrint (BCLog::NET, " mempool request with bloom filters disabled, disconnect peer=%d\n " , pfrom.GetId ());
3606
3606
pfrom.fDisconnect = true ;
3607
3607
}
3608
3608
return ;
3609
3609
}
3610
3610
3611
- if (m_connman.OutboundTargetReached (false ) && !pfrom.HasPermission (PF_MEMPOOL))
3611
+ if (m_connman.OutboundTargetReached (false ) && !pfrom.HasPermission (NetPermissionFlags:: PF_MEMPOOL))
3612
3612
{
3613
- if (!pfrom.HasPermission (PF_NOBAN))
3613
+ if (!pfrom.HasPermission (NetPermissionFlags:: PF_NOBAN))
3614
3614
{
3615
3615
LogPrint (BCLog::NET, " mempool request with bandwidth limit reached, disconnect peer=%d\n " , pfrom.GetId ());
3616
3616
pfrom.fDisconnect = true ;
@@ -3825,7 +3825,7 @@ bool PeerManagerImpl::MaybeDiscourageAndDisconnect(CNode& pnode, Peer& peer)
3825
3825
peer.m_should_discourage = false ;
3826
3826
} // peer.m_misbehavior_mutex
3827
3827
3828
- if (pnode.HasPermission (PF_NOBAN)) {
3828
+ if (pnode.HasPermission (NetPermissionFlags:: PF_NOBAN)) {
3829
3829
// We never disconnect or discourage peers for bad behavior if they have the NOBAN permission flag
3830
3830
LogPrintf (" Warning: not punishing noban peer %d!\n " , peer.m_id );
3831
3831
return false ;
@@ -4463,7 +4463,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
4463
4463
if (pto->m_tx_relay != nullptr ) {
4464
4464
LOCK (pto->m_tx_relay ->cs_tx_inventory );
4465
4465
// Check whether periodic sends should happen
4466
- bool fSendTrickle = pto->HasPermission (PF_NOBAN);
4466
+ bool fSendTrickle = pto->HasPermission (NetPermissionFlags:: PF_NOBAN);
4467
4467
if (pto->m_tx_relay ->nNextInvSend < current_time) {
4468
4468
fSendTrickle = true ;
4469
4469
if (pto->IsInboundConn ()) {
@@ -4625,7 +4625,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
4625
4625
// Note: If all our peers are inbound, then we won't
4626
4626
// disconnect our sync peer for stalling; we have bigger
4627
4627
// problems if we can't get any outbound peers.
4628
- if (!pto->HasPermission (PF_NOBAN)) {
4628
+ if (!pto->HasPermission (NetPermissionFlags:: PF_NOBAN)) {
4629
4629
LogPrintf (" Timeout downloading headers from peer=%d, disconnecting\n " , pto->GetId ());
4630
4630
pto->fDisconnect = true ;
4631
4631
return true ;
@@ -4712,7 +4712,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
4712
4712
!m_ignore_incoming_txs &&
4713
4713
pto->GetCommonVersion () >= FEEFILTER_VERSION &&
4714
4714
gArgs .GetBoolArg (" -feefilter" , DEFAULT_FEEFILTER) &&
4715
- !pto->HasPermission (PF_FORCERELAY) // peers with the forcerelay permission should not filter txs to us
4715
+ !pto->HasPermission (NetPermissionFlags:: PF_FORCERELAY) // peers with the forcerelay permission should not filter txs to us
4716
4716
) {
4717
4717
CAmount currentFilter = m_mempool.GetMinFee (gArgs .GetArg (" -maxmempool" , DEFAULT_MAX_MEMPOOL_SIZE) * 1000000 ).GetFeePerK ();
4718
4718
static FeeFilterRounder g_filter_rounder{CFeeRate{DEFAULT_MIN_RELAY_TX_FEE}};
0 commit comments