aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuhas Daftuar <sdaftuar@chaincode.com>2016-04-27 09:57:02 -0400
committerSuhas Daftuar <sdaftuar@chaincode.com>2016-04-27 09:57:02 -0400
commit383fc10ebb8e9ffe88c1b9e2ea706c76e5a6343e (patch)
tree8b00c04741a399d5eafa6b85a98c3323c71a66b8
parente26b62093ae21e89ed7d36a24a6b863f38ec631d (diff)
Only use AddInventoryKnown for transactions
filterInventoryKnown is only used when relaying transactions, so stop adding block hashes to the filter.
-rw-r--r--src/main.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/main.cpp b/src/main.cpp
index f6a89fa2e6..90db9de14e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -4765,7 +4765,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
const CInv &inv = vInv[nInv];
boost::this_thread::interruption_point();
- pfrom->AddInventoryKnown(inv);
bool fAlreadyHave = AlreadyHave(inv);
LogPrint("net", "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom->id);
@@ -4795,6 +4794,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
}
else
{
+ pfrom->AddInventoryKnown(inv);
if (fBlocksOnly)
LogPrint("net", "transaction (%s) inv sent in violation of protocol peer=%d\n", inv.hash.ToString(), pfrom->id);
else if (!fAlreadyHave && !fImporting && !fReindex && !IsInitialBlockDownload())
@@ -5173,10 +5173,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
CBlock block;
vRecv >> block;
- CInv inv(MSG_BLOCK, block.GetHash());
- LogPrint("net", "received block %s peer=%d\n", inv.hash.ToString(), pfrom->id);
-
- pfrom->AddInventoryKnown(inv);
+ LogPrint("net", "received block %s peer=%d\n", block.GetHash().ToString(), pfrom->id);
CValidationState state;
// Process all blocks from whitelisted peers, even if not requested,
@@ -5189,7 +5186,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
if (state.IsInvalid(nDoS)) {
assert (state.GetRejectCode() < REJECT_INTERNAL); // Blocks are never rejected with internal reject codes
pfrom->PushMessage(NetMsgType::REJECT, strCommand, (unsigned char)state.GetRejectCode(),
- state.GetRejectReason().substr(0, MAX_REJECT_MESSAGE_LENGTH), inv.hash);
+ state.GetRejectReason().substr(0, MAX_REJECT_MESSAGE_LENGTH), block.GetHash());
if (nDoS > 0) {
LOCK(cs_main);
Misbehaving(pfrom->GetId(), nDoS);
@@ -5769,9 +5766,7 @@ bool SendMessages(CNode* pto)
hashToAnnounce.ToString(), chainActive.Tip()->GetBlockHash().ToString());
}
- // If the peer announced this block to us, don't inv it back.
- // (Since block announcements may not be via inv's, we can't solely rely on
- // setInventoryKnown to track this.)
+ // If the peer's chain has this block, don't inv it back.
if (!PeerHasHeader(&state, pindex)) {
pto->PushInventory(CInv(MSG_BLOCK, hashToAnnounce));
LogPrint("net", "%s: sending inv peer=%d hash=%s\n", __func__,