Skip to content

Commit

Permalink
Fix wrongCid bug and log errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Wondertan committed Aug 7, 2020
1 parent bbac61e commit 8607000
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
15 changes: 10 additions & 5 deletions reedsolomon/recover.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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) {
Expand Down Expand Up @@ -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"))
3 changes: 3 additions & 0 deletions reedsolomon/reedsolomon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit 8607000

Please sign in to comment.