Skip to content

Commit

Permalink
pinner: change the interface to have async pin listing
Browse files Browse the repository at this point in the history
The rational is that if the pin list get big, a synchronous call to get the complete list can delay handling unnecessarily. For example, when listing indirect pins, you can start walking the DAGs immediately with the first recursive pin instead of waiting for the full list.

This matters even more on low power device, of if the pin list is stored remotely.

* coreiface: allow to return an error not linked to a specific Cid
* merkledag/test: add a DAG generator

Rationale is that generating a test DAG is quite difficult, and anything that helps writing better tests is helpful.

This commit was moved from ipfs/boxo@e2fc7f2
  • Loading branch information
MichaelMure committed Jun 2, 2023
1 parent 18143e2 commit 0134124
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions core/coreiface/pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ type PinStatus interface {

// BadNodes returns any bad (usually missing) nodes from the pin
BadNodes() []BadPinNode

// if not nil, an error happened. Everything else should be ignored.
Err() error
}

// BadPinNode is a node that has been marked as bad by Pin.Verify
Expand Down
5 changes: 4 additions & 1 deletion core/coreiface/tests/pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ func (tp *TestSuite) TestPinRecursive(t *testing.T) {
}
n := 0
for r := range res {
if err := r.Err(); err != nil {
t.Error(err)
}
if !r.Ok() {
t.Error("expected pin to be ok")
}
Expand All @@ -208,7 +211,7 @@ func (tp *TestSuite) TestPinRecursive(t *testing.T) {
t.Errorf("unexpected verify result count: %d", n)
}

//TODO: figure out a way to test verify without touching IpfsNode
// TODO: figure out a way to test verify without touching IpfsNode
/*
err = api.Block().Rm(ctx, p0, opt.Block.Force(true))
if err != nil {
Expand Down

0 comments on commit 0134124

Please sign in to comment.