Skip to content

Commit 6b94711

Browse files
authored
Merge pull request #580 from libp2p/feat/expose-wan-active
feat: expose WANActive
2 parents 7e74bc8 + 7847863 commit 6b94711

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

dual/dual.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,14 @@ func (dht *DHT) Close() error {
8080
return combineErrors(dht.WAN.Close(), dht.LAN.Close())
8181
}
8282

83-
func (dht *DHT) activeWAN() bool {
83+
// WANActive returns true when the WAN DHT is active (has peers).
84+
func (dht *DHT) WANActive() bool {
8485
return dht.WAN.RoutingTable().Size() > 0
8586
}
8687

8788
// Provide adds the given cid to the content routing system.
8889
func (dht *DHT) Provide(ctx context.Context, key cid.Cid, announce bool) error {
89-
if dht.activeWAN() {
90+
if dht.WANActive() {
9091
return dht.WAN.Provide(ctx, key, announce)
9192
}
9293
return dht.LAN.Provide(ctx, key, announce)
@@ -212,7 +213,7 @@ func (dht *DHT) Bootstrap(ctx context.Context) error {
212213

213214
// PutValue adds value corresponding to given Key.
214215
func (dht *DHT) PutValue(ctx context.Context, key string, val []byte, opts ...routing.Option) error {
215-
if dht.activeWAN() {
216+
if dht.WANActive() {
216217
return dht.WAN.PutValue(ctx, key, val, opts...)
217218
}
218219
return dht.LAN.PutValue(ctx, key, val, opts...)

0 commit comments

Comments
 (0)