Commit b7b352fe authored by Kevin Atkinson's avatar Kevin Atkinson

Make BlockService an interface.

License: MIT
Signed-off-by: default avatarKevin Atkinson <k@kevina.org>
parent dbebd417
......@@ -41,7 +41,7 @@ type LinkService interface {
GetOfflineLinkService() LinkService
}
func NewDAGService(bs *bserv.BlockService) *dagService {
func NewDAGService(bs bserv.BlockService) *dagService {
return &dagService{Blocks: bs}
}
......@@ -51,7 +51,7 @@ func NewDAGService(bs *bserv.BlockService) *dagService {
// TODO: should cache Nodes that are in memory, and be
// able to free some of them when vm pressure is high
type dagService struct {
Blocks *bserv.BlockService
Blocks bserv.BlockService
}
// Add adds a node to the dagService, storing the block in the BlockService
......@@ -113,8 +113,8 @@ func (n *dagService) GetLinks(ctx context.Context, c *cid.Cid) ([]*Link, error)
}
func (n *dagService) GetOfflineLinkService() LinkService {
if n.Blocks.Exchange.IsOnline() {
bsrv := bserv.New(n.Blocks.Blockstore, offline.Exchange(n.Blocks.Blockstore))
if n.Blocks.Exchange().IsOnline() {
bsrv := bserv.New(n.Blocks.Blockstore(), offline.Exchange(n.Blocks.Blockstore()))
return NewDAGService(bsrv)
} else {
return n
......
......@@ -237,7 +237,7 @@ func TestFetchGraph(t *testing.T) {
}
// create an offline dagstore and ensure all blocks were fetched
bs := bserv.New(bsis[1].Blockstore, offline.Exchange(bsis[1].Blockstore))
bs := bserv.New(bsis[1].Blockstore(), offline.Exchange(bsis[1].Blockstore()))
offline_ds := NewDAGService(bs)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment