Skip to content

Commit

Permalink
Fix code according to the new changes in router2
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkren committed Oct 18, 2019
1 parent fc14d32 commit b7b9f11
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/app2/appnet/skywire_networker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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")
}
}()
Expand All @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions pkg/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type DialOptions struct {
MaxConsumeRts int
}

// TODO(nkryuchkov): return pointer, make struct val unexported
func DefaultDialOptions() DialOptions {
return DialOptions{
MinForwardRts: 1,
Expand Down

0 comments on commit b7b9f11

Please sign in to comment.