Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,11 @@ func (d *testDag) RemoveMany(ctx context.Context, cids []cid.Cid) error {
var _ DAGService = new(testDag)

func TestBatch(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ctx := t.Context()

d := newTestDag()
b := NewBatch(ctx, d)
for i := 0; i < 1000; i++ {
for range 1000 {
// It would be great if we could use *many* different nodes here
// but we can't add any dependencies and I don't feel like adding
// any more testing code.
Expand Down Expand Up @@ -113,11 +112,10 @@ func TestBatch(t *testing.T) {

func TestBufferedDAG(t *testing.T) {
ds := newTestDag()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ctx := t.Context()
var bdag DAGService = NewBufferedDAG(ctx, ds)

for i := 0; i < 1000; i++ {
for range 1000 {
n := new(EmptyNode)
if err := bdag.Add(ctx, n); err != nil {
t.Fatal(err)
Expand All @@ -132,8 +130,7 @@ func TestBufferedDAG(t *testing.T) {
}

func TestBatchOptions(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ctx := t.Context()

wantMaxSize := 8 << 10
wantMaxNodes := 500
Expand Down
8 changes: 3 additions & 5 deletions daghelpers_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package format

import (
"context"
"testing"

"github.com/ipfs/go-cid"
Expand All @@ -28,7 +27,7 @@ func InitNode(d []byte) *TestNode {
}
}

func (n *TestNode) Resolve([]string) (interface{}, []string, error) {
func (n *TestNode) Resolve([]string) (any, []string, error) {
return nil, nil, ErrEmptyNode
}

Expand Down Expand Up @@ -56,7 +55,7 @@ func (n *TestNode) Links() []*Link {
return n.links
}

func (n *TestNode) Loggable() map[string]interface{} {
func (n *TestNode) Loggable() map[string]any {
return nil
}

Expand Down Expand Up @@ -102,8 +101,7 @@ func (n *TestNode) AddRawLink(name string, l *Link) error {
}

func TestCopy(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ctx := t.Context()
from := newTestDag()

root := InitNode([]byte("level0"))
Expand Down
2 changes: 1 addition & 1 deletion format.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
type Resolver interface {
// Resolve resolves a path through this node, stopping at any link boundary
// and returning the object found as well as the remaining path to traverse
Resolve(path []string) (interface{}, []string, error)
Resolve(path []string) (any, []string, error)

// Tree lists all paths within the object under 'path', and up to the given depth.
// To list the entire object (similar to `find .`) pass "" and -1
Expand Down
4 changes: 2 additions & 2 deletions format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type EmptyNode struct{}

var ErrEmptyNode error = errors.New("dummy node")

func (n *EmptyNode) Resolve([]string) (interface{}, []string, error) {
func (n *EmptyNode) Resolve([]string) (any, []string, error) {
return nil, nil, ErrEmptyNode
}

Expand Down Expand Up @@ -46,7 +46,7 @@ func (n *EmptyNode) Links() []*Link {
return nil
}

func (n *EmptyNode) Loggable() map[string]interface{} {
func (n *EmptyNode) Loggable() map[string]any {
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.24.0

require (
github.com/ipfs/go-block-format v0.2.3
github.com/ipfs/go-cid v0.5.0
github.com/ipfs/go-cid v0.6.0
github.com/multiformats/go-multihash v0.2.3
)

Expand All @@ -16,7 +16,7 @@ require (
github.com/multiformats/go-base32 v0.1.0 // indirect
github.com/multiformats/go-base36 v0.2.0 // indirect
github.com/multiformats/go-multibase v0.2.0 // indirect
github.com/multiformats/go-varint v0.0.7 // indirect
github.com/multiformats/go-varint v0.1.0 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
golang.org/x/crypto v0.41.0 // indirect
golang.org/x/sys v0.35.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ github.com/ipfs/boxo v0.34.0 h1:pMP9bAsTs4xVh8R0ZmxIWviV7kjDa60U24QrlGgHb1g=
github.com/ipfs/boxo v0.34.0/go.mod h1:kzdH/ewDybtO3+M8MCVkpwnIIc/d2VISX95DFrY4vQA=
github.com/ipfs/go-block-format v0.2.3 h1:mpCuDaNXJ4wrBJLrtEaGFGXkferrw5eqVvzaHhtFKQk=
github.com/ipfs/go-block-format v0.2.3/go.mod h1:WJaQmPAKhD3LspLixqlqNFxiZ3BZ3xgqxxoSR/76pnA=
github.com/ipfs/go-cid v0.5.0 h1:goEKKhaGm0ul11IHA7I6p1GmKz8kEYniqFopaB5Otwg=
github.com/ipfs/go-cid v0.5.0/go.mod h1:0L7vmeNXpQpUS9vt+yEARkJ8rOg43DF3iPgn4GIN0mk=
github.com/ipfs/go-cid v0.6.0 h1:DlOReBV1xhHBhhfy/gBNNTSyfOM6rLiIx9J7A4DGf30=
github.com/ipfs/go-cid v0.6.0/go.mod h1:NC4kS1LZjzfhK40UGmpXv5/qD2kcMzACYJNntCUiDhQ=
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM=
Expand All @@ -18,8 +18,8 @@ github.com/multiformats/go-multibase v0.2.0 h1:isdYCVLvksgWlMW9OZRYJEa9pZETFivnc
github.com/multiformats/go-multibase v0.2.0/go.mod h1:bFBZX4lKCA/2lyOFSAoKH5SS6oPyjtnzK/XTFDPkNuk=
github.com/multiformats/go-multihash v0.2.3 h1:7Lyc8XfX/IY2jWb/gI7JP+o7JEq9hOa7BFvVU9RSh+U=
github.com/multiformats/go-multihash v0.2.3/go.mod h1:dXgKXCXjBzdscBLk9JkjINiEsCKRVch90MdaGiKsvSM=
github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/nEGOHFS8=
github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU=
github.com/multiformats/go-varint v0.1.0 h1:i2wqFp4sdl3IcIxfAonHQV9qU5OsZ4Ts9IOoETFs5dI=
github.com/multiformats/go-varint v0.1.0/go.mod h1:5KVAVXegtfmNQQm/lCY+ATvDzvJJhSkUlGQV9wgObdI=
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4=
Expand Down
5 changes: 1 addition & 4 deletions navipld.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ const preloadSize = 10
// Preload at most `preloadSize` child nodes from `beg` through promises
// created using this `ctx`.
func (nn *NavigableIPLDNode) preload(ctx context.Context, beg uint) {
end := beg + preloadSize
if end >= uint(len(nn.childCIDs)) {
end = uint(len(nn.childCIDs))
}
end := min(beg+preloadSize, uint(len(nn.childCIDs)))

copy(nn.childPromises[beg:], GetNodes(ctx, nn.nodeGetter, nn.childCIDs[beg:end]))
}
Expand Down