Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit 444e5b8

Browse files
committed
docs
1 parent 54c2a79 commit 444e5b8

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

hamt/util.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,17 @@ func CreateFullShard(ds ipld.DAGService, treeHeight int) (rootNode ipld.Node, er
126126
for i := 0; i < totalChildren; i++ {
127127
var hashbuf [8]byte
128128
binary.LittleEndian.PutUint64(hashbuf[:], uint64(i))
129-
_, err = root.SetAndPrevious(context.Background(), string(hashbuf[:treeHeight]), unixfs.EmptyFileNode())
129+
var previous *ipld.Link
130+
previous, err = root.SetAndPrevious(context.Background(), string(hashbuf[:treeHeight]), unixfs.EmptyFileNode())
130131
if err != nil {
131132
return
132133
}
134+
if previous != nil {
135+
// We shouldn't be overwriting any value, otherwise the tree
136+
// won't be full.
137+
return nil, fmt.Errorf("we have overwritten entry %s",
138+
previous.Cid)
139+
}
133140
}
134141

135142
rootNode, err = root.Node()

io/directory_test.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ func TestHAMTEnumerationWhenComputingSize(t *testing.T) {
264264
//oldShardWidth := DefaultShardWidth
265265
//defer func() { DefaultShardWidth = oldShardWidth }()
266266
//DefaultShardWidth = 8
267+
// FIXME: We should be able to use a smaller DefaultShardWidth to have
268+
// a deeper tree and cheaper tests once the import cycle is resolved
269+
// in hamt.CreateFullShard.
267270

268271
treeHeight := 2
269272
thresholdToWidthRatio := 4
@@ -285,9 +288,7 @@ func TestHAMTEnumerationWhenComputingSize(t *testing.T) {
285288
assert.NoError(t, err)
286289

287290
sequentialDagService.ResetCounter()
288-
// FIXME: Revert to const timeout after debugging.
289-
below, timeoutExceeded := hamtDir.sizeBelowThreshold(1, func(ctx context.Context, _ *ipld.Link) {
290-
})
291+
below, timeoutExceeded := hamtDir.sizeBelowThreshold(EvaluateHAMTTransitionTimeout, nil)
291292
assert.False(t, below)
292293
assert.False(t, timeoutExceeded)
293294
assert.Equal(t, nodesToFetch, sequentialDagService.UniqueCidsFetched())
@@ -433,10 +434,14 @@ func TestDirBuilder(t *testing.T) {
433434
}
434435

435436
// serialFetchDag is a DAG service that keeps track of requested nodes
436-
// and serves them in FIFO order to keep tight control on requests.
437+
// and serves them in FIFO order to keep tight control on requests. (We
438+
// don't use GetMany.)
439+
// FIXME: We still depend on the walk function to be sequential. The name
440+
// here might be misleading.
437441
type serialFetchDag struct {
438442
ipld.DAGService
439443

444+
// FIXME: Remove if we won't be using it for now.
440445
nextNode <-chan struct{}
441446
cidsFetched map[cid.Cid]struct{}
442447
mapLock sync.Mutex

0 commit comments

Comments
 (0)