-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.go
More file actions
51 lines (43 loc) · 1.08 KB
/
debug.go
File metadata and controls
51 lines (43 loc) · 1.08 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
package tcpgossip
import (
"fmt"
"github.com/NBSChain/go-nbs/utils"
)
func (e *viewEntity) String() string {
format := utils.GetConfig().SysTimeFormat
e.RLock()
defer e.RUnlock()
return fmt.Sprintf("------------%s------------\n"+
"|%-15s:%20.2f|\n"+
"|%-15s:%20s|\n"+
"|%-15s:%20s|\n"+
"|%-15s:%20s|\n"+
"-----------------------------------------------------------------------\n",
e.nodeID,
"probability",
e.probability,
"peerIP",
e.peerIP,
"heartBeatTime",
e.heartBeatTime.Format(format),
"expiredTime",
e.expiredTime.Format(format),
)
}
func (node *GspCtrlNode) ShowViews() {
fmt.Println("------------out view------------")
node.outView.RLock()
for _, item := range node.outView.AllViews() {
fmt.Println(item.String())
}
node.outView.RUnlock()
fmt.Println("------------in view------------")
node.inView.RLock()
for _, item := range node.inView.AllViews() {
fmt.Println(item.String())
}
node.inView.RUnlock()
}
func (e *viewEntity) KeyString() string {
return fmt.Sprintf("\nnodeId(%s)--->ip(%s)--->prob(%f)\n", e.nodeID, e.peerIP, e.probability)
}