@@ -72,6 +72,10 @@ func (r *Resolver) ResolveToLastNode(ctx context.Context, fpath path.Path) (cid.
7272 // create a selector to traverse and match all path segments
7373 pathSelector := pathAllSelector (p [:len (p )- 1 ])
7474
75+ // create a new cancellable session
76+ ctx , cancel := context .WithTimeout (ctx , time .Minute )
77+ defer cancel ()
78+
7579 // resolve node before last path segment
7680 nodes , lastCid , depth , err := r .resolveNodes (ctx , c , pathSelector )
7781 if err != nil {
@@ -118,6 +122,9 @@ func (r *Resolver) ResolveToLastNode(ctx context.Context, fpath path.Path) (cid.
118122
119123// ResolvePath fetches the node for given path. It returns the last item
120124// returned by ResolvePathComponents and the last link traversed which can be used to recover the block.
125+ //
126+ // Note: if/when the context is cancelled or expires then if a multi-block ADL node is returned then it may not be
127+ // possible to load certain values.
121128func (r * Resolver ) ResolvePath (ctx context.Context , fpath path.Path ) (ipld.Node , ipld.Link , error ) {
122129 // validate path
123130 if err := fpath .IsValid (); err != nil {
@@ -152,6 +159,9 @@ func ResolveSingle(ctx context.Context, ds format.NodeGetter, nd format.Node, na
152159// ResolvePathComponents fetches the nodes for each segment of the given path.
153160// It uses the first path component as a hash (key) of the first node, then
154161// resolves all other components walking the links via a selector traversal
162+ //
163+ // Note: if/when the context is cancelled or expires then if a multi-block ADL node is returned then it may not be
164+ // possible to load certain values.
155165func (r * Resolver ) ResolvePathComponents (ctx context.Context , fpath path.Path ) ([]ipld.Node , error ) {
156166 //lint:ignore SA1019 TODO: replace EventBegin
157167 evt := log .EventBegin (ctx , "resolvePathComponents" , logging.LoggableMap {"fpath" : fpath })
@@ -187,6 +197,9 @@ func (r *Resolver) ResolvePathComponents(ctx context.Context, fpath path.Path) (
187197//
188198// ResolveLinks(nd, []string{"foo", "bar", "baz"})
189199// would retrieve "baz" in ("bar" in ("foo" in nd.Links).Links).Links
200+ //
201+ // Note: if/when the context is cancelled or expires then if a multi-block ADL node is returned then it may not be
202+ // possible to load certain values.
190203func (r * Resolver ) ResolveLinks (ctx context.Context , ndd ipld.Node , names []string ) ([]ipld.Node , error ) {
191204 //lint:ignore SA1019 TODO: replace EventBegin
192205 evt := log .EventBegin (ctx , "resolveLinks" , logging.LoggableMap {"names" : names })
@@ -195,10 +208,6 @@ func (r *Resolver) ResolveLinks(ctx context.Context, ndd ipld.Node, names []stri
195208 // create a selector to traverse and match all path segments
196209 pathSelector := pathAllSelector (names )
197210
198- // create a new cancellable session
199- ctx , cancel := context .WithTimeout (ctx , time .Minute )
200- defer cancel ()
201-
202211 session := r .FetcherFactory .NewSession (ctx )
203212
204213 // traverse selector
@@ -218,10 +227,6 @@ func (r *Resolver) ResolveLinks(ctx context.Context, ndd ipld.Node, names []stri
218227// Finds nodes matching the selector starting with a cid. Returns the matched nodes, the cid of the block containing
219228// the last node, and the depth of the last node within its block (root is depth 0).
220229func (r * Resolver ) resolveNodes (ctx context.Context , c cid.Cid , sel ipld.Node ) ([]ipld.Node , cid.Cid , int , error ) {
221- // create a new cancellable session
222- ctx , cancel := context .WithTimeout (ctx , time .Minute )
223- defer cancel ()
224-
225230 session := r .FetcherFactory .NewSession (ctx )
226231
227232 // traverse selector
0 commit comments