update comment on MinimumChainWork check

This commit is contained in:
marcofleon 2025-01-15 14:42:32 +00:00
parent c20a5ce106
commit 632ae47372

View file

@ -4142,13 +4142,9 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
LOCK(cs_main); LOCK(cs_main);
// Note that if we were to be on a chain that forks from the checkpointed // Don't serve headers from our active chain until our chainwork is at least
// chain, then serving those headers to a peer that has seen the // the minimum chain work. This prevents us from starting a low-work headers
// checkpointed chain would cause that peer to disconnect us. Requiring // sync that will inevitably be aborted by our peer.
// that our chainwork exceed the minimum chain work is a protection against
// being fed a bogus chain when we started up for the first time and
// getting partitioned off the honest network for serving that chain to
// others.
if (m_chainman.ActiveTip() == nullptr || if (m_chainman.ActiveTip() == nullptr ||
(m_chainman.ActiveTip()->nChainWork < m_chainman.MinimumChainWork() && !pfrom.HasPermission(NetPermissionFlags::Download))) { (m_chainman.ActiveTip()->nChainWork < m_chainman.MinimumChainWork() && !pfrom.HasPermission(NetPermissionFlags::Download))) {
LogDebug(BCLog::NET, "Ignoring getheaders from peer=%d because active chain has too little work; sending empty response\n", pfrom.GetId()); LogDebug(BCLog::NET, "Ignoring getheaders from peer=%d because active chain has too little work; sending empty response\n", pfrom.GetId());