mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Politely and safely refuse getheaders requests for headers we have trimmed.
This commit is contained in:
parent
763d29895f
commit
394e59d38d
1 changed files with 7 additions and 0 deletions
|
|
@ -3166,10 +3166,17 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
|||
LogPrint(BCLog::NET, "getheaders %d to %s from peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop.IsNull() ? "end" : hashStop.ToString(), pfrom.GetId());
|
||||
for (; pindex; pindex = m_chainman.ActiveChain().Next(pindex))
|
||||
{
|
||||
if (pindex->trimmed()) {
|
||||
// For simplicity, if any of the headers they're asking for are trimmed,
|
||||
// just drop the request.
|
||||
LogPrint(BCLog::NET, "%s: ignoring getheaders from peer=%i which would return at least one trimmed header\n", __func__, pfrom.GetId());
|
||||
return;
|
||||
}
|
||||
vHeaders.push_back(pindex->GetBlockHeader());
|
||||
if (--nLimit <= 0 || pindex->GetBlockHash() == hashStop)
|
||||
break;
|
||||
}
|
||||
|
||||
// pindex can be nullptr either if we sent m_chainman.ActiveChain().Tip() OR
|
||||
// if our peer has m_chainman.ActiveChain().Tip() (and thus we are sending an empty
|
||||
// headers message). In both cases it's safe to update
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue