Skip to content

Commit

Permalink
expose session construction to other callers
Browse files Browse the repository at this point in the history
  • Loading branch information
whyrusleeping authored and aschmahmann committed Oct 21, 2021
1 parent 9979f9a commit 7602f0e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion merkledag.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,14 @@ func (sg *sesGetter) GetMany(ctx context.Context, keys []cid.Cid) <-chan *format
return getNodesFromBG(ctx, sg.bs, keys)
}

// WrapSession wraps a blockservice session to satisfy the format.NodeGetter interface
func WrapSession(s *bserv.Session) format.NodeGetter {
return &sesGetter{s}
}

// Session returns a NodeGetter using a new session for block fetches.
func (n *dagService) Session(ctx context.Context) format.NodeGetter {
return &sesGetter{bserv.NewSession(ctx, n.Blocks)}
return WrapSession(bserv.NewSession(ctx, n.Blocks))
}

// FetchGraph fetches all nodes that are children of the given node
Expand Down

0 comments on commit 7602f0e

Please sign in to comment.