mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 18:53:23 -03:00
rpc: Avoid "duplicate" return value for invalid submitblock
This commit is contained in:
parent
0de7cc848e
commit
fa6e49731b
1 changed files with 6 additions and 7 deletions
|
@ -725,7 +725,6 @@ static UniValue submitblock(const JSONRPCRequest& request)
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 hash = block.GetHash();
|
uint256 hash = block.GetHash();
|
||||||
bool fBlockPresent = false;
|
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
const CBlockIndex* pindex = LookupBlockIndex(hash);
|
const CBlockIndex* pindex = LookupBlockIndex(hash);
|
||||||
|
@ -736,8 +735,6 @@ static UniValue submitblock(const JSONRPCRequest& request)
|
||||||
if (pindex->nStatus & BLOCK_FAILED_MASK) {
|
if (pindex->nStatus & BLOCK_FAILED_MASK) {
|
||||||
return "duplicate-invalid";
|
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());
|
submitblock_StateCatcher sc(block.GetHash());
|
||||||
RegisterValidationInterface(&sc);
|
RegisterValidationInterface(&sc);
|
||||||
bool fAccepted = ProcessNewBlock(Params(), blockptr, true, nullptr);
|
bool accepted = ProcessNewBlock(Params(), blockptr, /* fForceProcessing */ true, /* fNewBlock */ &new_block);
|
||||||
UnregisterValidationInterface(&sc);
|
UnregisterValidationInterface(&sc);
|
||||||
if (fBlockPresent) {
|
if (!new_block) {
|
||||||
if (fAccepted && !sc.found) {
|
if (!accepted) {
|
||||||
return "duplicate-inconclusive";
|
// TODO Maybe pass down fNewBlock to AcceptBlockHeader, so it is properly set to true in this case?
|
||||||
|
return "invalid";
|
||||||
}
|
}
|
||||||
return "duplicate";
|
return "duplicate";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue