diff options
| author | MarcoFalke <[email protected]> | 2018-06-04 20:24:09 -0400 |
|---|---|---|
| committer | MarcoFalke <[email protected]> | 2018-06-11 15:08:50 -0400 |
| commit | fa6e49731bb7d390c9ed66fc2d8ce3c4fa9b074f (patch) | |
| tree | 7f7df585b0138b18132c9c052ad86b7ab6834bf5 /src/rpc/mining.cpp | |
| parent | Merge #13191: Specialized double-SHA256 with 64 byte inputs with SSE4.1 and AVX2 (diff) | |
| download | discoin-fa6e49731bb7d390c9ed66fc2d8ce3c4fa9b074f.tar.xz discoin-fa6e49731bb7d390c9ed66fc2d8ce3c4fa9b074f.zip | |
rpc: Avoid "duplicate" return value for invalid submitblock
Diffstat (limited to 'src/rpc/mining.cpp')
| -rw-r--r-- | src/rpc/mining.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 203fac39e..b2d857108 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -725,7 +725,6 @@ static UniValue submitblock(const JSONRPCRequest& request) } uint256 hash = block.GetHash(); - bool fBlockPresent = false; { LOCK(cs_main); const CBlockIndex* pindex = LookupBlockIndex(hash); @@ -736,8 +735,6 @@ static UniValue submitblock(const JSONRPCRequest& request) if (pindex->nStatus & BLOCK_FAILED_MASK) { return "duplicate-invalid"; } - // Otherwise, we might only have the header - process the block before returning - fBlockPresent = true; } } @@ -749,13 +746,15 @@ static UniValue submitblock(const JSONRPCRequest& request) } } + bool new_block; submitblock_StateCatcher sc(block.GetHash()); RegisterValidationInterface(&sc); - bool fAccepted = ProcessNewBlock(Params(), blockptr, true, nullptr); + bool accepted = ProcessNewBlock(Params(), 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"; } |