mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
partial bitcoin#20187: test-before-evict bugfix and improvements for block-relay-only peers
Contains only daf55531260833d597ee599e2d289ea1be0b1d9c
This commit is contained in:
parent
b513441300
commit
698a717ecd
@ -3310,7 +3310,7 @@ void CConnman::DeleteNode(CNode* pnode)
|
||||
{
|
||||
assert(pnode);
|
||||
bool fUpdateConnectionTime = false;
|
||||
m_msgproc->FinalizeNode(pnode->GetId(), fUpdateConnectionTime);
|
||||
m_msgproc->FinalizeNode(*pnode, fUpdateConnectionTime);
|
||||
if(fUpdateConnectionTime) {
|
||||
addrman.Connected(pnode->addr);
|
||||
}
|
||||
|
@ -708,7 +708,7 @@ public:
|
||||
virtual bool ProcessMessages(CNode* pnode, std::atomic<bool>& interrupt) = 0;
|
||||
virtual bool SendMessages(CNode* pnode) = 0;
|
||||
virtual void InitializeNode(CNode* pnode) = 0;
|
||||
virtual void FinalizeNode(NodeId id, bool& update_connection_time) = 0;
|
||||
virtual void FinalizeNode(const CNode& node, bool& update_connection_time) = 0;
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
@ -929,7 +929,8 @@ void PeerLogicValidation::ReattemptInitialBroadcast(CScheduler& scheduler) const
|
||||
scheduler.scheduleFromNow([&] { ReattemptInitialBroadcast(scheduler); }, delta);
|
||||
}
|
||||
|
||||
void PeerLogicValidation::FinalizeNode(NodeId nodeid, bool& fUpdateConnectionTime) {
|
||||
void PeerLogicValidation::FinalizeNode(const CNode& node, bool& fUpdateConnectionTime) {
|
||||
NodeId nodeid = node.GetId();
|
||||
fUpdateConnectionTime = false;
|
||||
LOCK(cs_main);
|
||||
CNodeState *state = State(nodeid);
|
||||
@ -938,7 +939,8 @@ void PeerLogicValidation::FinalizeNode(NodeId nodeid, bool& fUpdateConnectionTim
|
||||
if (state->fSyncStarted)
|
||||
nSyncStarted--;
|
||||
|
||||
if (state->nMisbehavior == 0 && state->fCurrentlyConnected) {
|
||||
if (state->nMisbehavior == 0 && state->fCurrentlyConnected && !node.m_block_relay_only_peer) {
|
||||
// Note: we avoid changing visible addrman state for block-relay-only peers
|
||||
fUpdateConnectionTime = true;
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ public:
|
||||
/** Initialize a peer by adding it to mapNodeState and pushing a message requesting its version */
|
||||
void InitializeNode(CNode* pnode) override;
|
||||
/** Handle removal of a peer by updating various state and removing it from mapNodeState */
|
||||
void FinalizeNode(NodeId nodeid, bool& fUpdateConnectionTime) override;
|
||||
void FinalizeNode(const CNode& node, bool& fUpdateConnectionTime) override;
|
||||
/**
|
||||
* Process protocol messages received from a given node
|
||||
*
|
||||
|
@ -134,7 +134,7 @@ BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction)
|
||||
SetMockTime(0);
|
||||
|
||||
bool dummy;
|
||||
peerLogic->FinalizeNode(dummyNode1.GetId(), dummy);
|
||||
peerLogic->FinalizeNode(dummyNode1, dummy);
|
||||
}
|
||||
|
||||
static void AddRandomOutboundPeer(std::vector<CNode *> &vNodes, PeerLogicValidation &peerLogic, CConnmanTest* connman)
|
||||
@ -219,7 +219,7 @@ BOOST_AUTO_TEST_CASE(stale_tip_peer_management)
|
||||
|
||||
bool dummy;
|
||||
for (const CNode *node : vNodes) {
|
||||
peerLogic->FinalizeNode(node->GetId(), dummy);
|
||||
peerLogic->FinalizeNode(*node, dummy);
|
||||
}
|
||||
|
||||
connman->ClearNodes();
|
||||
@ -278,8 +278,8 @@ BOOST_AUTO_TEST_CASE(DoS_banning)
|
||||
BOOST_CHECK(banman->IsDiscouraged(addr2));
|
||||
|
||||
bool dummy;
|
||||
peerLogic->FinalizeNode(dummyNode1.GetId(), dummy);
|
||||
peerLogic->FinalizeNode(dummyNode2.GetId(), dummy);
|
||||
peerLogic->FinalizeNode(dummyNode1, dummy);
|
||||
peerLogic->FinalizeNode(dummyNode2, dummy);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(DoS_banscore)
|
||||
@ -328,7 +328,7 @@ BOOST_AUTO_TEST_CASE(DoS_banscore)
|
||||
gArgs.ForceSetArg("-banscore", ToString(DEFAULT_BANSCORE_THRESHOLD));
|
||||
|
||||
bool dummy;
|
||||
peerLogic->FinalizeNode(dummyNode1.GetId(), dummy);
|
||||
peerLogic->FinalizeNode(dummyNode1, dummy);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(DoS_bantime)
|
||||
@ -361,7 +361,7 @@ BOOST_AUTO_TEST_CASE(DoS_bantime)
|
||||
BOOST_CHECK(banman->IsDiscouraged(addr));
|
||||
|
||||
bool dummy;
|
||||
peerLogic->FinalizeNode(dummyNode.GetId(), dummy);
|
||||
peerLogic->FinalizeNode(dummyNode, dummy);
|
||||
}
|
||||
|
||||
static CTransactionRef RandomOrphan()
|
||||
|
Loading…
Reference in New Issue
Block a user