Skip to content

Commit

Permalink
Break out finalizecomaptblock errors to be more helpful
Browse files Browse the repository at this point in the history
  • Loading branch information
instagibbs committed Oct 10, 2019
1 parent 8fd1b52 commit fe8e6df
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1382,8 +1382,14 @@ UniValue finalizecompactblock(const JSONRPCRequest& request)

const std::vector<std::pair<uint256, CTransactionRef>> dummy;
std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>();
if (partialBlock.InitData(cmpctblock, dummy) != READ_STATUS_OK || partialBlock.FillBlock(*pblock, found, false /* pow_check*/) != READ_STATUS_OK) {
if (partialBlock.InitData(cmpctblock, dummy) != READ_STATUS_OK) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "compact_hex appears malformed.");
}
auto result = partialBlock.FillBlock(*pblock, found, false /* pow_check*/);
if (result == READ_STATUS_FAILED) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Failed to complete block though all transactions were apparently found. Could be random short ID collision; requires full block instead.");
} else if (result != READ_STATUS_OK) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Failed to complete block though all transactions were apparently found.");
}

CDataStream ssBlock(SER_NETWORK, PROTOCOL_VERSION);
Expand Down

0 comments on commit fe8e6df

Please sign in to comment.