Commit 3cc73ee4 authored by Overbool's avatar Overbool Committed by Lucas Molas

fix(hamt): add error in makeShardValue

parent 9e75a2ec
...@@ -190,14 +190,17 @@ func (ds *Shard) Node() (ipld.Node, error) { ...@@ -190,14 +190,17 @@ func (ds *Shard) Node() (ipld.Node, error) {
return out, nil return out, nil
} }
func (ds *Shard) makeShardValue(lnk *ipld.Link) *Shard { func (ds *Shard) makeShardValue(lnk *ipld.Link) (*Shard, error) {
lnk2 := *lnk lnk2 := *lnk
s, _ := makeShard(ds.dserv, ds.tableSize) s, err := makeShard(ds.dserv, ds.tableSize)
if err != nil {
return nil, err
}
s.key = lnk.Name[ds.maxpadlen:] s.key = lnk.Name[ds.maxpadlen:]
s.val = &lnk2 s.val = &lnk2
return s return s, nil
} }
func hash(val []byte) []byte { func hash(val []byte) []byte {
...@@ -305,7 +308,11 @@ func (ds *Shard) loadChild(ctx context.Context, i int) (*Shard, error) { ...@@ -305,7 +308,11 @@ func (ds *Shard) loadChild(ctx context.Context, i int) (*Shard, error) {
c = cds c = cds
} else { } else {
c = ds.makeShardValue(lnk) s, err := ds.makeShardValue(lnk)
if err != nil {
return nil, err
}
c = s
} }
ds.children[i] = c ds.children[i] = c
...@@ -447,8 +454,11 @@ func makeAsyncTrieGetLinks(dagService ipld.DAGService, onShardValue func(shard * ...@@ -447,8 +454,11 @@ func makeAsyncTrieGetLinks(dagService ipld.DAGService, onShardValue func(shard *
if lnkLinkType == shardLink { if lnkLinkType == shardLink {
childShards = append(childShards, lnk) childShards = append(childShards, lnk)
} else { } else {
sv := directoryShard.makeShardValue(lnk) sv, err := directoryShard.makeShardValue(lnk)
err := onShardValue(sv) if err != nil {
return nil, err
}
err = onShardValue(sv)
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment