diff --git a/reedsolomon/recover.go b/reedsolomon/recover.go index d1fe8cf..c411402 100644 --- a/reedsolomon/recover.go +++ b/reedsolomon/recover.go @@ -45,8 +45,6 @@ outer: for i, ndp := range format.GetNodes(ctx, dag, ids) { nd, err := ndp.Get(ctx) switch err { - case context.DeadlineExceeded, context.Canceled: - return nil, err case nil: bs[i] = make([]byte, s) if i < lpnd { @@ -55,11 +53,18 @@ outer: } else { copy(bs[i], nd.RawData()) } + nlst = append(nlst, i) + continue + case context.DeadlineExceeded, context.Canceled: + return nil, err + case format.ErrNotFound: default: - bs[i] = make([]byte, s) - lst = append(lst, i) + log.Errorf("Failed to get child Node(%s) for recovery: %s", ids[i].String(), err) } + + bs[i] = make([]byte, s) + lst = append(lst, i) } if lrpnd < len(lst) { @@ -117,6 +122,6 @@ outer: var wrongCid, _ = cid.Prefix{ Version: 1, Codec: 1, - MhType: multihash.IDENTITY, + MhType: multihash.SHA2_256, MhLength: 1, }.Sum([]byte("f")) diff --git a/reedsolomon/reedsolomon.go b/reedsolomon/reedsolomon.go index c11c8bc..08098df 100644 --- a/reedsolomon/reedsolomon.go +++ b/reedsolomon/reedsolomon.go @@ -6,10 +6,13 @@ import ( "github.com/ipfs/go-cid" "github.com/ipfs/go-ipld-format" + logging "github.com/ipfs/go-log/v2" "github.com/Wondertan/go-ipfs-recovery" ) +var log = logging.Logger("recovery") + // Custom codec for Reed-Solomon recovery Nodes. const Codec uint64 = 0x700 // random number // TODO Register in IPFS codec table.