github.com/decred/dcrlnd@v0.7.6/watchtower/wtwire/summary.go (about) 1 package wtwire 2 3 import "fmt" 4 5 // MessageSummary creates a human-readable description of a given Message. If 6 // the type is unknown, an empty string is returned. 7 func MessageSummary(msg Message) string { 8 switch msg := msg.(type) { 9 case *Init: 10 return "" 11 12 case *CreateSession: 13 return fmt.Sprintf("blob_type=%s, max_updates=%d "+ 14 "reward_base=%d reward_rate=%d sweep_fee_rate=%d", 15 msg.BlobType, msg.MaxUpdates, msg.RewardBase, 16 msg.RewardRate, msg.SweepFeeRate) 17 18 case *CreateSessionReply: 19 return fmt.Sprintf("code=%d", msg.Code) 20 21 case *StateUpdate: 22 return fmt.Sprintf("seqnum=%d last_applied=%d is_complete=%d "+ 23 "hint=%x", msg.SeqNum, msg.LastApplied, msg.IsComplete, 24 msg.Hint) 25 26 case *StateUpdateReply: 27 return fmt.Sprintf("code=%d last_applied=%d", msg.Code, 28 msg.LastApplied) 29 30 case *Error: 31 return fmt.Sprintf("code=%d", msg.Code) 32 33 default: 34 return "" 35 } 36 }