mirror of https://github.com/status-im/js-waku.git
refactor: remove dupe code
This commit is contained in:
parent
39e96c554d
commit
a640e2c940
|
@ -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",
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
Loading…
Reference in New Issue