pinner: change the interface to have async pin listing
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@e2fc7f2fd0237afad200d7b0eec8b7a60bdc6644
Michael Muré committed
Jun 2, 2023 at 16:49 UTC
0134124cdd62b2437b3888e9bd240a5a59de9962
2 files changed
+7
-1
core/coreiface/pin.go
+3
@@ -27,6 +27,9 @@ type PinStatus interface {
27
28
// BadNodes returns any bad (usually missing) nodes from the pin
29
BadNodes() []BadPinNode
30
+
31
+ // if not nil, an error happened. Everything else should be ignored.
32
+ Err() error
33
}
34
35
// BadPinNode is a node that has been marked as bad by Pin.Verify
core/coreiface/tests/pin.go
+4
-1
@@ -198,6 +198,9 @@ func (tp *TestSuite) TestPinRecursive(t *testing.T) {
198
}
199
n := 0
200
for r := range res {
201
+ if err := r.Err(); err != nil {
202
+ t.Error(err)
203
+ }
204
if !r.Ok() {
205
t.Error("expected pin to be ok")
206
}
@@ -208,7 +211,7 @@ func (tp *TestSuite) TestPinRecursive(t *testing.T) {
211
t.Errorf("unexpected verify result count: %d", n)
212
}
213
211
- //TODO: figure out a way to test verify without touching IpfsNode
214
+ // TODO: figure out a way to test verify without touching IpfsNode
215
/*
216
err = api.Block().Rm(ctx, p0, opt.Block.Force(true))
217
if err != nil {