mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-03 19:53:58 +00:00
logging: shorten precommit log message (#6270)
This is an attempt to clean up the logging message as requested in #6269.
This commit is contained in:
@@ -2128,7 +2128,12 @@ func (cs *State) addVote(vote *types.Vote, peerID p2p.NodeID) (added bool, err e
|
||||
|
||||
case tmproto.PrecommitType:
|
||||
precommits := cs.Votes.Precommits(vote.Round)
|
||||
cs.Logger.Debug("added vote to precommit", "vote", vote, "precommits", precommits.StringShort())
|
||||
cs.Logger.Debug("added vote to precommit",
|
||||
"height", vote.Height,
|
||||
"round", vote.Round,
|
||||
"validator", vote.ValidatorAddress.String(),
|
||||
"vote_timestamp", vote.Timestamp,
|
||||
"data", precommits.LogString())
|
||||
|
||||
blockID, ok := precommits.TwoThirdsMajority()
|
||||
if ok {
|
||||
|
||||
@@ -1189,7 +1189,7 @@ func (blockID BlockID) Key() string {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return string(blockID.Hash) + string(bz)
|
||||
return fmt.Sprint(string(blockID.Hash), string(bz))
|
||||
}
|
||||
|
||||
// ValidateBasic performs basic validation.
|
||||
|
||||
@@ -442,12 +442,14 @@ func (voteSet *VoteSet) TwoThirdsMajority() (blockID BlockID, ok bool) {
|
||||
//--------------------------------------------------------------------------------
|
||||
// Strings and JSON
|
||||
|
||||
const nilVoteSetString = "nil-VoteSet"
|
||||
|
||||
// String returns a string representation of VoteSet.
|
||||
//
|
||||
// See StringIndented.
|
||||
func (voteSet *VoteSet) String() string {
|
||||
if voteSet == nil {
|
||||
return "nil-VoteSet"
|
||||
return nilVoteSetString
|
||||
}
|
||||
return voteSet.StringIndented("")
|
||||
}
|
||||
@@ -551,7 +553,7 @@ func (voteSet *VoteSet) voteStrings() []string {
|
||||
// 7. 2/3+ majority for each peer
|
||||
func (voteSet *VoteSet) StringShort() string {
|
||||
if voteSet == nil {
|
||||
return "nil-VoteSet"
|
||||
return nilVoteSetString
|
||||
}
|
||||
voteSet.mtx.Lock()
|
||||
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)
|
||||
}
|
||||
|
||||
// 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
|
||||
func (voteSet *VoteSet) sumTotalFrac() (int64, int64, float64) {
|
||||
voted, total := voteSet.sum, voteSet.valSet.TotalVotingPower()
|
||||
|
||||
Reference in New Issue
Block a user