Skip to content

Commit

Permalink
bug fix: clear future cache when view change && modify cache of block…
Browse files Browse the repository at this point in the history
… number before go out of the lock when access commitBlock
  • Loading branch information
cyjseagull committed Mar 5, 2019
1 parent 869585e commit 8ec5f0c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
10 changes: 4 additions & 6 deletions libblockchain/BlockChainImp.cpp
Expand Up @@ -879,14 +879,12 @@ CommitResult BlockChainImp::commitBlock(Block& block, std::shared_ptr<ExecutiveC
writeTotalTransactionCount(block, context);
writeTxToBlock(block, context);
context->dbCommit(block);
{
WriteGuard ll(m_blockNumberMutex);
m_blockNumber = block.blockHeader().number();
}
}
m_blockCache.add(block);

{
WriteGuard ll(m_blockNumberMutex);
m_blockNumber = block.blockHeader().number();
}

m_onReady(m_blockNumber);
return CommitResult::OK;
}
Expand Down
3 changes: 2 additions & 1 deletion libconsensus/pbft/PBFTEngine.cpp
Expand Up @@ -1451,7 +1451,8 @@ void PBFTEngine::getAllNodesViewStatus(json_spirit::Array& status)
dev::network::NodeID node_id = getSealerByIndex(it.first);
if (node_id != dev::network::NodeID())
{
view_obj.push_back(json_spirit::Pair("0x" + dev::toHex(node_id), it.second));
view_obj.push_back(json_spirit::Pair("nodeId", dev::toHex(node_id)));
view_obj.push_back(json_spirit::Pair("view", it.second));
view_array.push_back(view_obj);
}
}
Expand Down
1 change: 1 addition & 0 deletions libconsensus/pbft/PBFTReqCache.h
Expand Up @@ -199,6 +199,7 @@ class PBFTReqCache : public std::enable_shared_from_this<PBFTReqCache>
m_prepareCache.clear();
m_signCache.clear();
m_commitCache.clear();
m_futurePrepareCache.clear();
removeInvalidViewChange(curView);
}
/// delete requests cached in m_signCache, m_commitCache and m_prepareCache according to hash
Expand Down

0 comments on commit 8ec5f0c

Please sign in to comment.