Merge bitcoin/bitcoin#26172: p2p: ProcessHeadersMessage(): fix received_new_header

bdcafb9133 p2p: ProcessHeadersMessage(): fix received_new_header (Larry Ruane)

Pull request description:

  Follow-up to #25717. The commit "Utilize anti-DoS headers download strategy" changed how this bool variable is computed, so that its value is now the opposite of what it should be.

  Prior to #25717:
  ```
  bool received_new_header{WITH_LOCK(::cs_main, return m_chainman.m_blockman.LookupBlockIndex(headers.back().GetHash()) == nullptr)};
  ```
  After #25717 (simplified):
  ```
  {
      LOCK(cs_main);
      last_received_header = m_chainman.m_blockman.LookupBlockIndex(headers.back().GetHash());
  }
  bool received_new_header{last_received_header != nullptr};
  ```

ACKs for top commit:
  dergoegge:
    ACK bdcafb9133
  glozow:
    ACK bdcafb9133, I believe this is correct and don't see anything to suggest the switch was intentional.
  stickies-v:
    ACK bdcafb9133

Tree-SHA512: 35c12762f1429585a0b1c15053e310e83efb28c3d8cbf4092fad9fe81c893f6d766df1f2b20624882acb9654d0539a0c871f587d7090dc2a198115adf59db3ec
This commit is contained in:
glozow 2022-09-27 10:54:16 +01:00
commit 9fcdb9f3a0
No known key found for this signature in database
GPG key ID: BA03F4DBE0C63FB4

View file

@ -2846,7 +2846,7 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, Peer& peer,
// If we don't have the last header, then this peer will have given us // If we don't have the last header, then this peer will have given us
// something new (if these headers are valid). // something new (if these headers are valid).
bool received_new_header{last_received_header != nullptr}; bool received_new_header{last_received_header == nullptr};
// Now process all the headers. // Now process all the headers.
BlockValidationState state; BlockValidationState state;