Fix potential nil pointer (#3220)

pull/3226/head
Rongjian Lan 4 years ago committed by GitHub
parent 0435e2d203
commit c3cad1be6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      consensus/fbft_log.go

@ -41,14 +41,22 @@ type FBFTMessage struct {
// String ..
func (m *FBFTMessage) String() string {
sender := ""
if m.SenderPubkey != nil {
sender = m.SenderPubkey.Bytes.Hex()
}
leader := ""
if m.LeaderPubkey != nil {
leader = m.LeaderPubkey.Bytes.Hex()
}
return fmt.Sprintf(
"[Type:%s ViewID:%d Num:%d BlockHash:%s Sender:%s Leader:%s]",
m.MessageType.String(),
m.ViewID,
m.BlockNum,
m.BlockHash.Hex(),
m.SenderPubkey.Bytes.Hex(),
m.LeaderPubkey.Bytes.Hex(),
sender,
leader,
)
}

Loading…
Cancel
Save