Skip to content

Commit

Permalink
add some log for reset
Browse files Browse the repository at this point in the history
  • Loading branch information
dylenfu committed May 11, 2020
1 parent 19de4fc commit c510207
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
16 changes: 15 additions & 1 deletion methods/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func setup(protocol p2p.Protocol) {
}

func reset() {
log4.Debug("[GC] end testing, stop server and clear instance...")
ns.Stop()
common.Reset()
ns = nil
Expand Down Expand Up @@ -117,6 +118,7 @@ func HandshakeTimeout() bool {
var params struct {
Remote string
BlockTime int
Retry int
}
if err := getParamsFromJsonFile("./params/HandshakeTimeout.json", &params); err != nil {
_ = log4.Error("%s", err)
Expand All @@ -130,7 +132,19 @@ func HandshakeTimeout() bool {
if err := ns.Connect(params.Remote); err != nil {
log4.Debug("connecting to %s failed, err: %s", params.Remote, err)
} else {
log4.Info("handshakeTimeout end!")
log4.Info("handshake success!")
return true
}

for i:=0; i< params.Retry; i++ {
log4.Debug("connecting retry cnt %d", i)
common.SetHandshakeTimeout(0)
if err := ns.Connect(params.Remote); err != nil {
log4.Debug("connecting to %s failed, err: %s", params.Remote, err)
} else {
log4.Info("handshake success!")
return true
}
}

return true
Expand Down
3 changes: 2 additions & 1 deletion params/HandshakeTimeout.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"Remote": "172.168.3.158:20338",
"BlockTime": 20
"BlockTime": 20,
"Retry": 10
}

0 comments on commit c510207

Please sign in to comment.