Skip to content

Commit

Permalink
Add debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
nkryuchkov committed May 7, 2020
1 parent e32bb76 commit a78db95
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 19 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/google/uuid v1.1.1
github.com/gorilla/securecookie v1.1.1
github.com/libp2p/go-reuseport v0.0.1
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/mholt/archiver/v3 v3.3.0
github.com/pion/ice v0.7.12 // indirect
github.com/pion/turn v1.4.0 // indirect
Expand All @@ -27,4 +28,4 @@ require (
)

// Uncomment for tests with alternate branches of 'dmsg'
//replace github.com/SkycoinProject/dmsg => ../dmsg
replace github.com/SkycoinProject/dmsg => ../dmsg
11 changes: 10 additions & 1 deletion pkg/transport/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,13 @@ func (tm *Manager) SaveTransport(ctx context.Context, remote cipher.PubKey, tpTy
for i := 0; i < tries; i++ {
mTp, err := tm.saveTransport(remote, tpType)
if err != nil {
return nil, err
return nil, fmt.Errorf("save transport: %w", err)
}

tm.Logger.Debugf("Dialing transport to %v via %v", mTp.Remote(), mTp.netName)

if err = mTp.Dial(ctx); err != nil {
tm.Logger.Debugf("Error dialing transport to %v via %v: %w", mTp.Remote(), mTp.netName, err)
// TODO(nkryuchkov): Check for an error that underlying connection is not established
// and try again in this case. Otherwise, return the error.
pkTableErr := fmt.Sprintf("pk table: entry of %s does not exist", remote.String())
Expand All @@ -235,6 +238,8 @@ func (tm *Manager) SaveTransport(ctx context.Context, remote cipher.PubKey, tpTy
}

if err == ErrNotServing {
tm.Logger.Warn("Transport is no longer served")

mTp.wg.Wait()
delete(tm.tps, mTp.Entry.ID)
continue
Expand All @@ -243,7 +248,11 @@ func (tm *Manager) SaveTransport(ctx context.Context, remote cipher.PubKey, tpTy
tm.Logger.
WithError(err).
Warn("Underlying connection is not yet established. Will retry later.")

continue
}
tm.Logger.Debugf("Returning transport to %v via %v", mTp.Remote(), mTp.netName)

return mTp, nil
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/visor/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,15 @@ func (r *RPC) AddTransport(in *AddTransportIn, out *TransportSummary) (err error
defer cancel()
}

r.log.Debugf("Saving transport to %v via %v", in.RemotePK, in.TpType)

tp, err := r.visor.tm.SaveTransport(ctx, in.RemotePK, in.TpType)
if err != nil {
return err
}

r.log.Debugf("Saved transport to %v via %v", in.RemotePK, in.TpType)

*out = *newTransportSummary(r.visor.tm, tp, false, r.visor.router.SetupIsTrusted(tp.Remote()))
return nil
}
Expand Down
3 changes: 3 additions & 0 deletions vendor/github.com/SkycoinProject/dmsg/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 28 additions & 9 deletions vendor/github.com/SkycoinProject/dmsg/Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 32 additions & 7 deletions vendor/github.com/SkycoinProject/dmsg/client_session.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# github.com/SkycoinProject/dmsg v0.1.0
# github.com/SkycoinProject/dmsg v0.1.0 => ../dmsg
github.com/SkycoinProject/dmsg
github.com/SkycoinProject/dmsg/cipher
github.com/SkycoinProject/dmsg/disc
Expand Down

0 comments on commit a78db95

Please sign in to comment.