watchtower/wtwire/summary: adds message summaries
This commit is contained in:
parent
53a181ce49
commit
00db396b51
35
watchtower/wtwire/summary.go
Normal file
35
watchtower/wtwire/summary.go
Normal file
@ -0,0 +1,35 @@
|
||||
package wtwire
|
||||
|
||||
import "fmt"
|
||||
|
||||
// MessageSummary creates a human-readable description of a given Message. If
|
||||
// the type is unknown, an empty string is returned.
|
||||
func MessageSummary(msg Message) string {
|
||||
switch msg := msg.(type) {
|
||||
case *Init:
|
||||
return ""
|
||||
|
||||
case *CreateSession:
|
||||
return fmt.Sprintf("blob_type=%s, max_updates=%d "+
|
||||
"reward_rate=%d sweep_fee_rate=%d", msg.BlobType,
|
||||
msg.MaxUpdates, msg.RewardRate, msg.SweepFeeRate)
|
||||
|
||||
case *CreateSessionReply:
|
||||
return fmt.Sprintf("code=%d", msg.Code)
|
||||
|
||||
case *StateUpdate:
|
||||
return fmt.Sprintf("seqnum=%d last_applied=%d is_complete=%d "+
|
||||
"hint=%x", msg.SeqNum, msg.LastApplied, msg.IsComplete,
|
||||
msg.Hint)
|
||||
|
||||
case *StateUpdateReply:
|
||||
return fmt.Sprintf("code=%d last_applied=%d", msg.Code,
|
||||
msg.LastApplied)
|
||||
|
||||
case *Error:
|
||||
return fmt.Sprintf("code=%d", msg.Code)
|
||||
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user