diff --git a/doc/release-notes.md b/doc/release-notes.md --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -6,3 +6,5 @@ - The RPC `getrpcinfo` returns runtime details of the RPC server. At the moment it returns the active commands and the corresponding execution time. + - Seeder now filters out nodes that are not following the BCH chain up to the + most recent checkpoint. This applies to both mainnet and testnet. diff --git a/src/seeder/bitcoin.h b/src/seeder/bitcoin.h --- a/src/seeder/bitcoin.h +++ b/src/seeder/bitcoin.h @@ -46,7 +46,9 @@ void PushVersion(); - void GotVersion(); + void CheckpointVerified(); + + void RequestBlocksAfterCheckpoint(); bool ProcessMessages(); diff --git a/src/seeder/bitcoin.cpp b/src/seeder/bitcoin.cpp --- a/src/seeder/bitcoin.cpp +++ b/src/seeder/bitcoin.cpp @@ -92,7 +92,7 @@ EndMessage(); } -void CSeederNode::GotVersion() { +void CSeederNode::CheckpointVerified() { // fprintf(stdout, "\n%s: version %i\n", ToString(you).c_str(), // nVersion); if (vAddr) { @@ -104,6 +104,21 @@ } } +void CSeederNode::RequestBlocksAfterCheckpoint() { + // Create a getheaders message + BeginMessage("getheaders"); + // Locator hash; Seeder requests the headers after the latest checkpoint + uint256 seederCheckpoint = + Params().Checkpoints().mapCheckpoints.rbegin()->second; + std::vector hashStop(32, 0); + uint8_t numberOfLocatorHashes = 1; + vSend << PROTOCOL_VERSION << numberOfLocatorHashes << seederCheckpoint + << uint256(hashStop); + EndMessage(); + // Update socket timeout + doneAfter = time(nullptr) + GetTimeout(); +} + bool CSeederNode::ProcessMessage(std::string strCommand, CDataStream &recv) { // fprintf(stdout, "%s: RECV %s\n", ToString(you).c_str(), // strCommand.c_str()); @@ -127,7 +142,7 @@ if (strCommand == "verack") { vRecv.SetVersion(std::min(nVersion, PROTOCOL_VERSION)); - GotVersion(); + RequestBlocksAfterCheckpoint(); return false; } @@ -187,6 +202,7 @@ header.hashPrevBlock) { // fprintf(stderr, "Peer (%s) found seeder checkpoint.\n", // ToString(you).c_str()); + CheckpointVerified(); return false; }