diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -721,7 +721,6 @@ } uint256 hash = block.GetHash(); - bool fBlockPresent = false; { LOCK(cs_main); const CBlockIndex *pindex = LookupBlockIndex(hash); @@ -732,19 +731,21 @@ if (pindex->nStatus.isInvalid()) { return "duplicate-invalid"; } - // Otherwise, we might only have the header - process the block - // before returning - fBlockPresent = true; } } + bool new_block; submitblock_StateCatcher sc(block.GetHash()); RegisterValidationInterface(&sc); - bool fAccepted = ProcessNewBlock(config, blockptr, true, nullptr); + bool accepted = + ProcessNewBlock(config, blockptr, /* fForceProcessing */ true, + /* fNewBlock */ &new_block); UnregisterValidationInterface(&sc); - if (fBlockPresent) { - if (fAccepted && !sc.found) { - return "duplicate-inconclusive"; + if (!new_block) { + if (!accepted) { + // TODO Maybe pass down fNewBlock to AcceptBlockHeader, so it is + // properly set to true in this case? + return "invalid"; } return "duplicate"; } diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -4013,10 +4013,6 @@ } } - if (fNewBlock) { - *fNewBlock = true; - } - const CChainParams &chainparams = config.GetChainParams(); if (!CheckBlock(config, block, state, BlockValidationOptions(config)) || @@ -4053,6 +4049,9 @@ } // Write block to history file + if (fNewBlock) { + *fNewBlock = true; + } try { FlatFilePos blockPos = SaveBlockToDisk(block, pindex->nHeight, chainparams, dbp);