@@ -19,11 +19,11 @@ import PeerId from 'peer-id';
1919import { WakuMessage } from '../waku_message' ;
2020
2121import * as constants from './constants' ;
22- import { RelayCodec , RelayDefaultTopic } from './constants' ;
22+ import { DefaultPubsubTopic , RelayCodec } from './constants' ;
2323import { getRelayPeers } from './get_relay_peers' ;
2424import { RelayHeartbeat } from './relay_heartbeat' ;
2525
26- export { RelayCodec , RelayDefaultTopic } ;
26+ export { RelayCodec , DefaultPubsubTopic } ;
2727
2828/**
2929 * See {GossipOptions} from libp2p-gossipsub
@@ -94,7 +94,7 @@ export class WakuRelay extends Gossipsub implements Pubsub {
9494 * @returns {void }
9595 */
9696 public start ( ) : void {
97- this . on ( constants . RelayDefaultTopic , ( event ) => {
97+ this . on ( constants . DefaultPubsubTopic , ( event ) => {
9898 const wakuMsg = WakuMessage . decode ( event . data ) ;
9999 if ( this . observers [ '' ] ) {
100100 this . observers [ '' ] . forEach ( ( callbackFn ) => {
@@ -111,7 +111,7 @@ export class WakuRelay extends Gossipsub implements Pubsub {
111111 } ) ;
112112
113113 super . start ( ) ;
114- super . subscribe ( constants . RelayDefaultTopic ) ;
114+ super . subscribe ( constants . DefaultPubsubTopic ) ;
115115 }
116116
117117 /**
@@ -122,7 +122,7 @@ export class WakuRelay extends Gossipsub implements Pubsub {
122122 */
123123 public async send ( message : WakuMessage ) : Promise < void > {
124124 const msg = message . encode ( ) ;
125- await super . publish ( constants . RelayDefaultTopic , Buffer . from ( msg ) ) ;
125+ await super . publish ( constants . DefaultPubsubTopic , Buffer . from ( msg ) ) ;
126126 }
127127
128128 /**
@@ -152,6 +152,18 @@ export class WakuRelay extends Gossipsub implements Pubsub {
152152 }
153153 }
154154
155+ /**
156+ * Return the relay peers we are connected to and we would publish a message to
157+ */
158+ getPeers ( ) : Set < string > {
159+ return getRelayPeers ( this , DefaultPubsubTopic , this . _options . D , ( id ) => {
160+ // Filter peers we would not publish to
161+ return (
162+ this . score . score ( id ) >= this . _options . scoreThresholds . publishThreshold
163+ ) ;
164+ } ) ;
165+ }
166+
155167 /**
156168 * Join pubsub topic.
157169 * This is present to override the behavior of Gossipsub and should not
0 commit comments