Skip to content

Commit

Permalink
⚙️ be consistent and consume context while opening stream
Browse files Browse the repository at this point in the history
  • Loading branch information
mudler committed Feb 2, 2022
1 parent d293fa3 commit 516904f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/services/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func ReceiveFile(ctx context.Context, ledger *blockchain.Ledger, n *node.Node, l
}

// Open a stream
stream, err := n.Host().NewStream(context.Background(), d, protocol.FileProtocol.ID())
stream, err := n.Host().NewStream(ctx, d, protocol.FileProtocol.ID())
if err != nil {
l.Debugf("failed to dial %s, retrying in 5 seconds", d)
continue
Expand Down
2 changes: 1 addition & 1 deletion pkg/services/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ func ConnectToService(ctx context.Context, ledger *blockchain.Ledger, node *node
go copyStream(closer, conn, stream)
<-closer

conn.Close()
stream.Close()
conn.Close()
ll.Infof("(service %s) Done handling %s", serviceID, l.Addr().String())
}()
}
Expand Down

0 comments on commit 516904f

Please sign in to comment.