MCPcopy Create free account
hub / github.com/DNAProject/DNA / NewNodeWeight

Function NewNodeWeight

p2pserver/block_sync.go:65–82  ·  view source on GitHub ↗

NewNodeWeight new a nodeweight

(id uint64)

Source from the content-addressed store, hash-verified

63
64//NewNodeWeight new a nodeweight
65func NewNodeWeight(id uint64) *NodeWeight {
66 s := make([]float32, 0, SYNC_NODE_RECORD_SPEED_CNT)
67 for i := 0; i < SYNC_NODE_RECORD_SPEED_CNT; i++ {
68 s = append(s, float32(SYNC_NODE_SPEED_INIT))
69 }
70 r := make([]int64, 0, SYNC_NODE_RECORD_TIME_CNT)
71 now := time.Now().UnixNano() / int64(time.Millisecond)
72 for i := 0; i < SYNC_NODE_RECORD_TIME_CNT; i++ {
73 r = append(r, now)
74 }
75 return &NodeWeight{
76 id: id,
77 speed: s,
78 timeoutCnt: 0,
79 errorRespCnt: 0,
80 reqTime: r,
81 }
82}
83
84//AddTimeoutCnt incre timeout count
85func (this *NodeWeight) AddTimeoutCnt() {

Callers 1

OnAddNodeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected