Skip to content

Commit

Permalink
Only pass hash instead of CInv object to RemoveAskFor
Browse files Browse the repository at this point in the history
  • Loading branch information
codablock committed Oct 26, 2018
1 parent b35ee5c commit 677f49a
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/governance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, const std::string& strComm

{
LOCK(cs_main);
connman.RemoveAskFor(CInv(MSG_GOVERNANCE_OBJECT, nHash));
connman.RemoveAskFor(nHash);
}

if (pfrom->nVersion < MIN_GOVERNANCE_PEER_PROTO_VERSION) {
Expand Down Expand Up @@ -225,7 +225,7 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, const std::string& strComm

{
LOCK(cs_main);
connman.RemoveAskFor(CInv(MSG_GOVERNANCE_OBJECT_VOTE, nHash));
connman.RemoveAskFor(nHash);
}

if (pfrom->nVersion < MIN_GOVERNANCE_PEER_PROTO_VERSION) {
Expand Down
2 changes: 1 addition & 1 deletion src/instantx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void CInstantSend::ProcessMessage(CNode* pfrom, const std::string& strCommand, C

{
LOCK(cs_main);
connman.RemoveAskFor(CInv(MSG_TXLOCK_VOTE, nVoteHash));
connman.RemoveAskFor(nVoteHash);
}

// Ignore any InstantSend messages until masternode list is synced
Expand Down
2 changes: 1 addition & 1 deletion src/masternode-payments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ void CMasternodePayments::ProcessMessage(CNode* pfrom, const std::string& strCom

{
LOCK(cs_main);
connman.RemoveAskFor(CInv(MSG_MASTERNODE_PAYMENT_VOTE, nHash));
connman.RemoveAskFor(nHash);
}

// TODO: clear setAskFor for MSG_MASTERNODE_PAYMENT_BLOCK too
Expand Down
6 changes: 3 additions & 3 deletions src/masternodeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, const std::string& strCommand,

{
LOCK(cs_main);
connman.RemoveAskFor(CInv(MSG_MASTERNODE_ANNOUNCE, mnb.GetHash()));
connman.RemoveAskFor(mnb.GetHash());
}

if(!masternodeSync.IsBlockchainSynced()) return;
Expand Down Expand Up @@ -1008,7 +1008,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, const std::string& strCommand,

{
LOCK(cs_main);
connman.RemoveAskFor(CInv(MSG_MASTERNODE_PING, nHash));
connman.RemoveAskFor(nHash);
}

if(!masternodeSync.IsBlockchainSynced()) return;
Expand Down Expand Up @@ -1074,7 +1074,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, const std::string& strCommand,

{
LOCK(cs_main);
connman.RemoveAskFor(CInv(MSG_MASTERNODE_VERIFY, mnv.GetHash()));
connman.RemoveAskFor(mnv.GetHash());
}

if(!masternodeSync.IsMasternodeListSynced()) return;
Expand Down
12 changes: 6 additions & 6 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2655,13 +2655,13 @@ void CConnman::RelayInvFiltered(CInv &inv, const CTransaction& relatedTx, const
}
}

void CConnman::RemoveAskFor(const CInv& inv)
void CConnman::RemoveAskFor(const uint256& hash)
{
mapAlreadyAskedFor.erase(inv.hash);
mapAlreadyAskedFor.erase(hash);

LOCK(cs_vNodes);
for (const auto& pnode : vNodes) {
pnode->RemoveAskFor(inv);
pnode->RemoveAskFor(hash);
}
}

Expand Down Expand Up @@ -2916,11 +2916,11 @@ void CNode::AskFor(const CInv& inv)
mapAskFor.insert(std::make_pair(nRequestTime, inv));
}

void CNode::RemoveAskFor(const CInv& inv)
void CNode::RemoveAskFor(const uint256& hash)
{
setAskFor.erase(inv.hash);
setAskFor.erase(hash);
for (auto it = mapAskFor.begin(); it != mapAskFor.end();) {
if (it->second.hash == inv.hash) {
if (it->second.hash == hash) {
it = mapAskFor.erase(it);
} else {
++it;
Expand Down
4 changes: 2 additions & 2 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ class CConnman
void RelayTransaction(const CTransaction& tx, const CDataStream& ss);
void RelayInv(CInv &inv, const int minProtoVersion = MIN_PEER_PROTO_VERSION);
void RelayInvFiltered(CInv &inv, const CTransaction &relatedTx, const int minProtoVersion = MIN_PEER_PROTO_VERSION);
void RemoveAskFor(const CInv& inv);
void RemoveAskFor(const uint256& hash);

// Addrman functions
size_t GetAddressCount() const;
Expand Down Expand Up @@ -930,7 +930,7 @@ class CNode
}

void AskFor(const CInv& inv);
void RemoveAskFor(const CInv& inv);
void RemoveAskFor(const uint256& hash);

void CloseSocketDisconnect();

Expand Down
2 changes: 1 addition & 1 deletion src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2008,7 +2008,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr

LOCK(cs_main);

connman.RemoveAskFor(inv);
connman.RemoveAskFor(inv.hash);

bool fMissingInputs = false;
CValidationState state;
Expand Down
2 changes: 1 addition & 1 deletion src/spork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void CSporkManager::ProcessSpork(CNode* pfrom, const std::string& strCommand, CD
std::string strLogMsg;
{
LOCK(cs_main);
connman.RemoveAskFor(CInv(MSG_SPORK, hash));
connman.RemoveAskFor(hash);
if(!chainActive.Tip()) return;
strLogMsg = strprintf("SPORK -- hash: %s id: %d value: %10d bestHeight: %d peer=%d", hash.ToString(), spork.nSporkID, spork.nValue, chainActive.Height(), pfrom->id);
}
Expand Down

0 comments on commit 677f49a

Please sign in to comment.