Skip to content

Commit 34ad246

Browse files
updated interface
1 parent 254abbf commit 34ad246

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

reprovider/interface.md

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,32 @@
33
## Suggested `SweepingReprovider` interface
44

55
```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)
1832

1933
// StopProviding stops reproviding the given keys to the DHT swarm. The node
2034
// stops being referred as a provider when the provider records in the DHT
@@ -23,6 +37,8 @@ type Provider interface {
2337

2438
// ProvideOnce sends provider records for the specified keys to the DHT swarm
2539
// only once. It does not automatically reprovide those keys afterward.
40+
//
41+
// Canceling the context cancels the immediate provide of the keys.
2642
ProvideOnce(context.Context, ...mh.Multihash) error
2743
}
2844
```

0 commit comments

Comments
 (0)