1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-10 05:52:20 +08:00

Fix 'ctx, _' to have explicit cancel

License: MIT
Signed-off-by: rht <rhtbot@gmail.com>
This commit is contained in:
rht
2015-08-23 19:33:53 +07:00
parent 34e06f6c95
commit a7202fa94c
9 changed files with 37 additions and 23 deletions

View File

@ -60,7 +60,8 @@ func (p *ipnsPublisher) Publish(ctx context.Context, k ci.PrivKey, value path.Pa
log.Debugf("Storing pubkey at: %s", namekey)
// Store associated public key
timectx, _ := context.WithDeadline(ctx, time.Now().Add(time.Second*10))
timectx, cancel := context.WithDeadline(ctx, time.Now().Add(time.Second*10))
defer cancel()
err = p.routing.PutValue(timectx, namekey, pkbytes)
if err != nil {
return err
@ -70,9 +71,9 @@ func (p *ipnsPublisher) Publish(ctx context.Context, k ci.PrivKey, value path.Pa
log.Debugf("Storing ipns entry at: %s", ipnskey)
// Store ipns entry at "/ipns/"+b58(h(pubkey))
timectx, _ = context.WithDeadline(ctx, time.Now().Add(time.Second*10))
err = p.routing.PutValue(timectx, ipnskey, data)
if err != nil {
timectx, cancel = context.WithDeadline(ctx, time.Now().Add(time.Second*10))
defer cancel()
if err := p.routing.PutValue(timectx, ipnskey, data); err != nil {
return err
}