Skip to content

Commit 3d9cf45

Browse files
web3-botrvagg
authored andcommitted
run gofmt -s
1 parent 4a7a4fe commit 3d9cf45

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

doc.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ intermediate data insertion and deletion. Therefore, for any given set of keys
1414
and their values, a HAMT using the same parameters and CHAMP semantics, the
1515
root node should always produce the same content identifier (CID).
1616
17-
Algorithm Overview
17+
# Algorithm Overview
1818
1919
The HAMT algorithm hashes incoming keys and uses incrementing subsections of
2020
that hash digest at each level of its tree structure to determine the placement
@@ -39,7 +39,7 @@ elements a bucket is allowed to contain ("collisions"). In practice, indexes do
3939
not distribute with perfect randomness so this maximum is theoretical. Entries
4040
stored in the node's buckets are stored in key-sorted order.
4141
42-
Parameters
42+
# Parameters
4343
4444
This HAMT implementation:
4545
@@ -49,7 +49,7 @@ This HAMT implementation:
4949
5050
• Defaults the hash algorithm to the 64-bit variant of Murmur3-x64
5151
52-
Further Reading
52+
# Further Reading
5353
5454
The algorithm used here is identical to that of the IPLD HashMap algorithm
5555
specified at

hamt.go

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
cbg "github.com/whyrusleeping/cbor-gen"
1313
)
1414

15-
//-----------------------------------------------------------------------------
15+
// -----------------------------------------------------------------------------
1616
// Boolean constants
1717
type overwrite bool
1818

@@ -58,7 +58,9 @@ type HashFunc func([]byte) []byte
5858

5959
// Node is a single point in the HAMT, encoded as an IPLD tuple in DAG-CBOR of
6060
// shape:
61-
// [bytes, [Pointer...]]
61+
//
62+
// [bytes, [Pointer...]]
63+
//
6264
// where 'bytes' is the big.Int#Bytes() and the Pointers array is between 1 and
6365
// `2^bitWidth`.
6466
//
@@ -74,10 +76,10 @@ type HashFunc func([]byte) []byte
7476
//
7577
// The IPLD Schema representation of this data structure is as follows:
7678
//
77-
// type Node struct {
78-
// bitfield Bytes
79-
// pointers [Pointer]
80-
// } representation tuple
79+
// type Node struct {
80+
// bitfield Bytes
81+
// pointers [Pointer]
82+
// } representation tuple
8183
type Node struct {
8284
Bitfield *big.Int
8385
Pointers []*Pointer
@@ -91,7 +93,9 @@ type Node struct {
9193

9294
// Pointer is an element in a HAMT node's Pointers array, encoded as an IPLD
9395
// tuple in DAG-CBOR of shape:
94-
// CID or [KV...]
96+
//
97+
// CID or [KV...]
98+
//
9599
// i.e. it is represented as a "kinded union" where a Link is a pointer to a
96100
// child node, while an array is a bucket of elements local to this node. A
97101
// Pointer must represent exactly one of of these two states and cannot be both
@@ -106,12 +110,12 @@ type Node struct {
106110
//
107111
// The IPLD Schema representation of this data structure is as follows:
108112
//
109-
// type Pointer union {
110-
// &Node link
111-
// Bucket list
112-
// } representation kinded
113+
// type Pointer union {
114+
// &Node link
115+
// Bucket list
116+
// } representation kinded
113117
//
114-
// type Bucket [KV]
118+
// type Bucket [KV]
115119
type Pointer struct {
116120
KVs []*KV
117121
Link cid.Cid
@@ -152,10 +156,10 @@ type Pointer struct {
152156
//
153157
// The IPLD Schema representation of this data structure is as follows:
154158
//
155-
// type KV struct {
156-
// key Bytes
157-
// value Any
158-
// } representation tuple
159+
// type KV struct {
160+
// key Bytes
161+
// value Any
162+
// } representation tuple
159163
type KV struct {
160164
Key []byte
161165
Value *cbg.Deferred
@@ -459,8 +463,10 @@ func (n *Node) checkSize(ctx context.Context) (uint64, error) {
459463

460464
// Write is a convenience method that calls flush and writes the node to it's
461465
// internal store, returning the CID of the stored node. It is equivelant to:
462-
// n.Flush
463-
// store.Put(ctx, n)
466+
//
467+
// n.Flush
468+
// store.Put(ctx, n)
469+
//
464470
// where store is equal to the store provided to the node when constructed.
465471
//
466472
// write should only be called on the root node of a HAMT

0 commit comments

Comments
 (0)