From b7b9f11c0af2609b0f2cdc0ac09c3d5663ff54eb Mon Sep 17 00:00:00 2001 From: Sir Darkrengarius Date: Fri, 18 Oct 2019 22:45:40 +0300 Subject: [PATCH] Fix code according to the new changes in `router2` --- pkg/app2/appnet/skywire_networker.go | 9 +++++---- pkg/router/router.go | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/app2/appnet/skywire_networker.go b/pkg/app2/appnet/skywire_networker.go index 3ec363b774..c790d8ab4f 100644 --- a/pkg/app2/appnet/skywire_networker.go +++ b/pkg/app2/appnet/skywire_networker.go @@ -43,7 +43,8 @@ func (r *SkywireNetworker) DialContext(ctx context.Context, addr Addr) (net.Conn return nil, err } - rg, err := r.r.DialRoutes(ctx, addr.PubKey, routing.Port(localPort), addr.Port, router.DefaultDialOptions) + dialOpts := router.DefaultDialOptions() + rg, err := r.r.DialRoutes(ctx, addr.PubKey, routing.Port(localPort), addr.Port, &dialOpts) if err != nil { return nil, err } @@ -79,7 +80,7 @@ func (r *SkywireNetworker) ListenContext(ctx context.Context, addr Addr) (net.Li if atomic.CompareAndSwapInt32(&r.isServing, 0, 1) { go func() { - if err := r.serve(); err != nil { + if err := r.serve(ctx); err != nil { r.log.WithError(err).Error("error serving") } }() @@ -89,9 +90,9 @@ func (r *SkywireNetworker) ListenContext(ctx context.Context, addr Addr) (net.Li } // serve accepts and serves routes. -func (r *SkywireNetworker) serve() error { +func (r *SkywireNetworker) serve(ctx context.Context) error { for { - rg, err := r.r.AcceptRoutes() + rg, err := r.r.AcceptRoutes(ctx) if err != nil { return err } diff --git a/pkg/router/router.go b/pkg/router/router.go index 75b08a5a23..40d7460e8a 100644 --- a/pkg/router/router.go +++ b/pkg/router/router.go @@ -56,6 +56,7 @@ type DialOptions struct { MaxConsumeRts int } +// TODO(nkryuchkov): return pointer, make struct val unexported func DefaultDialOptions() DialOptions { return DialOptions{ MinForwardRts: 1,