diff options
| author | João Barbosa <[email protected]> | 2018-01-12 00:23:09 +0000 |
|---|---|---|
| committer | João Barbosa <[email protected]> | 2018-03-06 19:52:19 +0000 |
| commit | 92fabcd443322dcfdf2b3477515fae79e8647d86 (patch) | |
| tree | 5511c22adffa3eaccb75afdd2ec53c81550ff7d3 /src/rpc/mining.cpp | |
| parent | Add missing cs_lock in CreateWalletFromFile (diff) | |
| download | discoin-92fabcd443322dcfdf2b3477515fae79e8647d86.tar.xz discoin-92fabcd443322dcfdf2b3477515fae79e8647d86.zip | |
Add LookupBlockIndex function
Diffstat (limited to 'src/rpc/mining.cpp')
| -rw-r--r-- | src/rpc/mining.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 3f3bfa0cf..d8f3c40ba 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -396,9 +396,8 @@ UniValue getblocktemplate(const JSONRPCRequest& request) throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block decode failed"); uint256 hash = block.GetHash(); - BlockMap::iterator mi = mapBlockIndex.find(hash); - if (mi != mapBlockIndex.end()) { - CBlockIndex *pindex = mi->second; + const CBlockIndex* pindex = LookupBlockIndex(hash); + if (pindex) { if (pindex->IsValid(BLOCK_VALID_SCRIPTS)) return "duplicate"; if (pindex->nStatus & BLOCK_FAILED_MASK) @@ -727,9 +726,8 @@ UniValue submitblock(const JSONRPCRequest& request) bool fBlockPresent = false; { LOCK(cs_main); - BlockMap::iterator mi = mapBlockIndex.find(hash); - if (mi != mapBlockIndex.end()) { - CBlockIndex *pindex = mi->second; + const CBlockIndex* pindex = LookupBlockIndex(hash); + if (pindex) { if (pindex->IsValid(BLOCK_VALID_SCRIPTS)) { return "duplicate"; } @@ -743,9 +741,9 @@ UniValue submitblock(const JSONRPCRequest& request) { LOCK(cs_main); - BlockMap::iterator mi = mapBlockIndex.find(block.hashPrevBlock); - if (mi != mapBlockIndex.end()) { - UpdateUncommittedBlockStructures(block, mi->second, Params().GetConsensus()); + const CBlockIndex* pindex = LookupBlockIndex(block.hashPrevBlock); + if (pindex) { + UpdateUncommittedBlockStructures(block, pindex, Params().GetConsensus()); } } |