refactor: remove dupe code

This commit is contained in:
fryorcraken.eth 2022-12-13 15:23:39 +11:00
parent 39e96c554d
commit a640e2c940
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
3 changed files with 2 additions and 18 deletions

View File

@ -59,6 +59,7 @@
"dependencies": {
"@waku/enr": "*",
"@waku/byte-utils": "*",
"@waku/libp2p-utils": "*",
"hi-base32": "^0.5.1",
"debug": "^4.3.4",
"dns-query": "^0.11.2",

View File

@ -6,10 +6,10 @@ import { symbol } from "@libp2p/interface-peer-discovery";
import type { PeerInfo } from "@libp2p/interface-peer-info";
import { CustomEvent, EventEmitter } from "@libp2p/interfaces/events";
import { ENR } from "@waku/enr";
import { multiaddrsToPeerInfo } from "@waku/libp2p-utils";
import debug from "debug";
import { DnsNodeDiscovery, NodeCapabilityCount } from "./dns.js";
import { multiaddrsToPeerInfo } from "./multiaddr_to_peer_info.js";
const log = debug("waku:peer-discovery-dns");

View File

@ -1,17 +0,0 @@
import { PeerInfo } from "@libp2p/interface-peer-info";
import { peerIdFromString } from "@libp2p/peer-id";
import { Multiaddr } from "@multiformats/multiaddr";
export function multiaddrsToPeerInfo(mas: Multiaddr[]): PeerInfo[] {
return mas
.map((ma) => {
const peerIdStr = ma.getPeerId();
const protocols: string[] = [];
return {
id: peerIdStr ? peerIdFromString(peerIdStr) : null,
multiaddrs: [ma.decapsulateCode(421)],
protocols,
};
})
.filter((peerInfo): peerInfo is PeerInfo => peerInfo.id !== null);
}