@ -442,12 +442,14 @@ func (voteSet *VoteSet) TwoThirdsMajority() (blockID BlockID, ok bool) {
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
// Strings and JSON
// Strings and JSON
const nilVoteSetString = "nil-VoteSet"
// String returns a string representation of VoteSet.
// String returns a string representation of VoteSet.
//
//
// See StringIndented.
// See StringIndented.
func ( voteSet * VoteSet ) String ( ) string {
func ( voteSet * VoteSet ) String ( ) string {
if voteSet == nil {
if voteSet == nil {
return "nil-VoteSet"
return nilVoteSetString
}
}
return voteSet . StringIndented ( "" )
return voteSet . StringIndented ( "" )
}
}
@ -551,7 +553,7 @@ func (voteSet *VoteSet) voteStrings() []string {
// 7. 2/3+ majority for each peer
// 7. 2/3+ majority for each peer
func ( voteSet * VoteSet ) StringShort ( ) string {
func ( voteSet * VoteSet ) StringShort ( ) string {
if voteSet == nil {
if voteSet == nil {
return "nil-VoteSet"
return nilVoteSetString
}
}
voteSet . mtx . Lock ( )
voteSet . mtx . Lock ( )
defer voteSet . mtx . Unlock ( )
defer voteSet . mtx . Unlock ( )
@ -560,6 +562,19 @@ func (voteSet *VoteSet) StringShort() string {
voteSet . height , voteSet . round , voteSet . signedMsgType , voteSet . maj23 , frac , voteSet . votesBitArray , voteSet . peerMaj23s )
voteSet . height , voteSet . round , voteSet . signedMsgType , voteSet . maj23 , frac , voteSet . votesBitArray , voteSet . peerMaj23s )
}
}
// LogString produces a logging suitable string representation of the
// vote set.
func ( voteSet * VoteSet ) LogString ( ) string {
if voteSet == nil {
return nilVoteSetString
}
voteSet . mtx . Lock ( )
defer voteSet . mtx . Unlock ( )
voted , total , frac := voteSet . sumTotalFrac ( )
return fmt . Sprintf ( "Votes:%d/%d(%.3f)" , voted , total , frac )
}
// return the power voted, the total, and the fraction
// return the power voted, the total, and the fraction
func ( voteSet * VoteSet ) sumTotalFrac ( ) ( int64 , int64 , float64 ) {
func ( voteSet * VoteSet ) sumTotalFrac ( ) ( int64 , int64 , float64 ) {
voted , total := voteSet . sum , voteSet . valSet . TotalVotingPower ( )
voted , total := voteSet . sum , voteSet . valSet . TotalVotingPower ( )