mirror of https://github.com/waku-org/js-waku.git
Returns waku relay peers, not all waku peers across the various protocols
This commit is contained in:
parent
433a490dec
commit
b487e7803b
|
@ -13,7 +13,7 @@ import { RelayCodec, WakuRelayPubsub } from './index';
|
|||
* @returns {Set<string>}
|
||||
*
|
||||
*/
|
||||
export function getWakuPeers(
|
||||
export function getRelayPeers(
|
||||
router: WakuRelayPubsub,
|
||||
topic: string,
|
||||
count: number,
|
|
@ -7,7 +7,7 @@ import { SignaturePolicy } from 'libp2p-interfaces/src/pubsub/signature-policy';
|
|||
import { WakuMessage } from '../waku_message';
|
||||
|
||||
import { RelayCodec, RelayDefaultTopic } from './constants';
|
||||
import { getWakuPeers } from './get_waku_peers';
|
||||
import { getRelayPeers } from './get_relay_peers';
|
||||
import { RelayHeartbeat } from './relay_heartbeat';
|
||||
|
||||
export * from './constants';
|
||||
|
@ -59,7 +59,7 @@ export class WakuRelayPubsub extends Gossipsub {
|
|||
});
|
||||
if (fanoutPeers.size < this._options.D) {
|
||||
// we need more peers; eager, as this would get fixed in the next heartbeat
|
||||
getWakuPeers(
|
||||
getRelayPeers(
|
||||
this,
|
||||
topic,
|
||||
this._options.D - fanoutPeers.size,
|
||||
|
@ -77,7 +77,7 @@ export class WakuRelayPubsub extends Gossipsub {
|
|||
this.fanout.delete(topic);
|
||||
this.lastpub.delete(topic);
|
||||
} else {
|
||||
const peers = getWakuPeers(
|
||||
const peers = getRelayPeers(
|
||||
this,
|
||||
topic,
|
||||
this._options.D,
|
||||
|
@ -132,7 +132,7 @@ export class WakuRelayPubsub extends Gossipsub {
|
|||
meshPeers = this.fanout.get(topic);
|
||||
if (!meshPeers) {
|
||||
// If we are not in the fanout, then pick peers in topic above the publishThreshold
|
||||
const peers = getWakuPeers(this, topic, this._options.D, (id) => {
|
||||
const peers = getRelayPeers(this, topic, this._options.D, (id) => {
|
||||
return (
|
||||
this.score.score(id) >=
|
||||
this._options.scoreThresholds.publishThreshold
|
||||
|
|
|
@ -3,7 +3,7 @@ import { Heartbeat } from 'libp2p-gossipsub/src/heartbeat';
|
|||
import { shuffle } from 'libp2p-gossipsub/src/utils';
|
||||
|
||||
import * as constants from './constants';
|
||||
import { getWakuPeers } from './get_waku_peers';
|
||||
import { getRelayPeers } from './get_relay_peers';
|
||||
|
||||
export class RelayHeartbeat extends Heartbeat {
|
||||
/**
|
||||
|
@ -152,7 +152,7 @@ export class RelayHeartbeat extends Heartbeat {
|
|||
if (peers.size < Dlo) {
|
||||
const backoff = this.gossipsub.backoff.get(topic);
|
||||
const ineed = D - peers.size;
|
||||
const peersSet = getWakuPeers(
|
||||
const peersSet = getRelayPeers(
|
||||
this.gossipsub,
|
||||
topic,
|
||||
ineed,
|
||||
|
@ -239,7 +239,7 @@ export class RelayHeartbeat extends Heartbeat {
|
|||
if (outbound < Dout) {
|
||||
const ineed = Dout - outbound;
|
||||
const backoff = this.gossipsub.backoff.get(topic);
|
||||
getWakuPeers(this.gossipsub, topic, ineed, (id: string): boolean => {
|
||||
getRelayPeers(this.gossipsub, topic, ineed, (id: string): boolean => {
|
||||
// filter our current mesh peers, direct peers, peers we are backing off, peers with negative score
|
||||
return (
|
||||
!peers.has(id) &&
|
||||
|
@ -278,7 +278,7 @@ export class RelayHeartbeat extends Heartbeat {
|
|||
this.gossipsub._options.scoreThresholds.opportunisticGraftThreshold
|
||||
) {
|
||||
const backoff = this.gossipsub.backoff.get(topic);
|
||||
const peersToGraft = getWakuPeers(
|
||||
const peersToGraft = getRelayPeers(
|
||||
this.gossipsub,
|
||||
topic,
|
||||
constants.RelayOpportunisticGraftPeers,
|
||||
|
@ -334,7 +334,7 @@ export class RelayHeartbeat extends Heartbeat {
|
|||
// do we need more peers?
|
||||
if (fanoutPeers.size < D) {
|
||||
const ineed = D - fanoutPeers.size;
|
||||
const peersSet = getWakuPeers(
|
||||
const peersSet = getRelayPeers(
|
||||
this.gossipsub,
|
||||
topic,
|
||||
ineed,
|
||||
|
|
Loading…
Reference in New Issue