Skip to content

Commit

Permalink
806 improve consensus speed
Browse files Browse the repository at this point in the history
  • Loading branch information
kladkogex committed Mar 1, 2024
1 parent 66913ac commit a5bcf6d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions db/BlockProposalDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ void BlockProposalDB::addBlockProposal( const ptr< BlockProposal > _proposal ) {
// save own proposal to levelDB
if ( _proposal->getProposerIndex() == getSchain()->getSchainIndex() ) {

// for optimized consensus only the winner of the previous similar round will send the proposal
// to the network. Therefor we
// for optimized consensus only previous winner proposed.
// non-winners skip sending proposal and do not need to save it to the db
// since saving proposal to the db is done to be able to resend it in case of a
// crash
if (getSchain()->getOptimizerAgent()->skipSendingProposalToTheNetwork(_proposal->getBlockID()))
return;

Expand Down
4 changes: 2 additions & 2 deletions monitoring/OptimizerAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ schain_index OptimizerAgent::getLastWinner(block_id _blockId) {
}

schain_index OptimizerAgent::skipSendingProposalToTheNetwork(block_id _blockId) {
// node skips sending proposal if the current block consensus
// is optimized consensus and if node chain index is not equal to the last winner
// whe we run optimized consensus a node skips sending proposal to the network
// if node chain index is not equal to the last winner
return (getSchain()->getOptimizerAgent()->doOptimizedConsensus(_blockId) &&
(getSchain()->getOptimizerAgent()->getLastWinner(_blockId) != getSchain()->getSchainIndex()));
}
Expand Down

0 comments on commit a5bcf6d

Please sign in to comment.