Skip to content

Commit fa6e497

Browse files
author
MarcoFalke
committed
rpc: Avoid "duplicate" return value for invalid submitblock
1 parent 0de7cc8 commit fa6e497

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/rpc/mining.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,6 @@ static UniValue submitblock(const JSONRPCRequest& request)
725725
}
726726

727727
uint256 hash = block.GetHash();
728-
bool fBlockPresent = false;
729728
{
730729
LOCK(cs_main);
731730
const CBlockIndex* pindex = LookupBlockIndex(hash);
@@ -736,8 +735,6 @@ static UniValue submitblock(const JSONRPCRequest& request)
736735
if (pindex->nStatus & BLOCK_FAILED_MASK) {
737736
return "duplicate-invalid";
738737
}
739-
// Otherwise, we might only have the header - process the block before returning
740-
fBlockPresent = true;
741738
}
742739
}
743740

@@ -749,13 +746,15 @@ static UniValue submitblock(const JSONRPCRequest& request)
749746
}
750747
}
751748

749+
bool new_block;
752750
submitblock_StateCatcher sc(block.GetHash());
753751
RegisterValidationInterface(&sc);
754-
bool fAccepted = ProcessNewBlock(Params(), blockptr, true, nullptr);
752+
bool accepted = ProcessNewBlock(Params(), blockptr, /* fForceProcessing */ true, /* fNewBlock */ &new_block);
755753
UnregisterValidationInterface(&sc);
756-
if (fBlockPresent) {
757-
if (fAccepted && !sc.found) {
758-
return "duplicate-inconclusive";
754+
if (!new_block) {
755+
if (!accepted) {
756+
// TODO Maybe pass down fNewBlock to AcceptBlockHeader, so it is properly set to true in this case?
757+
return "invalid";
759758
}
760759
return "duplicate";
761760
}

0 commit comments

Comments
 (0)