diff options
| author | Suhas Daftuar <[email protected]> | 2017-10-26 14:54:33 -0400 |
|---|---|---|
| committer | Suhas Daftuar <[email protected]> | 2017-10-27 16:29:12 -0400 |
| commit | 37886d5e2f9992678dea4b1bd893f4f10d61d3ad (patch) | |
| tree | 25a7e92c05cad5014c522310e76efd4fbf88bb84 /src/validation.cpp | |
| parent | moveonly: factor out headers processing into separate function (diff) | |
| download | discoin-37886d5e2f9992678dea4b1bd893f4f10d61d3ad.tar.xz discoin-37886d5e2f9992678dea4b1bd893f4f10d61d3ad.zip | |
Disconnect outbound peers relaying invalid headers
Diffstat (limited to 'src/validation.cpp')
| -rw-r--r-- | src/validation.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index 866e0c9fb..78eb6d730 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3079,13 +3079,15 @@ static bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state } // Exposed wrapper for AcceptBlockHeader -bool ProcessNewBlockHeaders(const std::vector<CBlockHeader>& headers, CValidationState& state, const CChainParams& chainparams, const CBlockIndex** ppindex) +bool ProcessNewBlockHeaders(const std::vector<CBlockHeader>& headers, CValidationState& state, const CChainParams& chainparams, const CBlockIndex** ppindex, CBlockHeader *first_invalid) { + if (first_invalid != nullptr) first_invalid->SetNull(); { LOCK(cs_main); for (const CBlockHeader& header : headers) { CBlockIndex *pindex = nullptr; // Use a temp pindex instead of ppindex to avoid a const_cast if (!AcceptBlockHeader(header, state, chainparams, &pindex)) { + if (first_invalid) *first_invalid = header; return false; } if (ppindex) { |