mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-24 03:47:45 +08:00
make NewSession in the blockservice be a function, not a method
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
This commit is contained in:
parent
579fd46488
commit
1ffb44cd46
@ -32,7 +32,6 @@ type BlockService interface {
|
||||
GetBlock(ctx context.Context, c *cid.Cid) (blocks.Block, error)
|
||||
GetBlocks(ctx context.Context, ks []*cid.Cid) <-chan blocks.Block
|
||||
DeleteBlock(o blocks.Block) error
|
||||
NewSession(context.Context) *Session
|
||||
Close() error
|
||||
}
|
||||
|
||||
@ -79,18 +78,18 @@ func (bs *blockService) Exchange() exchange.Interface {
|
||||
return bs.exchange
|
||||
}
|
||||
|
||||
func (bs *blockService) NewSession(ctx context.Context) *Session {
|
||||
bswap, ok := bs.Exchange().(*bitswap.Bitswap)
|
||||
if ok {
|
||||
func NewSession(ctx context.Context, bs BlockService) *Session {
|
||||
exchange := bs.Exchange()
|
||||
if bswap, ok := exchange.(*bitswap.Bitswap); ok {
|
||||
ses := bswap.NewSession(ctx)
|
||||
return &Session{
|
||||
ses: ses,
|
||||
bs: bs.blockstore,
|
||||
bs: bs.Blockstore(),
|
||||
}
|
||||
}
|
||||
return &Session{
|
||||
ses: bs.exchange,
|
||||
bs: bs.blockstore,
|
||||
ses: exchange,
|
||||
bs: bs.Blockstore(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -182,7 +182,7 @@ func FetchGraph(ctx context.Context, root *cid.Cid, serv DAGService) error {
|
||||
var ng node.NodeGetter = serv
|
||||
ds, ok := serv.(*dagService)
|
||||
if ok {
|
||||
ng = &sesGetter{ds.Blocks.NewSession(ctx)}
|
||||
ng = &sesGetter{bserv.NewSession(ctx, ds.Blocks)}
|
||||
}
|
||||
|
||||
v, _ := ctx.Value("progress").(*ProgressTracker)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user