Skip to content

Commit e5ce857

Browse files
committed
log: net: new header over cmpctblock
1 parent 40e1c4d commit e5ce857

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/net_processing.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4190,6 +4190,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
41904190
vRecv >> cmpctblock;
41914191

41924192
bool received_new_header = false;
4193+
const auto blockhash = cmpctblock.header.GetHash();
41934194

41944195
{
41954196
LOCK(cs_main);
@@ -4207,7 +4208,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
42074208
return;
42084209
}
42094210

4210-
if (!m_chainman.m_blockman.LookupBlockIndex(cmpctblock.header.GetHash())) {
4211+
if (!m_chainman.m_blockman.LookupBlockIndex(blockhash)) {
42114212
received_new_header = true;
42124213
}
42134214
}
@@ -4221,6 +4222,11 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
42214222
}
42224223
}
42234224

4225+
if (received_new_header) {
4226+
LogPrintfCategory(BCLog::NET, "Saw new cmpctblock header hash=%s peer=%d\n",
4227+
blockhash.ToString(), pfrom.GetId());
4228+
}
4229+
42244230
// When we succeed in decoding a block's txids from a cmpctblock
42254231
// message we typically jump to the BLOCKTXN handling code, with a
42264232
// dummy (empty) BLOCKTXN message, to re-use the logic there in
@@ -4263,7 +4269,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
42634269
// We requested this block for some reason, but our mempool will probably be useless
42644270
// so we just grab the block via normal getdata
42654271
std::vector<CInv> vInv(1);
4266-
vInv[0] = CInv(MSG_BLOCK | GetFetchFlags(*peer), cmpctblock.header.GetHash());
4272+
vInv[0] = CInv(MSG_BLOCK | GetFetchFlags(*peer), blockhash);
42674273
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::GETDATA, vInv));
42684274
}
42694275
return;
@@ -4299,7 +4305,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
42994305
} else if (status == READ_STATUS_FAILED) {
43004306
// Duplicate txindexes, the block is now in-flight, so just request it
43014307
std::vector<CInv> vInv(1);
4302-
vInv[0] = CInv(MSG_BLOCK | GetFetchFlags(*peer), cmpctblock.header.GetHash());
4308+
vInv[0] = CInv(MSG_BLOCK | GetFetchFlags(*peer), blockhash);
43034309
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::GETDATA, vInv));
43044310
return;
43054311
}
@@ -4312,7 +4318,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
43124318
if (req.indexes.empty()) {
43134319
// Dirty hack to jump to BLOCKTXN code (TODO: move message handling into their own functions)
43144320
BlockTransactions txn;
4315-
txn.blockhash = cmpctblock.header.GetHash();
4321+
txn.blockhash = blockhash;
43164322
blockTxnMsg << txn;
43174323
fProcessBLOCKTXN = true;
43184324
} else {
@@ -4342,7 +4348,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
43424348
// We requested this block, but its far into the future, so our
43434349
// mempool will probably be useless - request the block normally
43444350
std::vector<CInv> vInv(1);
4345-
vInv[0] = CInv(MSG_BLOCK | GetFetchFlags(*peer), cmpctblock.header.GetHash());
4351+
vInv[0] = CInv(MSG_BLOCK | GetFetchFlags(*peer), blockhash);
43464352
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::GETDATA, vInv));
43474353
return;
43484354
} else {

0 commit comments

Comments
 (0)