Skip to content

Commit

Permalink
modify log
Browse files Browse the repository at this point in the history
  • Loading branch information
dylenfu committed May 11, 2020
1 parent 271d18a commit 19de4fc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions p2pserver/protocols/heatbeat/heartbeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func (self *HeartBeat) Start() {
func (self *HeartBeat) Stop() {
close(self.quit)
}

func (this *HeartBeat) heartBeatService() {
var periodTime uint = config.DEFAULT_GEN_BLOCK_TIME / common.UPDATE_RATE_PER_BLOCK
t := time.NewTicker(time.Second * (time.Duration(periodTime)))
Expand All @@ -78,10 +79,10 @@ func (this *HeartBeat) ping() {
return
}

height := atomic.AddUint64(&this.height, 1)
height := this.height
ping := msgpack.NewPingMsg(uint64(height))
go this.net.Broadcast(ping)
log4.Debug("[p2p]ping msg height %d", height)
log4.Debug("[p2p]send ping msg height %d", height)
}

//timeout trace whether some peer be long time no response
Expand Down Expand Up @@ -117,12 +118,14 @@ func (this *HeartBeat) PingHandle(ctx *p2p.Context, ping *types.Ping) {
if err != nil {
log4.Warn(err)
}
log4.Debug("[p2p]pong msg height %d", height)
log4.Debug("[p2p]recv pong msg height %d", height)
}

func (this *HeartBeat) PongHandle(ctx *p2p.Context, pong *types.Pong) {
remotePeer := ctx.Network()
remotePeer.SetHeight(pong.Height)
// mark:
atomic.AddUint64(&this.height, 1)
}

func (this *HeartBeat) NeedInterrupt(iscli bool) bool {
Expand Down
2 changes: 1 addition & 1 deletion params/HandshakeTimeout.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"Remote": "172.168.3.158:20338",
"BlockTime": 10
"BlockTime": 20
}

0 comments on commit 19de4fc

Please sign in to comment.