Skip to content

Commit f4f0391

Browse files
author
Mark Travis
committed
Scott S review fixes. Also clang-format.
1 parent 4ad9cbf commit f4f0391

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

src/ripple/consensus/Consensus.h

+26-14
Original file line numberDiff line numberDiff line change
@@ -1861,7 +1861,7 @@ Consensus<Adaptor>::updateOurPositions(bool const share)
18611861
<< static_cast<std::uint32_t>(previousLedger_.seq()) + 1
18621862
<< " Close times and vote count are as follows: ";
18631863
bool first = true;
1864-
for (auto const& [closeTime, voteCount]: closeTimeVotes)
1864+
for (auto const& [closeTime, voteCount] : closeTimeVotes)
18651865
{
18661866
if (first)
18671867
first = false;
@@ -1870,14 +1870,18 @@ Consensus<Adaptor>::updateOurPositions(bool const share)
18701870
votesByCloseTime.insert({voteCount, closeTime});
18711871
ss << closeTime.time_since_epoch().count() << ':' << voteCount;
18721872
}
1873+
// These always gets populated because currPeerPositions_ is not
1874+
// empty to end up here, so at least 1 close time has at least 1 vote.
1875+
assert(!currPeerPositions_.empty());
18731876
std::optional<int> maxVote;
18741877
std::set<NetClock::time_point> maxCloseTimes;
18751878
// Highest vote getter is last. Track each close time that is tied
18761879
// with the highest.
18771880
for (auto rit = votesByCloseTime.crbegin();
1878-
rit != votesByCloseTime.crend(); ++rit)
1881+
rit != votesByCloseTime.crend();
1882+
++rit)
18791883
{
1880-
int const& voteCount = rit->first;
1884+
int const voteCount = rit->first;
18811885
if (!maxVote.has_value())
18821886
maxVote = voteCount;
18831887
else if (voteCount < *maxVote)
@@ -1888,8 +1892,9 @@ Consensus<Adaptor>::updateOurPositions(bool const share)
18881892
// the maximum number of votes.
18891893
NetClock::time_point const bestCloseTime = *maxCloseTimes.crbegin();
18901894
ss << ". The best close time has the most votes. If there is a tie, "
1891-
"choose the latest. This is " << bestCloseTime.time_since_epoch().count() <<
1892-
"with " << *maxVote << " votes. ";
1895+
"choose the latest. This is "
1896+
<< bestCloseTime.time_since_epoch().count() << "with " << *maxVote
1897+
<< " votes. ";
18931898

18941899
// If we are a validator potentially at an impasse and our own close
18951900
// time is not the best, change our close time to match it and
@@ -1900,10 +1905,16 @@ Consensus<Adaptor>::updateOurPositions(bool const share)
19001905
consensusCloseTime = bestCloseTime;
19011906
++*maxVote;
19021907
ss << " We are a validator. Consensus has taken "
1903-
<< result_->roundTime.read().count() << "ms. Previous round "
1904-
"took " << prevRoundTime_.count() << "ms. Now changing our "
1905-
"close time to " << bestCloseTime.time_since_epoch().count() << " that "
1906-
"now has " << *maxVote << " votes.";
1908+
<< result_->roundTime.read().count()
1909+
<< "ms. Previous round "
1910+
"took "
1911+
<< prevRoundTime_.count()
1912+
<< "ms. Now changing our "
1913+
"close time to "
1914+
<< bestCloseTime.time_since_epoch().count()
1915+
<< " that "
1916+
"now has "
1917+
<< *maxVote << " votes.";
19071918
}
19081919
// If the close time with the most votes also meets or exceeds the
19091920
// threshold to change our position, then change our position.
@@ -1917,14 +1928,15 @@ Consensus<Adaptor>::updateOurPositions(bool const share)
19171928
if (*maxVote >= threshVote)
19181929
{
19191930
consensusCloseTime = bestCloseTime;
1920-
ss << "Close time " << bestCloseTime.time_since_epoch().count() << " has " <<
1921-
*maxVote << " votes, which is >= the threshold (" << threshVote
1922-
<< " to make that our positions if it isn't already.";
1931+
ss << "Close time " << bestCloseTime.time_since_epoch().count()
1932+
<< " has " << *maxVote << " votes, which is >= the threshold ("
1933+
<< threshVote
1934+
<< " to make that our position if it isn't already.";
19231935
if (*maxVote >= threshConsensus)
19241936
{
19251937
haveCloseTimeConsensus_ = true;
1926-
ss << " The maximum votes also >= the threshold (" << threshConsensus
1927-
<< ") for consensus.";
1938+
ss << " The maximum votes also >= the threshold ("
1939+
<< threshConsensus << ") for consensus.";
19281940
}
19291941
}
19301942

0 commit comments

Comments
 (0)