mirror of https://github.com/waku-org/js-waku.git
Add getPeers method
To know if relay messages would be published.
This commit is contained in:
parent
eb9955314c
commit
a8d4d494f8
|
@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- `WakuRelay.getPeers` method.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Enable passing `string`s to `addPeerToAddressBook`.
|
- Enable passing `string`s to `addPeerToAddressBook`.
|
||||||
- Use `addPeerToAddressBook` in examples and usage doc.
|
- Use `addPeerToAddressBook` in examples and usage doc.
|
||||||
|
|
|
@ -152,6 +152,18 @@ export class WakuRelay extends Gossipsub implements Pubsub {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the relay peers we are connected to and we would publish a message to
|
||||||
|
*/
|
||||||
|
getPeers(): Set<string> {
|
||||||
|
return getRelayPeers(this, DefaultPubsubTopic, this._options.D, (id) => {
|
||||||
|
// Filter peers we would not publish to
|
||||||
|
return (
|
||||||
|
this.score.score(id) >= this._options.scoreThresholds.publishThreshold
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Join pubsub topic.
|
* Join pubsub topic.
|
||||||
* This is present to override the behavior of Gossipsub and should not
|
* This is present to override the behavior of Gossipsub and should not
|
||||||
|
|
Loading…
Reference in New Issue