Skip to content
Draft
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
21 changes: 9 additions & 12 deletions core/commands/provide.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,20 @@ See: https://github.com/ipfs/kubo/blob/master/docs/config.md#providestrategy
return nil
}

cleared := n.Provider.Clear()
err = n.Provider.Clear()
if err != nil {
return err
}
if quiet {
return nil
}
_ = re.Emit(cleared)

return nil
msg := "removed all items from provide queue\n"
return cmds.EmitOnce(re, &MessageOutput{Message: msg})
},
Type: int(0),
Type: MessageOutput{},
Encoders: cmds.EncoderMap{
cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, cleared int) error {
quiet, _ := req.Options[provideQuietOptionName].(bool)
if quiet {
return nil
}

_, err := fmt.Fprintf(w, "removed %d items from provide queue\n", cleared)
cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *MessageOutput) error {
_, err := fmt.Fprint(w, out.Message)
return err
}),
},
Expand Down
35 changes: 27 additions & 8 deletions core/node/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ const (
// KeystoreDatastorePath is the base directory for the provider keystore datastores.
KeystoreDatastorePath = "provider-keystore"

// ProvideQueuePath is the directory where the provide queue keeps data.
ProvideQueuePath = "provideq"

// reprovideLastUniqueCountKey stores the unique CID count from
// the last +unique reprovide cycle, used to size the next cycle's
// bloom filter.
Expand Down Expand Up @@ -135,12 +138,11 @@ type DHTProvider interface {
// The schedule and provide queue depend on the network size, hence recent
// network connectivity is essential.
ProvideOnce(keys ...mh.Multihash) error
// Clear clears the all the keys from the provide queue and returns the number
// of keys that were cleared.
// Clear clears all the keys from the provide queue.
//
// The keys are not deleted from the keystore, so they will continue to be
// reprovided as scheduled.
Clear() int
Clear() error
// RefreshSchedule scans the Keystore for any keys that are not currently
// scheduled for reproviding. If such keys are found, it schedules their
// associated keyspace region to be reprovided.
Expand Down Expand Up @@ -171,7 +173,7 @@ type NoopProvider struct{}

func (r *NoopProvider) StartProviding(bool, ...mh.Multihash) error { return nil }
func (r *NoopProvider) ProvideOnce(...mh.Multihash) error { return nil }
func (r *NoopProvider) Clear() int { return 0 }
func (r *NoopProvider) Clear() error { return nil }
func (r *NoopProvider) RefreshSchedule() error { return nil }
func (r *NoopProvider) Close() error { return nil }

Expand Down Expand Up @@ -204,7 +206,7 @@ func (r *LegacyProvider) ProvideOnce(keys ...mh.Multihash) error {
return nil
}

func (r *LegacyProvider) Clear() int {
func (r *LegacyProvider) Clear() error {
return r.System.Clear()
}

Expand All @@ -222,6 +224,7 @@ func LegacyProviderOpt(reprovideInterval time.Duration, strategy string, acceler
provider.Online(cr),
provider.ReproviderInterval(reprovideInterval),
provider.ProvideWorkerCount(provideWorkerCount),
provider.QueueDir(filepath.Join(repo.Path(), ProvideQueuePath)),
}
if !acceleratedDHTClient && reprovideInterval > 0 {
// The estimation kinda suck if you are running with accelerated DHT client,
Expand Down Expand Up @@ -740,6 +743,10 @@ func SweepingProviderOpt(cfg *config.Config) fx.Option {
// processes the queue regardless of this timing.
bufferedIdleWriteTime = time.Minute

// bufferedQueuePath is the repo subdirectory where the buffered provider stores its
// provide queue files.
bufferedQueuePath = "bprovqueue"

// loggerName is the name of the go-log logger used by the provider.
loggerName = dhtprovider.DefaultLoggerName
)
Expand All @@ -749,6 +756,8 @@ func SweepingProviderOpt(cfg *config.Config) fx.Option {
buffered.WithDsName(bufferedDsName),
buffered.WithIdleWriteTime(bufferedIdleWriteTime),
}
queuePath := filepath.Join(repoPath, bufferedQueuePath)

var impl dhtImpl
switch inDht := in.DHT.(type) {
case *dht.IpfsDHT:
Expand Down Expand Up @@ -778,7 +787,11 @@ func SweepingProviderOpt(cfg *config.Config) fx.Option {
if err != nil {
return nil, nil, err
}
return buffered.New(prov, ds, bufferedProviderOpts...), ks, nil
dht, err := buffered.New(prov, ds, queuePath, bufferedProviderOpts...)
if err != nil {
return nil, nil, err
}
return dht, ks, nil
}
case *fullrt.FullRT:
if inDht != nil {
Expand Down Expand Up @@ -826,7 +839,11 @@ func SweepingProviderOpt(cfg *config.Config) fx.Option {
if err != nil {
return nil, nil, err
}
return buffered.New(prov, ds, bufferedProviderOpts...), ks, nil
dht, err := buffered.New(prov, ds, queuePath, bufferedProviderOpts...)
if err != nil {
return nil, nil, err
}
return dht, ks, nil
})

type keystoreInput struct {
Expand Down Expand Up @@ -1475,7 +1492,9 @@ func handleStrategyChange(strategy string, provider DHTProvider, ds datastore.Da
}

providerLog.Infow("Provide.Strategy changed, clearing provide queue", "previous", previous, "current", strategy)
provider.Clear()
if err = provider.Clear(); err != nil {
providerLog.Error("cannot clear provide queue", "err", err)
}

if err := persistStrategy(ctx, strategy, ds); err != nil {
providerLog.Error("cannot update reprovide strategy", "err", err)
Expand Down
7 changes: 4 additions & 3 deletions docs/examples/kubo-as-a-library/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ go 1.26.4
replace github.com/ipfs/kubo => ./../../..

require (
github.com/ipfs/boxo v0.41.1-0.20260701041656-8a6d1d21a6fb
github.com/ipfs/boxo v0.41.1-0.20260703234054-69d6019d09e1
github.com/ipfs/kubo v0.0.0-00010101000000-000000000000
github.com/libp2p/go-libp2p v0.48.0
github.com/multiformats/go-multiaddr v0.16.1
Expand Down Expand Up @@ -53,8 +53,10 @@ require (
github.com/flynn/noise v1.1.0 // indirect
github.com/fsnotify/fsnotify v1.10.1 // indirect
github.com/gabriel-vasile/mimetype v1.4.13 // indirect
github.com/gammazero/cascadeq v0.2.0 // indirect
github.com/gammazero/chanqueue v1.1.2 // indirect
github.com/gammazero/deque v1.2.1 // indirect
github.com/gammazero/fsutil v0.2.0 // indirect
github.com/getsentry/sentry-go v0.27.0 // indirect
github.com/go-jose/go-jose/v4 v4.1.4 // indirect
github.com/go-logr/logr v1.4.3 // indirect
Expand Down Expand Up @@ -85,7 +87,6 @@ require (
github.com/ipfs/go-ds-leveldb v0.5.2 // indirect
github.com/ipfs/go-ds-measure v0.2.2 // indirect
github.com/ipfs/go-ds-pebble v0.5.12 // indirect
github.com/ipfs/go-dsqueue v0.2.0 // indirect
github.com/ipfs/go-fs-lock v0.1.1 // indirect
github.com/ipfs/go-ipfs-cmds v0.16.1 // indirect
github.com/ipfs/go-ipfs-ds-help v1.1.1 // indirect
Expand Down Expand Up @@ -118,7 +119,7 @@ require (
github.com/libp2p/go-doh-resolver v0.5.0 // indirect
github.com/libp2p/go-flow-metrics v0.3.0 // indirect
github.com/libp2p/go-libp2p-asn-util v0.4.1 // indirect
github.com/libp2p/go-libp2p-kad-dht v0.41.0 // indirect
github.com/libp2p/go-libp2p-kad-dht v0.41.1-0.20260703233757-7e03fc4a9736 // indirect
github.com/libp2p/go-libp2p-kbucket v0.8.0 // indirect
github.com/libp2p/go-libp2p-pubsub v0.16.0 // indirect
github.com/libp2p/go-libp2p-pubsub-router v0.6.0 // indirect
Expand Down
14 changes: 8 additions & 6 deletions docs/examples/kubo-as-a-library/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,14 @@ github.com/fsnotify/fsnotify v1.10.1 h1:b0/UzAf9yR5rhf3RPm9gf3ehBPpf0oZKIjtpKrx5
github.com/fsnotify/fsnotify v1.10.1/go.mod h1:TLheqan6HD6GBK6PrDWyDPBaEV8LspOxvPSjC+bVfgo=
github.com/gabriel-vasile/mimetype v1.4.13 h1:46nXokslUBsAJE/wMsp5gtO500a4F3Nkz9Ufpk2AcUM=
github.com/gabriel-vasile/mimetype v1.4.13/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
github.com/gammazero/cascadeq v0.2.0 h1:LHq6hWLQvQCHVtCl5hDWYSavqXRFCKZ8upCdRtsPpfo=
github.com/gammazero/cascadeq v0.2.0/go.mod h1:aEkjsO3wVhT09lheCjiKbEmT7GtGa03WXGmclOZp5wY=
github.com/gammazero/chanqueue v1.1.2 h1:dZEsxlyANZMyeTRemABqZF8QM9BnE4NBI43Oh3y5fIU=
github.com/gammazero/chanqueue v1.1.2/go.mod h1:XDN1X/jjAbmSceNFOQbtKToeSkxtdVdpKu90LiEdBEE=
github.com/gammazero/deque v1.2.1 h1:9fnQVFCCZ9/NOc7ccTNqzoKd1tCWOqeI05/lPqFPMGQ=
github.com/gammazero/deque v1.2.1/go.mod h1:5nSFkzVm+afG9+gy0VIowlqVAW4N8zNcMne+CMQVD2g=
github.com/gammazero/fsutil v0.2.0 h1:/MqQHCBoT07KGY75avKqG/SI0zS693zr1Ljx8cwKWhs=
github.com/gammazero/fsutil v0.2.0/go.mod h1:UhNgS1Hr75DBX6zqBEOB4AAZQiNytnr3Mc0ZpiLKPz4=
github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps=
github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY=
github.com/ghemawat/stream v0.0.0-20171120220530-696b145b53b9 h1:r5GgOLGbza2wVHRzK7aAj6lWZjfbAwiu/RDCVOKjRyM=
Expand Down Expand Up @@ -273,8 +277,8 @@ github.com/ipfs-shipyard/nopfs/ipfs v0.25.0 h1:OqNqsGZPX8zh3eFMO8Lf8EHRRnSGBMqcd
github.com/ipfs-shipyard/nopfs/ipfs v0.25.0/go.mod h1:BxhUdtBgOXg1B+gAPEplkg/GpyTZY+kCMSfsJvvydqU=
github.com/ipfs/bbloom v0.1.0 h1:nIWwfIE3AaG7RCDQIsrUonGCOTp7qSXzxH7ab/ss964=
github.com/ipfs/bbloom v0.1.0/go.mod h1:lDy3A3i6ndgEW2z1CaRFvDi5/ZTzgM1IxA/pkL7Wgts=
github.com/ipfs/boxo v0.41.1-0.20260701041656-8a6d1d21a6fb h1:jLhqcb0bTDtpFJJ4lZhHiv9QRfuVw699DsnE6jVuexk=
github.com/ipfs/boxo v0.41.1-0.20260701041656-8a6d1d21a6fb/go.mod h1:mnR769LN1W7rDI6z1GBLmD15x4pvMdW0oWxik8j3y6g=
github.com/ipfs/boxo v0.41.1-0.20260703234054-69d6019d09e1 h1:dCiGu3j6foxqumSzogscxkHosWrqSpWTwjLJPHx+lRA=
github.com/ipfs/boxo v0.41.1-0.20260703234054-69d6019d09e1/go.mod h1:UgimwKR3NYghoC0+kbsncc+6+BBT/zmOLsgfmwveios=
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.3/go.mod h1:4LmD4ZUw0mhO+JSKdpWwrzATiEfM7WWgQ8H5l6P8MVk=
Expand Down Expand Up @@ -305,8 +309,6 @@ github.com/ipfs/go-ds-measure v0.2.2 h1:4kwvBGbbSXNYe4ANlg7qTIYoZU6mNlqzQHdVqICk
github.com/ipfs/go-ds-measure v0.2.2/go.mod h1:b/87ak0jMgH9Ylt7oH0+XGy4P8jHx9KG09Qz+pOeTIs=
github.com/ipfs/go-ds-pebble v0.5.12 h1:idO/w4i3IBA6vZtVWsyG5IlPIgwd62iUaQZBl/Kv+yI=
github.com/ipfs/go-ds-pebble v0.5.12/go.mod h1:H2zy28KMQSiAflUxpKzKHqbpSHRWPZS5/bi4ymAJOjY=
github.com/ipfs/go-dsqueue v0.2.0 h1:MBi9w3oSiX98Xc+Y7NuJ9G8MI6mAT4IGdO9dHEMCZzU=
github.com/ipfs/go-dsqueue v0.2.0/go.mod h1:8FfNQC4DMF/KkzBXRNB9Rb3MKDW0Sh98HMtXYl1mLQE=
github.com/ipfs/go-fs-lock v0.1.1 h1:TecsP/Uc7WqYYatasreZQiP9EGRy4ZnKoG4yXxR33nw=
github.com/ipfs/go-fs-lock v0.1.1/go.mod h1:2goSXMCw7QfscHmSe09oXiR34DQeUdm+ei+dhonqly0=
github.com/ipfs/go-ipfs-cmds v0.16.1 h1:O3xV6v2LN52wL0odvXX6jqlt7G2scuHzQYl80OJ+TOA=
Expand Down Expand Up @@ -417,8 +419,8 @@ github.com/libp2p/go-libp2p-asn-util v0.4.1 h1:xqL7++IKD9TBFMgnLPZR6/6iYhawHKHl9
github.com/libp2p/go-libp2p-asn-util v0.4.1/go.mod h1:d/NI6XZ9qxw67b4e+NgpQexCIiFYJjErASrYW4PFDN8=
github.com/libp2p/go-libp2p-core v0.2.4/go.mod h1:STh4fdfa5vDYr0/SzYYeqnt+E6KfEV5VxfIrm0bcI0g=
github.com/libp2p/go-libp2p-core v0.3.0/go.mod h1:ACp3DmS3/N64c2jDzcV429ukDpicbL6+TrrxANBjPGw=
github.com/libp2p/go-libp2p-kad-dht v0.41.0 h1:sDigz5SgV20Crj8ItJmJpEAM+eJrzC/SaiBweg0gDRw=
github.com/libp2p/go-libp2p-kad-dht v0.41.0/go.mod h1:2qc4QGLvmIdznYbNg++FF76vp4q2SaBZyr76jHV8xgs=
github.com/libp2p/go-libp2p-kad-dht v0.41.1-0.20260703233757-7e03fc4a9736 h1:C721Ew/Xbjbw1Gk2kPExYP+cFG4CvVRGkW6P/H3Gc2Q=
github.com/libp2p/go-libp2p-kad-dht v0.41.1-0.20260703233757-7e03fc4a9736/go.mod h1:ViYBY1c0mezdQ9T5LQLNRNZZ2mx82xdH6s57487E/e8=
github.com/libp2p/go-libp2p-kbucket v0.3.1/go.mod h1:oyjT5O7tS9CQurok++ERgc46YLwEpuGoFq9ubvoUOio=
github.com/libp2p/go-libp2p-kbucket v0.8.0 h1:QAK7RzKJpYe+EuSEATAaaHYMYLkPDGC18m9jxPLnU8s=
github.com/libp2p/go-libp2p-kbucket v0.8.0/go.mod h1:JMlxqcEyKwO6ox716eyC0hmiduSWZZl6JY93mGaaqc4=
Expand Down
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (
github.com/hashicorp/go-version v1.9.0
github.com/ipfs-shipyard/nopfs v0.0.14
github.com/ipfs-shipyard/nopfs/ipfs v0.25.0
github.com/ipfs/boxo v0.41.1-0.20260701041656-8a6d1d21a6fb
github.com/ipfs/boxo v0.41.1-0.20260703234054-69d6019d09e1
github.com/ipfs/go-block-format v0.2.3
github.com/ipfs/go-cid v0.6.1
github.com/ipfs/go-cidutil v0.1.1
Expand Down Expand Up @@ -52,7 +52,7 @@ require (
github.com/libp2p/go-doh-resolver v0.5.0
github.com/libp2p/go-libp2p v0.48.0
github.com/libp2p/go-libp2p-http v0.5.0
github.com/libp2p/go-libp2p-kad-dht v0.41.0
github.com/libp2p/go-libp2p-kad-dht v0.41.1-0.20260703233757-7e03fc4a9736
github.com/libp2p/go-libp2p-kbucket v0.8.0
github.com/libp2p/go-libp2p-pubsub v0.16.0
github.com/libp2p/go-libp2p-pubsub-router v0.6.0
Expand Down Expand Up @@ -133,8 +133,10 @@ require (
github.com/filecoin-project/go-clock v0.1.0 // indirect
github.com/flynn/noise v1.1.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.13 // indirect
github.com/gammazero/cascadeq v0.2.0 // indirect
github.com/gammazero/chanqueue v1.1.2 // indirect
github.com/gammazero/deque v1.2.1 // indirect
github.com/gammazero/fsutil v0.2.0 // indirect
github.com/getsentry/sentry-go v0.27.0 // indirect
github.com/go-jose/go-jose/v4 v4.1.4 // indirect
github.com/go-kit/log v0.2.1 // indirect
Expand All @@ -155,7 +157,6 @@ require (
github.com/huin/goupnp v1.3.0 // indirect
github.com/ipfs/bbloom v0.1.0 // indirect
github.com/ipfs/go-bitfield v1.1.0 // indirect
github.com/ipfs/go-dsqueue v0.2.0 // indirect
github.com/ipfs/go-ipfs-ds-help v1.1.1 // indirect
github.com/ipfs/go-ipfs-pq v0.0.4 // indirect
github.com/ipfs/go-ipfs-redirects-file v0.1.2 // indirect
Expand Down
14 changes: 8 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,14 @@ github.com/fsnotify/fsnotify v1.10.1 h1:b0/UzAf9yR5rhf3RPm9gf3ehBPpf0oZKIjtpKrx5
github.com/fsnotify/fsnotify v1.10.1/go.mod h1:TLheqan6HD6GBK6PrDWyDPBaEV8LspOxvPSjC+bVfgo=
github.com/gabriel-vasile/mimetype v1.4.13 h1:46nXokslUBsAJE/wMsp5gtO500a4F3Nkz9Ufpk2AcUM=
github.com/gabriel-vasile/mimetype v1.4.13/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
github.com/gammazero/cascadeq v0.2.0 h1:LHq6hWLQvQCHVtCl5hDWYSavqXRFCKZ8upCdRtsPpfo=
github.com/gammazero/cascadeq v0.2.0/go.mod h1:aEkjsO3wVhT09lheCjiKbEmT7GtGa03WXGmclOZp5wY=
github.com/gammazero/chanqueue v1.1.2 h1:dZEsxlyANZMyeTRemABqZF8QM9BnE4NBI43Oh3y5fIU=
github.com/gammazero/chanqueue v1.1.2/go.mod h1:XDN1X/jjAbmSceNFOQbtKToeSkxtdVdpKu90LiEdBEE=
github.com/gammazero/deque v1.2.1 h1:9fnQVFCCZ9/NOc7ccTNqzoKd1tCWOqeI05/lPqFPMGQ=
github.com/gammazero/deque v1.2.1/go.mod h1:5nSFkzVm+afG9+gy0VIowlqVAW4N8zNcMne+CMQVD2g=
github.com/gammazero/fsutil v0.2.0 h1:/MqQHCBoT07KGY75avKqG/SI0zS693zr1Ljx8cwKWhs=
github.com/gammazero/fsutil v0.2.0/go.mod h1:UhNgS1Hr75DBX6zqBEOB4AAZQiNytnr3Mc0ZpiLKPz4=
github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps=
github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY=
github.com/ghemawat/stream v0.0.0-20171120220530-696b145b53b9 h1:r5GgOLGbza2wVHRzK7aAj6lWZjfbAwiu/RDCVOKjRyM=
Expand Down Expand Up @@ -344,8 +348,8 @@ github.com/ipfs-shipyard/nopfs/ipfs v0.25.0 h1:OqNqsGZPX8zh3eFMO8Lf8EHRRnSGBMqcd
github.com/ipfs-shipyard/nopfs/ipfs v0.25.0/go.mod h1:BxhUdtBgOXg1B+gAPEplkg/GpyTZY+kCMSfsJvvydqU=
github.com/ipfs/bbloom v0.1.0 h1:nIWwfIE3AaG7RCDQIsrUonGCOTp7qSXzxH7ab/ss964=
github.com/ipfs/bbloom v0.1.0/go.mod h1:lDy3A3i6ndgEW2z1CaRFvDi5/ZTzgM1IxA/pkL7Wgts=
github.com/ipfs/boxo v0.41.1-0.20260701041656-8a6d1d21a6fb h1:jLhqcb0bTDtpFJJ4lZhHiv9QRfuVw699DsnE6jVuexk=
github.com/ipfs/boxo v0.41.1-0.20260701041656-8a6d1d21a6fb/go.mod h1:mnR769LN1W7rDI6z1GBLmD15x4pvMdW0oWxik8j3y6g=
github.com/ipfs/boxo v0.41.1-0.20260703234054-69d6019d09e1 h1:dCiGu3j6foxqumSzogscxkHosWrqSpWTwjLJPHx+lRA=
github.com/ipfs/boxo v0.41.1-0.20260703234054-69d6019d09e1/go.mod h1:UgimwKR3NYghoC0+kbsncc+6+BBT/zmOLsgfmwveios=
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.3/go.mod h1:4LmD4ZUw0mhO+JSKdpWwrzATiEfM7WWgQ8H5l6P8MVk=
Expand Down Expand Up @@ -376,8 +380,6 @@ github.com/ipfs/go-ds-measure v0.2.2 h1:4kwvBGbbSXNYe4ANlg7qTIYoZU6mNlqzQHdVqICk
github.com/ipfs/go-ds-measure v0.2.2/go.mod h1:b/87ak0jMgH9Ylt7oH0+XGy4P8jHx9KG09Qz+pOeTIs=
github.com/ipfs/go-ds-pebble v0.5.12 h1:idO/w4i3IBA6vZtVWsyG5IlPIgwd62iUaQZBl/Kv+yI=
github.com/ipfs/go-ds-pebble v0.5.12/go.mod h1:H2zy28KMQSiAflUxpKzKHqbpSHRWPZS5/bi4ymAJOjY=
github.com/ipfs/go-dsqueue v0.2.0 h1:MBi9w3oSiX98Xc+Y7NuJ9G8MI6mAT4IGdO9dHEMCZzU=
github.com/ipfs/go-dsqueue v0.2.0/go.mod h1:8FfNQC4DMF/KkzBXRNB9Rb3MKDW0Sh98HMtXYl1mLQE=
github.com/ipfs/go-fs-lock v0.1.1 h1:TecsP/Uc7WqYYatasreZQiP9EGRy4ZnKoG4yXxR33nw=
github.com/ipfs/go-fs-lock v0.1.1/go.mod h1:2goSXMCw7QfscHmSe09oXiR34DQeUdm+ei+dhonqly0=
github.com/ipfs/go-ipfs-cmds v0.16.1 h1:O3xV6v2LN52wL0odvXX6jqlt7G2scuHzQYl80OJ+TOA=
Expand Down Expand Up @@ -504,8 +506,8 @@ github.com/libp2p/go-libp2p-gostream v0.6.0 h1:QfAiWeQRce6pqnYfmIVWJFXNdDyfiR/qk
github.com/libp2p/go-libp2p-gostream v0.6.0/go.mod h1:Nywu0gYZwfj7Jc91PQvbGU8dIpqbQQkjWgDuOrFaRdA=
github.com/libp2p/go-libp2p-http v0.5.0 h1:+x0AbLaUuLBArHubbbNRTsgWz0RjNTy6DJLOxQ3/QBc=
github.com/libp2p/go-libp2p-http v0.5.0/go.mod h1:glh87nZ35XCQyFsdzZps6+F4HYI6DctVFY5u1fehwSg=
github.com/libp2p/go-libp2p-kad-dht v0.41.0 h1:sDigz5SgV20Crj8ItJmJpEAM+eJrzC/SaiBweg0gDRw=
github.com/libp2p/go-libp2p-kad-dht v0.41.0/go.mod h1:2qc4QGLvmIdznYbNg++FF76vp4q2SaBZyr76jHV8xgs=
github.com/libp2p/go-libp2p-kad-dht v0.41.1-0.20260703233757-7e03fc4a9736 h1:C721Ew/Xbjbw1Gk2kPExYP+cFG4CvVRGkW6P/H3Gc2Q=
github.com/libp2p/go-libp2p-kad-dht v0.41.1-0.20260703233757-7e03fc4a9736/go.mod h1:ViYBY1c0mezdQ9T5LQLNRNZZ2mx82xdH6s57487E/e8=
github.com/libp2p/go-libp2p-kbucket v0.3.1/go.mod h1:oyjT5O7tS9CQurok++ERgc46YLwEpuGoFq9ubvoUOio=
github.com/libp2p/go-libp2p-kbucket v0.8.0 h1:QAK7RzKJpYe+EuSEATAaaHYMYLkPDGC18m9jxPLnU8s=
github.com/libp2p/go-libp2p-kbucket v0.8.0/go.mod h1:JMlxqcEyKwO6ox716eyC0hmiduSWZZl6JY93mGaaqc4=
Expand Down
36 changes: 3 additions & 33 deletions test/cli/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1103,15 +1103,14 @@ func runProviderSuite(t *testing.T, sweep bool, apply cfgApplier, awaitReprovide
require.NoError(t, res1.Err)

// Should report cleared items and proper message format
assert.Contains(t, res1.Stdout.String(), "removed")
assert.Contains(t, res1.Stdout.String(), "items from provide queue")
assert.Contains(t, res1.Stdout.String(), "removed all items from provide queue")

// Clear the provide queue second time - should definitely report 0 items
// Clear the provide queue second time.
res2 := nodes[0].IPFS("provide", "clear")
require.NoError(t, res2.Err)

// Should report 0 items cleared since queue was already cleared
assert.Contains(t, res2.Stdout.String(), "removed 0 items from provide queue")
assert.Contains(t, res2.Stdout.String(), "removed all items from provide queue")
})

t.Run("provide clear command with quiet option", func(t *testing.T) {
Expand Down Expand Up @@ -1150,35 +1149,6 @@ func runProviderSuite(t *testing.T, sweep bool, apply cfgApplier, awaitReprovide
res := nodes[0].IPFS("provide", "clear")
require.NoError(t, res.Err)
})

t.Run("provide clear command returns JSON with removed item count", func(t *testing.T) {
t.Parallel()

nodes := harness.NewT(t).NewNodes(1).Init()
nodes.ForEachPar(func(n *harness.Node) {
n.SetIPFSConfig("Provide.Enabled", true)
n.SetIPFSConfig("Provide.DHT.Interval", "22h")
n.SetIPFSConfig("Provide.Strategy", "all")
})
nodes.StartDaemons()
defer nodes.StopDaemons()

// Clear the provide queue with JSON encoding
res := nodes[0].IPFS("provide", "clear", "--enc=json")
require.NoError(t, res.Err)

// Should return valid JSON with the number of removed items
output := res.Stdout.String()
assert.NotEmpty(t, output)

// Parse JSON to verify structure
var result int
err := json.Unmarshal([]byte(output), &result)
require.NoError(t, err, "Output should be valid JSON")

// Should be a non-negative integer (0 or positive)
assert.GreaterOrEqual(t, result, 0)
})
}

// runResumeTests validates Provide.DHT.ResumeEnabled behavior for SweepingProvider.
Expand Down
Loading
Loading