From 1c12bc1d42c4120cd76b840e874a2f177ce95d66 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Fri, 13 Oct 2023 19:01:10 +0200 Subject: [PATCH] Add some custom bitswap client options --- go.mod | 4 ++-- go.sum | 4 ++-- setup.go | 14 +++++++++++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 6f741cb..7c33415 100644 --- a/go.mod +++ b/go.mod @@ -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 @@ -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 diff --git a/go.sum b/go.sum index 9d9f48d..2661b46 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/setup.go b/setup.go index bf7a319..fb15c52 100644 --- a/setup.go +++ b/setup.go @@ -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" @@ -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(), + ) bn.Start(bswap) files, err := nopfs.GetDenylistFiles()