mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 13:32:47 +01:00
Merge #7960: Only use AddInventoryKnown for transactions
383fc10
Only use AddInventoryKnown for transactions (Suhas Daftuar)
This commit is contained in:
commit
6a22373771
13
src/main.cpp
13
src/main.cpp
@ -4822,7 +4822,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||||||
const CInv &inv = vInv[nInv];
|
const CInv &inv = vInv[nInv];
|
||||||
|
|
||||||
boost::this_thread::interruption_point();
|
boost::this_thread::interruption_point();
|
||||||
pfrom->AddInventoryKnown(inv);
|
|
||||||
|
|
||||||
bool fAlreadyHave = AlreadyHave(inv);
|
bool fAlreadyHave = AlreadyHave(inv);
|
||||||
LogPrint("net", "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom->id);
|
LogPrint("net", "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom->id);
|
||||||
@ -4852,6 +4851,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
pfrom->AddInventoryKnown(inv);
|
||||||
if (fBlocksOnly)
|
if (fBlocksOnly)
|
||||||
LogPrint("net", "transaction (%s) inv sent in violation of protocol peer=%d\n", inv.hash.ToString(), pfrom->id);
|
LogPrint("net", "transaction (%s) inv sent in violation of protocol peer=%d\n", inv.hash.ToString(), pfrom->id);
|
||||||
else if (!fAlreadyHave && !fImporting && !fReindex && !IsInitialBlockDownload())
|
else if (!fAlreadyHave && !fImporting && !fReindex && !IsInitialBlockDownload())
|
||||||
@ -5239,10 +5239,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||||||
CBlock block;
|
CBlock block;
|
||||||
vRecv >> block;
|
vRecv >> block;
|
||||||
|
|
||||||
CInv inv(MSG_BLOCK, block.GetHash());
|
LogPrint("net", "received block %s peer=%d\n", block.GetHash().ToString(), pfrom->id);
|
||||||
LogPrint("net", "received block %s peer=%d\n", inv.hash.ToString(), pfrom->id);
|
|
||||||
|
|
||||||
pfrom->AddInventoryKnown(inv);
|
|
||||||
|
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
// Process all blocks from whitelisted peers, even if not requested,
|
// Process all blocks from whitelisted peers, even if not requested,
|
||||||
@ -5255,7 +5252,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||||||
if (state.IsInvalid(nDoS)) {
|
if (state.IsInvalid(nDoS)) {
|
||||||
assert (state.GetRejectCode() < REJECT_INTERNAL); // Blocks are never rejected with internal reject codes
|
assert (state.GetRejectCode() < REJECT_INTERNAL); // Blocks are never rejected with internal reject codes
|
||||||
pfrom->PushMessage(NetMsgType::REJECT, strCommand, (unsigned char)state.GetRejectCode(),
|
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) {
|
if (nDoS > 0) {
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
Misbehaving(pfrom->GetId(), nDoS);
|
Misbehaving(pfrom->GetId(), nDoS);
|
||||||
@ -5827,9 +5824,7 @@ bool SendMessages(CNode* pto)
|
|||||||
hashToAnnounce.ToString(), chainActive.Tip()->GetBlockHash().ToString());
|
hashToAnnounce.ToString(), chainActive.Tip()->GetBlockHash().ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the peer announced this block to us, don't inv it back.
|
// If the peer's chain has this block, 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 (!PeerHasHeader(&state, pindex)) {
|
if (!PeerHasHeader(&state, pindex)) {
|
||||||
pto->PushInventory(CInv(MSG_BLOCK, hashToAnnounce));
|
pto->PushInventory(CInv(MSG_BLOCK, hashToAnnounce));
|
||||||
LogPrint("net", "%s: sending inv peer=%d hash=%s\n", __func__,
|
LogPrint("net", "%s: sending inv peer=%d hash=%s\n", __func__,
|
||||||
|
Loading…
Reference in New Issue
Block a user