explain when a promise can be canceled in pbdagreader
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
Steven Allen committed
Jul 5, 2018 at 17:06 UTC
7fd34048abb5cfadae75e4162ea9f50848133d9f
1 file changed
+5
unixfs/io/pbdagreader.go
+5
@@ -110,6 +110,11 @@ func (dr *PBDagReader) precalcNextBuf(ctx context.Context) error {
110
// In this case, the context used to *preload* the node has been canceled.
111
// We need to retry the load with our context and we might as
112
// well preload some extra nodes while we're at it.
113
+ //
114
+ // Note: When using `Read`, this code will never execute as
115
+ // `Read` will use the global context. It only runs if the user
116
+ // explicitly reads with a custom context (e.g., by calling
117
+ // `CtxReadFull`).
118
dr.preload(ctx, dr.linkPosition)
119
nxt, err = dr.promises[dr.linkPosition].Get(ctx)
120
dr.promises[dr.linkPosition] = nil