1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-08-01 08:15:43 +08:00

Simplify Pinner interface by folding ManualPinner into Pinner

Pinner had method GetManual that returned a ManualPinner, so every
Pinner had to implement ManualPinner anyway.

License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
This commit is contained in:
Tommi Virtanen
2015-05-08 11:00:55 -07:00
committed by Jeromy
parent c4d2988c11
commit c9ce2e724a
12 changed files with 38 additions and 45 deletions

View File

@ -27,25 +27,25 @@ import (
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
)
func getMockDagServ(t testing.TB) (mdag.DAGService, pin.ManualPinner) {
func getMockDagServ(t testing.TB) (mdag.DAGService, pin.Pinner) {
dstore := ds.NewMapDatastore()
tsds := sync.MutexWrap(dstore)
bstore := blockstore.NewBlockstore(tsds)
bserv := bs.New(bstore, offline.Exchange(bstore))
dserv := mdag.NewDAGService(bserv)
return dserv, pin.NewPinner(tsds, dserv).GetManual()
return dserv, pin.NewPinner(tsds, dserv)
}
func getMockDagServAndBstore(t testing.TB) (mdag.DAGService, blockstore.Blockstore, pin.ManualPinner) {
func getMockDagServAndBstore(t testing.TB) (mdag.DAGService, blockstore.Blockstore, pin.Pinner) {
dstore := ds.NewMapDatastore()
tsds := sync.MutexWrap(dstore)
bstore := blockstore.NewBlockstore(tsds)
bserv := bs.New(bstore, offline.Exchange(bstore))
dserv := mdag.NewDAGService(bserv)
return dserv, bstore, pin.NewPinner(tsds, dserv).GetManual()
return dserv, bstore, pin.NewPinner(tsds, dserv)
}
func getNode(t testing.TB, dserv mdag.DAGService, size int64, pinner pin.ManualPinner) ([]byte, *mdag.Node) {
func getNode(t testing.TB, dserv mdag.DAGService, size int64, pinner pin.Pinner) ([]byte, *mdag.Node) {
in := io.LimitReader(u.NewTimeSeededRand(), size)
node, err := imp.BuildTrickleDagFromReader(dserv, sizeSplitterGen(500)(in), imp.BasicPinnerCB(pinner))
if err != nil {
@ -469,7 +469,7 @@ func TestSparseWrite(t *testing.T) {
}
}
func basicGC(t *testing.T, bs blockstore.Blockstore, pins pin.ManualPinner) {
func basicGC(t *testing.T, bs blockstore.Blockstore, pins pin.Pinner) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel() // in case error occurs during operation
keychan, err := bs.AllKeysChan(ctx)