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

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
schomatis committed Jun 29, 2021
1 parent 790373d commit 445e541
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
9 changes: 8 additions & 1 deletion hamt/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,17 @@ func CreateFullShard(ds ipld.DAGService, treeHeight int) (rootNode ipld.Node, er
for i := 0; i < totalChildren; i++ {
var hashbuf [8]byte
binary.LittleEndian.PutUint64(hashbuf[:], uint64(i))
_, err = root.SetAndPrevious(context.Background(), string(hashbuf[:treeHeight]), unixfs.EmptyFileNode())
var previous *ipld.Link
previous, err = root.SetAndPrevious(context.Background(), string(hashbuf[:treeHeight]), unixfs.EmptyFileNode())
if err != nil {
return
}
if previous != nil {
// We shouldn't be overwriting any value, otherwise the tree
// won't be full.
return nil, fmt.Errorf("we have overwritten entry %s",
previous.Cid)
}
}

rootNode, err = root.Node()
Expand Down
3 changes: 3 additions & 0 deletions io/directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,9 @@ func (d *HAMTDirectory) sizeBelowThreshold(timeout time.Duration, processLink fu
return false, true
}

// FIXME: Any other ctx.Err() we should process here? Or just return
// any other error we find here (to avoid another panic call).

// If we reach this then:
// * We are below the threshold (we didn't return inside the EnumLinksAsync
// loop).
Expand Down
13 changes: 9 additions & 4 deletions io/directory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ func TestHAMTEnumerationWhenComputingSize(t *testing.T) {
//oldShardWidth := DefaultShardWidth
//defer func() { DefaultShardWidth = oldShardWidth }()
//DefaultShardWidth = 8
// FIXME: We should be able to use a smaller DefaultShardWidth to have
// a deeper tree and cheaper tests once the import cycle is resolved
// in hamt.CreateFullShard.

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

sequentialDagService.ResetCounter()
// FIXME: Revert to const timeout after debugging.
below, timeoutExceeded := hamtDir.sizeBelowThreshold(1, func(ctx context.Context, _ *ipld.Link) {
})
below, timeoutExceeded := hamtDir.sizeBelowThreshold(EvaluateHAMTTransitionTimeout, nil)
assert.False(t, below)
assert.False(t, timeoutExceeded)
assert.Equal(t, nodesToFetch, sequentialDagService.UniqueCidsFetched())
Expand Down Expand Up @@ -433,10 +434,14 @@ func TestDirBuilder(t *testing.T) {
}

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

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

0 comments on commit 445e541

Please sign in to comment.