Skip to content

Commit

Permalink
Add some custom bitswap client options
Browse files Browse the repository at this point in the history
  • Loading branch information
hsanjuan committed Oct 13, 2023
1 parent 858df29 commit 1c12bc1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ require (
github.com/dgraph-io/badger/v4 v4.2.0
github.com/ipfs-shipyard/nopfs v0.0.12-0.20231012170252-ab19c8a36941
github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231012170819-d73899390a71
github.com/ipfs/boxo v0.13.2-0.20231012132507-6602207a8fa3
github.com/ipfs/boxo v0.13.2-0.20231013160006-ef6adea52299
github.com/ipfs/go-cid v0.4.1
github.com/ipfs/go-datastore v0.6.0
github.com/ipfs/go-ds-badger4 v0.0.0-20231006150127-9137bcc6b981
github.com/ipfs/go-ds-leveldb v0.5.0
github.com/ipfs/go-ipfs-delay v0.0.1
github.com/ipfs/go-log/v2 v2.5.1
github.com/ipfs/go-metrics-interface v0.0.1
github.com/ipfs/go-metrics-prometheus v0.0.2
Expand Down Expand Up @@ -83,7 +84,6 @@ require (
github.com/ipfs/bbloom v0.0.4 // indirect
github.com/ipfs/go-bitfield v1.1.0 // indirect
github.com/ipfs/go-block-format v0.1.2 // indirect
github.com/ipfs/go-ipfs-delay v0.0.1 // indirect
github.com/ipfs/go-ipfs-redirects-file v0.1.1 // indirect
github.com/ipfs/go-ipfs-util v0.0.2 // indirect
github.com/ipfs/go-ipld-cbor v0.0.6 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231012170819-d73899390a71 h1:gMc
github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231012170819-d73899390a71/go.mod h1:+hCrN49NLsrgas30m4xwqD6V8xPRl/I1ZMqy0iNEzUE=
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
github.com/ipfs/boxo v0.13.2-0.20231012132507-6602207a8fa3 h1:sgrhALL6mBoZsNvJ2zUcITcN6IW3y14ej6w7gv5RcOI=
github.com/ipfs/boxo v0.13.2-0.20231012132507-6602207a8fa3/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk=
github.com/ipfs/boxo v0.13.2-0.20231013160006-ef6adea52299 h1:WFpBlVbrvRyMzukb2TS+JPqrc8TkuILdGPoZoyX2na0=
github.com/ipfs/boxo v0.13.2-0.20231013160006-ef6adea52299/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk=
github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY=
Expand Down
14 changes: 13 additions & 1 deletion setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/ipfs/go-datastore"
badger4 "github.com/ipfs/go-ds-badger4"
levelds "github.com/ipfs/go-ds-leveldb"
delay "github.com/ipfs/go-ipfs-delay"
metri "github.com/ipfs/go-metrics-interface"
mprome "github.com/ipfs/go-metrics-prometheus"
"github.com/ipfs/go-unixfsnode"
Expand Down Expand Up @@ -264,7 +265,18 @@ func Setup(ctx context.Context, cfg Config) (*Node, error) {
}

bn := bsnet.NewFromIpfsHost(h, cr)
bswap := bsclient.New(bsctx, bn, blkst)
bswap := bsclient.New(bsctx, bn, blkst,
// default is 1 minute to search for a random live-want (1
// CID). I think we want to search for random live-wants more
// often although probably it overlaps with general
// rebroadcasts.
bsclient.RebroadcastDelay(delay.Fixed(5*time.Second)),
// ProviderSearchDelay: default is 1 second. Worth giving a
// little bit more time for peers to answer before asking them
// again.
bsclient.ProviderSearchDelay(3*time.Second),
bsclient.WithoutDuplicatedBlockStats(),
)

Check warning on line 279 in setup.go

View check run for this annotation

Codecov / codecov/patch

setup.go#L268-L279

Added lines #L268 - L279 were not covered by tests
bn.Start(bswap)

files, err := nopfs.GetDenylistFiles()
Expand Down

0 comments on commit 1c12bc1

Please sign in to comment.