3
3
## Suggested ` SweepingReprovider ` interface
4
4
5
5
``` go
6
- type Provider interface {
7
- // StartProviding provides the given keys to the DHT swarm unless they were
8
- // already provided in the past. The keys will be periodically reprovided until
9
- // StopProviding is called for the same keys or user defined garbage collection
10
- // deletes the keys.
11
- StartProviding (...mh .Multihash )
12
-
13
- // ForceStartProviding is similar to StartProviding, but it sends provider
14
- // records out to the DHT regardless of whether the keys were already provided
15
- // in the past. It keeps reproviding the keys until StopProviding is called
16
- // for these keys.
17
- ForceStartProviding (context.Context , ...mh .Multihash ) error
6
+ // DHTProvider is an interface for providing keys to a DHT swarm. It holds a
7
+ // state of keys to be advertised, and is responsible for periodically
8
+ // publishing provider records for these keys to the DHT swarm before the
9
+ // records expire.
10
+ type DHTProvider interface {
11
+ // StartProviding ensures keys are periodically advertised to the DHT swarm.
12
+ //
13
+ // If the keys aren't currently being reprovided, they are immediately
14
+ // provided to the DHT swarm, and scheduled to be reprovided periodically. If
15
+ // `force` is set to true, all keys are immediately provided to the DHT
16
+ // swarm, regardless of whether they were already being provided in the past.
17
+ // `keys` keep being reprovided until `StopProviding` is called.
18
+ //
19
+ // This call blocks until the initial provide completes (or fails), at
20
+ // which point it returns any error related to the initial provide.
21
+ //
22
+ // Cancelling the context cancels only the immediate provide, but not the
23
+ // reproviding of keys which is still done at some point the future. Call
24
+ // `StopProviding` to stop reproviding the specified keys.
25
+ StartProviding (ctx context.Context , force bool , keys ...mh .Multihash ) error
26
+
27
+ // StartProvidingAsync is similar to `StartProviding`, but it does not block
28
+ // until the initial provide operation completes or fails. The supplied keys
29
+ // will eventually be provided and reprovided to the DHT swarm until
30
+ // `StopProviding` is called.
31
+ StartProvidingAsync (force bool , keys ...mh .Multihash )
18
32
19
33
// StopProviding stops reproviding the given keys to the DHT swarm. The node
20
34
// stops being referred as a provider when the provider records in the DHT
@@ -23,6 +37,8 @@ type Provider interface {
23
37
24
38
// ProvideOnce sends provider records for the specified keys to the DHT swarm
25
39
// only once. It does not automatically reprovide those keys afterward.
40
+ //
41
+ // Canceling the context cancels the immediate provide of the keys.
26
42
ProvideOnce (context.Context , ...mh .Multihash ) error
27
43
}
28
44
```
0 commit comments