@@ -1861,7 +1861,7 @@ Consensus<Adaptor>::updateOurPositions(bool const share)
1861
1861
<< static_cast <std::uint32_t >(previousLedger_.seq ()) + 1
1862
1862
<< " Close times and vote count are as follows: " ;
1863
1863
bool first = true ;
1864
- for (auto const & [closeTime, voteCount]: closeTimeVotes)
1864
+ for (auto const & [closeTime, voteCount] : closeTimeVotes)
1865
1865
{
1866
1866
if (first)
1867
1867
first = false ;
@@ -1870,14 +1870,18 @@ Consensus<Adaptor>::updateOurPositions(bool const share)
1870
1870
votesByCloseTime.insert ({voteCount, closeTime});
1871
1871
ss << closeTime.time_since_epoch ().count () << ' :' << voteCount;
1872
1872
}
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 ());
1873
1876
std::optional<int > maxVote;
1874
1877
std::set<NetClock::time_point> maxCloseTimes;
1875
1878
// Highest vote getter is last. Track each close time that is tied
1876
1879
// with the highest.
1877
1880
for (auto rit = votesByCloseTime.crbegin ();
1878
- rit != votesByCloseTime.crend (); ++rit)
1881
+ rit != votesByCloseTime.crend ();
1882
+ ++rit)
1879
1883
{
1880
- int const & voteCount = rit->first ;
1884
+ int const voteCount = rit->first ;
1881
1885
if (!maxVote.has_value ())
1882
1886
maxVote = voteCount;
1883
1887
else if (voteCount < *maxVote)
@@ -1888,8 +1892,9 @@ Consensus<Adaptor>::updateOurPositions(bool const share)
1888
1892
// the maximum number of votes.
1889
1893
NetClock::time_point const bestCloseTime = *maxCloseTimes.crbegin ();
1890
1894
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. " ;
1893
1898
1894
1899
// If we are a validator potentially at an impasse and our own close
1895
1900
// time is not the best, change our close time to match it and
@@ -1900,10 +1905,16 @@ Consensus<Adaptor>::updateOurPositions(bool const share)
1900
1905
consensusCloseTime = bestCloseTime;
1901
1906
++*maxVote;
1902
1907
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." ;
1907
1918
}
1908
1919
// If the close time with the most votes also meets or exceeds the
1909
1920
// threshold to change our position, then change our position.
@@ -1917,14 +1928,15 @@ Consensus<Adaptor>::updateOurPositions(bool const share)
1917
1928
if (*maxVote >= threshVote)
1918
1929
{
1919
1930
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." ;
1923
1935
if (*maxVote >= threshConsensus)
1924
1936
{
1925
1937
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." ;
1928
1940
}
1929
1941
}
1930
1942
0 commit comments