mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-09 23:42:20 +08:00
Make sure ctx in commands are derived from req.Context
License: MIT Signed-off-by: rht <rhtbot@gmail.com>
This commit is contained in:
@ -320,7 +320,7 @@ func setupDiscoveryOption(d config.Discovery) DiscoveryOption {
|
||||
|
||||
func (n *IpfsNode) HandlePeerFound(p peer.PeerInfo) {
|
||||
log.Warning("trying peer info: ", p)
|
||||
ctx, _ := context.WithTimeout(context.TODO(), time.Second*10)
|
||||
ctx, _ := context.WithTimeout(n.Context(), time.Second*10)
|
||||
err := n.PeerHost.Connect(ctx, p)
|
||||
if err != nil {
|
||||
log.Warning("Failed to connect to peer found by discovery: ", err)
|
||||
@ -367,6 +367,9 @@ func (n *IpfsNode) Close() error {
|
||||
|
||||
// Context returns the IpfsNode context
|
||||
func (n *IpfsNode) Context() context.Context {
|
||||
if n.ctx == nil {
|
||||
n.ctx = context.TODO()
|
||||
}
|
||||
return n.ctx
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user