kubo/merkledag/session.go
Jeromy a703e2d1f2 comments
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
2018-02-03 14:45:11 -08:00

22 lines
520 B
Go

package merkledag
import (
"context"
ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
)
// SessionMaker is an object that can generate a new fetching session.
type SessionMaker interface {
Session(context.Context) ipld.NodeGetter
}
// NewSession returns a session backed NodeGetter if the given NodeGetter
// implements SessionMaker.
func NewSession(ctx context.Context, g ipld.NodeGetter) ipld.NodeGetter {
if sm, ok := g.(SessionMaker); ok {
return sm.Session(ctx)
}
return g
}