Skip to content

Commit

Permalink
write instead of insert if it already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
alex v committed Nov 18, 2019
1 parent 70a96a7 commit fcc66d1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/coins.cpp
Expand Up @@ -251,15 +251,23 @@ bool CCoinsViewCache::AddProposal(const CProposal& proposal) const {
if (HaveProposal(proposal.hash))
return false;

cacheProposals.insert(std::make_pair(proposal.hash, proposal));
if (cacheProposals.count(proposal.hash))
cacheProposals[proposal.hash]=proposal;
else
cacheProposals.insert(std::make_pair(proposal.hash, proposal));

return true;
}

bool CCoinsViewCache::AddPaymentRequest(const CPaymentRequest& prequest) const {
if (HavePaymentRequest(prequest.hash))
return false;
cachePaymentRequests.insert(std::make_pair(prequest.hash, prequest));

if (cachePaymentRequests.count(prequest.hash))
cachePaymentRequests[prequest.hash]=prequest;
else
cachePaymentRequests.insert(std::make_pair(prequest.hash, prequest));

return true;
}

Expand Down

0 comments on commit fcc66d1

Please sign in to comment.