2024-03-04 10:56:20 +01:00
|
|
|
import type { PeerDiscovery } from "@libp2p/interface";
|
2024-04-07 14:21:00 +02:00
|
|
|
import {
|
|
|
|
|
enrTree,
|
|
|
|
|
wakuDnsDiscovery,
|
|
|
|
|
wakuLocalPeerCacheDiscovery,
|
|
|
|
|
wakuPeerExchangeDiscovery
|
|
|
|
|
} from "@waku/discovery";
|
2024-06-06 12:55:57 -04:00
|
|
|
import {
|
|
|
|
|
DefaultPubsubTopic,
|
|
|
|
|
type Libp2pComponents,
|
|
|
|
|
PubsubTopic
|
|
|
|
|
} from "@waku/interfaces";
|
2024-03-04 10:56:20 +01:00
|
|
|
|
|
|
|
|
const DEFAULT_NODE_REQUIREMENTS = {
|
|
|
|
|
lightPush: 1,
|
|
|
|
|
filter: 1,
|
|
|
|
|
store: 1
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export function defaultPeerDiscoveries(
|
|
|
|
|
pubsubTopics: PubsubTopic[]
|
|
|
|
|
): ((components: Libp2pComponents) => PeerDiscovery)[] {
|
2024-06-06 12:55:57 -04:00
|
|
|
const isDefaultPubsubTopic = pubsubTopics.includes(DefaultPubsubTopic);
|
|
|
|
|
const dnsEnrTrees = isDefaultPubsubTopic
|
|
|
|
|
? [enrTree["DEPRECATED_DEFAULT_PUBSUB"]]
|
|
|
|
|
: [enrTree["SANDBOX"], enrTree["TEST"]];
|
|
|
|
|
|
2024-03-04 10:56:20 +01:00
|
|
|
const discoveries = [
|
2024-06-06 12:55:57 -04:00
|
|
|
wakuDnsDiscovery(dnsEnrTrees, DEFAULT_NODE_REQUIREMENTS),
|
2024-03-04 10:56:20 +01:00
|
|
|
wakuLocalPeerCacheDiscovery(),
|
|
|
|
|
wakuPeerExchangeDiscovery(pubsubTopics)
|
|
|
|
|
];
|
2024-06-06 12:55:57 -04:00
|
|
|
|
2024-03-04 10:56:20 +01:00
|
|
|
return discoveries;
|
|
|
|
|
}
|