Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
Merge pull request #26 from ipfs/feat/fetcher-from-session
Browse files Browse the repository at this point in the history
add a fetcher constructor for the case where we already have a session
  • Loading branch information
whyrusleeping authored Oct 21, 2021
2 parents 8349e49 + 99235cc commit 204874a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion impl/blockservice/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@ func NewFetcherConfig(blockService blockservice.BlockService) FetcherConfig {
// NewSession creates a session from which nodes may be retrieved.
// The session ends when the provided context is canceled.
func (fc FetcherConfig) NewSession(ctx context.Context) fetcher.Fetcher {
return fc.FetcherWithSession(ctx, blockservice.NewSession(ctx, fc.blockService))
}

func (fc FetcherConfig) FetcherWithSession(ctx context.Context, s *blockservice.Session) fetcher.Fetcher {
ls := cidlink.DefaultLinkSystem()
// while we may be loading blocks remotely, they are already hash verified by the time they load
// into ipld-prime
ls.TrustedStorage = true
ls.StorageReadOpener = blockOpener(ctx, blockservice.NewSession(ctx, fc.blockService))
ls.StorageReadOpener = blockOpener(ctx, s)
ls.NodeReifier = fc.NodeReifier

protoChooser := fc.PrototypeChooser
Expand Down

0 comments on commit 204874a

Please sign in to comment.