badger/AllKeysChan(): respect context.
This commit is contained in:
parent
6f593d53d0
commit
04a866121e
@ -359,7 +359,11 @@ func (b *Blockstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error) {
|
|||||||
buf = make([]byte, reqlen)
|
buf = make([]byte, reqlen)
|
||||||
}
|
}
|
||||||
if n, err := base32.RawStdEncoding.Decode(buf, k); err == nil {
|
if n, err := base32.RawStdEncoding.Decode(buf, k); err == nil {
|
||||||
ch <- cid.NewCidV1(cid.Raw, buf[:n])
|
select {
|
||||||
|
case ch <- cid.NewCidV1(cid.Raw, buf[:n]):
|
||||||
|
case <-ctx.Done():
|
||||||
|
return
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Warnf("failed to decode key %s in badger AllKeysChan; err: %s", k, err)
|
log.Warnf("failed to decode key %s in badger AllKeysChan; err: %s", k, err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user