vertcoin-project / vertcoin-core

A digital currency with mining decentralisation and ASIC resistance as a key focus
https://vertcoin.org
MIT License
350 stars 134 forks source link

Reduce getheaders spam by serializing getheaders requests per peer #211

Closed cruelnovo closed 1 year ago

cruelnovo commented 2 years ago

This is gracefully borrowed from: https://github.com/dogecoin/dogecoin/pull/2417

Introduces a counter for getheader requests that have been sent to a peer but are pending response, reducing the number of parallel requests a node pushes out to its peers when needing to sync large amounts of headers. All getheader requests are serialized during initial sync, except when a non-connecting header is received, allowing the node to resolve issues with peers sending faulty blocks using the DoS mechanism, and when we get an inv for a block that we do not know, because it's possible we're only connected to legacy nodes that do not implement header announcement properly.

vertiond commented 1 year ago

Tested ACK. Header sync time noticeably faster without dropped connections.

This is in response to an issue with numerous dropped connections during header sync which appears to have become an unintended side-effect of https://github.com/vertcoin-project/vertcoin-core/commit/32feecdd9ed7a16f097aae3f85d6d215296cb7c8 (originally, https://github.com/vertcoin-project/vertcoin-core/pull/103).

Could you remove the .gitignore file and I'll squash? @cruelnovo

cruelnovo commented 1 year ago

Cleaned up my mess. PR should be good now.