-
Notifications
You must be signed in to change notification settings - Fork 134
/
result.go
39 lines (30 loc) · 942 Bytes
/
result.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
37
38
39
package add
import (
"bytes"
"fmt"
"github.com/ExzoNetwork/ExzoCoin/command/helper"
)
type PeersAddResult struct {
NumRequested int `json:"num_requested"`
NumAdded int `json:"num_added"`
Peers []string `json:"peers"`
Errors []string `json:"errors"`
}
func (r *PeersAddResult) GetOutput() string {
var buffer bytes.Buffer
buffer.WriteString("\n[PEERS ADDED]\n")
buffer.WriteString(helper.FormatKV([]string{
fmt.Sprintf("Peers listed|%d", r.NumRequested), // The number of peers the user wanted to add
fmt.Sprintf("Peers added|%d", r.NumAdded), // The number of peers that have been added
}))
if len(r.Peers) > 0 {
buffer.WriteString("\n\n[LIST OF ADDED PEERS]\n")
buffer.WriteString(helper.FormatList(r.Peers))
}
if len(r.Errors) > 0 {
buffer.WriteString("\n\n[ERRORS]\n")
buffer.WriteString(helper.FormatList(r.Errors))
}
buffer.WriteString("\n")
return buffer.String()
}