Skip to content

Commit

Permalink
Merge #7862: Use txid as key in mapAlreadyAskedFor
Browse files Browse the repository at this point in the history
7e91f63 Use txid as key in mapAlreadyAskedFor (Suhas Daftuar)
  • Loading branch information
laanwj committed Apr 14, 2016
2 parents ab8586e + 7e91f63 commit 97d0b98
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main.cpp
Expand Up @@ -4955,7 +4955,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
CValidationState state;

pfrom->setAskFor.erase(inv.hash);
mapAlreadyAskedFor.erase(inv);
mapAlreadyAskedFor.erase(inv.hash);

CFeeRate txFeeRate = CFeeRate(0);
if (!AlreadyHave(inv) && AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs, &txFeeRate)) {
Expand Down
6 changes: 3 additions & 3 deletions src/net.cpp
Expand Up @@ -93,7 +93,7 @@ CCriticalSection cs_vNodes;
map<CInv, CDataStream> mapRelay;
deque<pair<int64_t, CInv> > vRelayExpiration;
CCriticalSection cs_mapRelay;
limitedmap<CInv, int64_t> mapAlreadyAskedFor(MAX_INV_SZ);
limitedmap<uint256, int64_t> mapAlreadyAskedFor(MAX_INV_SZ);

static deque<string> vOneShots;
CCriticalSection cs_vOneShots;
Expand Down Expand Up @@ -2436,7 +2436,7 @@ void CNode::AskFor(const CInv& inv)
// We're using mapAskFor as a priority queue,
// the key is the earliest time the request can be sent
int64_t nRequestTime;
limitedmap<CInv, int64_t>::const_iterator it = mapAlreadyAskedFor.find(inv);
limitedmap<uint256, int64_t>::const_iterator it = mapAlreadyAskedFor.find(inv.hash);
if (it != mapAlreadyAskedFor.end())
nRequestTime = it->second;
else
Expand All @@ -2455,7 +2455,7 @@ void CNode::AskFor(const CInv& inv)
if (it != mapAlreadyAskedFor.end())
mapAlreadyAskedFor.update(it, nRequestTime);
else
mapAlreadyAskedFor.insert(std::make_pair(inv, nRequestTime));
mapAlreadyAskedFor.insert(std::make_pair(inv.hash, nRequestTime));
mapAskFor.insert(std::make_pair(nRequestTime, inv));
}

Expand Down
2 changes: 1 addition & 1 deletion src/net.h
Expand Up @@ -164,7 +164,7 @@ extern CCriticalSection cs_vNodes;
extern std::map<CInv, CDataStream> mapRelay;
extern std::deque<std::pair<int64_t, CInv> > vRelayExpiration;
extern CCriticalSection cs_mapRelay;
extern limitedmap<CInv, int64_t> mapAlreadyAskedFor;
extern limitedmap<uint256, int64_t> mapAlreadyAskedFor;

extern std::vector<std::string> vAddedNodes;
extern CCriticalSection cs_vAddedNodes;
Expand Down

0 comments on commit 97d0b98

Please sign in to comment.