Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/mining.cpp
Show First 20 Lines • Show All 474 Lines • ▼ Show 20 Lines | if (!request.params[0].isNull()) { | ||||
CBlock block; | CBlock block; | ||||
if (!DecodeHexBlk(block, dataval.get_str())) { | if (!DecodeHexBlk(block, dataval.get_str())) { | ||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, | throw JSONRPCError(RPC_DESERIALIZATION_ERROR, | ||||
"Block decode failed"); | "Block decode failed"); | ||||
} | } | ||||
uint256 hash = block.GetHash(); | uint256 hash = block.GetHash(); | ||||
BlockMap::iterator mi = mapBlockIndex.find(hash); | const CBlockIndex *pindex = LookupBlockIndex(hash); | ||||
if (mi != mapBlockIndex.end()) { | if (pindex) { | ||||
CBlockIndex *pindex = mi->second; | |||||
if (pindex->IsValid(BlockValidity::SCRIPTS)) { | if (pindex->IsValid(BlockValidity::SCRIPTS)) { | ||||
return "duplicate"; | return "duplicate"; | ||||
} | } | ||||
if (pindex->nStatus.isInvalid()) { | if (pindex->nStatus.isInvalid()) { | ||||
return "duplicate-invalid"; | return "duplicate-invalid"; | ||||
} | } | ||||
return "duplicate-inconclusive"; | return "duplicate-inconclusive"; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 237 Lines • ▼ Show 20 Lines | if (block.vtx.empty() || !block.vtx[0]->IsCoinBase()) { | ||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, | throw JSONRPCError(RPC_DESERIALIZATION_ERROR, | ||||
"Block does not start with a coinbase"); | "Block does not start with a coinbase"); | ||||
} | } | ||||
uint256 hash = block.GetHash(); | uint256 hash = block.GetHash(); | ||||
bool fBlockPresent = false; | bool fBlockPresent = false; | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
BlockMap::iterator mi = mapBlockIndex.find(hash); | const CBlockIndex *pindex = LookupBlockIndex(hash); | ||||
if (mi != mapBlockIndex.end()) { | if (pindex) { | ||||
CBlockIndex *pindex = mi->second; | |||||
if (pindex->IsValid(BlockValidity::SCRIPTS)) { | if (pindex->IsValid(BlockValidity::SCRIPTS)) { | ||||
return "duplicate"; | return "duplicate"; | ||||
} | } | ||||
if (pindex->nStatus.isInvalid()) { | if (pindex->nStatus.isInvalid()) { | ||||
return "duplicate-invalid"; | return "duplicate-invalid"; | ||||
} | } | ||||
// Otherwise, we might only have the header - process the block | // Otherwise, we might only have the header - process the block | ||||
// before returning | // before returning | ||||
▲ Show 20 Lines • Show All 69 Lines • Show Last 20 Lines |