Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed Oct 29, 2020
1 parent 9c15d17 commit 04f4207
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions node.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func newNode(nd internal.Node, allowEmpty, expectLeaf bool) (*node, error) {
if !expectLeaf {
return nil, errLeafUnexpected
}
for x := byte(0); x < internal.Width; x++ {
for x := 0; x < internal.Width; x++ {
if nd.Bmap[x/8]&(1<<(x%8)) > 0 {
if i >= len(nd.Values) {
return nil, fmt.Errorf("expected at least %d values, found %d", i+1, len(nd.Values))
Expand All @@ -55,7 +55,7 @@ func newNode(nd internal.Node, allowEmpty, expectLeaf bool) (*node, error) {
return nil, errLeafExpected
}

for x := byte(0); x < internal.Width; x++ {
for x := 0; x < internal.Width; x++ {
if nd.Bmap[x/8]&(1<<(x%8)) > 0 {
if i >= len(nd.Links) {
return nil, fmt.Errorf("expected at least %d links, found %d", i+1, len(nd.Links))
Expand Down Expand Up @@ -305,6 +305,9 @@ func (n *node) flush(ctx context.Context, bs cbor.IpldStore, height int) (*inter
continue
}
if ln.dirty {
if ln.cached == nil {
return nil, fmt.Errorf("expected dirty node to be cached")
}
subn, err := ln.cached.flush(ctx, bs, height-1)
if err != nil {
return nil, err
Expand Down

0 comments on commit 04f4207

Please sign in to comment.