Skip to content

Commit

Permalink
WIP: send 'notfound' for headers
Browse files Browse the repository at this point in the history
  • Loading branch information
furszy committed Jun 5, 2024
1 parent 14b18cb commit 2b57bb3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4554,11 +4554,13 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
// If locator is null, return the hashStop block
pindex = m_chainman.m_blockman.LookupBlockIndex(hashStop);
if (!pindex) {
MakeAndPushMessage(pfrom, NetMsgType::NOTFOUND, std::vector<CInv>{CInv(MSG_BLOCK_HEADER, hashStop)});
return;
}

if (!BlockRequestAllowed(pindex)) {
LogPrint(BCLog::NET, "%s: ignoring request from peer=%i for old block header that isn't in the main chain\n", __func__, pfrom.GetId());
MakeAndPushMessage(pfrom, NetMsgType::NOTFOUND, std::vector<CInv>{CInv(MSG_BLOCK_HEADER, hashStop)});
return;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ enum GetDataMsg : uint32_t {
// The following can only occur in getdata. Invs always use TX/WTX or BLOCK.
MSG_FILTERED_BLOCK = 3, //!< Defined in BIP37
MSG_CMPCT_BLOCK = 4, //!< Defined in BIP152
MSG_BLOCK_HEADER = 5, //!< Defined in BIP<>
MSG_WITNESS_BLOCK = MSG_BLOCK | MSG_WITNESS_FLAG, //!< Defined in BIP144
MSG_WITNESS_TX = MSG_TX | MSG_WITNESS_FLAG, //!< Defined in BIP144
// MSG_FILTERED_WITNESS_BLOCK is defined in BIP144 as reserved for future
Expand Down

0 comments on commit 2b57bb3

Please sign in to comment.