-
Notifications
You must be signed in to change notification settings - Fork 0
/
summary.go
36 lines (28 loc) · 891 Bytes
/
summary.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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_base=%d reward_rate=%d sweep_fee_rate=%d",
msg.BlobType, msg.MaxUpdates, msg.RewardBase,
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 ""
}
}