mirror of
https://github.com/waku-org/js-waku.git
synced 2025-01-14 14:34:40 +00:00
Use PeerId.toString()
instead of toB58String()
New version of `PeerId` will only support `toString`
This commit is contained in:
parent
3217b28063
commit
6c30e8d400
@ -26,7 +26,7 @@ function info(waku: Waku | undefined): string[] {
|
||||
if (!waku) {
|
||||
return ["Waku node is starting"];
|
||||
}
|
||||
return [`PeerId: ${waku.libp2p.peerId.toB58String()}`];
|
||||
return [`PeerId: ${waku.libp2p.peerId.toString()}`];
|
||||
}
|
||||
|
||||
function connect(peer: string | undefined, waku: Waku | undefined): string[] {
|
||||
@ -64,7 +64,7 @@ async function peers(waku: Waku | undefined): Promise<string[]> {
|
||||
peers.push(peer);
|
||||
}
|
||||
Array.from(peers).forEach((peer) => {
|
||||
response.push(peer.id.toB58String() + ":");
|
||||
response.push(peer.id.toString() + ":");
|
||||
let addresses = " addresses: [";
|
||||
peer.addresses.forEach(({ multiaddr }) => {
|
||||
addresses += " " + multiaddr.toString() + ",";
|
||||
|
@ -171,7 +171,7 @@ describe("DNS Node Discovery w/ capabilities", () => {
|
||||
});
|
||||
|
||||
expect(peers.length).to.eq(1);
|
||||
expect(peers[0].peerId?.toB58String()).to.eq(
|
||||
expect(peers[0].peerId?.toString()).to.eq(
|
||||
"16Uiu2HAmPsYLvfKafxgRsb6tioYyGnSvGXS2iuMigptHrqHPNPzx"
|
||||
);
|
||||
});
|
||||
@ -186,7 +186,7 @@ describe("DNS Node Discovery w/ capabilities", () => {
|
||||
});
|
||||
|
||||
expect(peers.length).to.eq(1);
|
||||
expect(peers[0].peerId?.toB58String()).to.eq(
|
||||
expect(peers[0].peerId?.toString()).to.eq(
|
||||
"16Uiu2HAm2HyS6brcCspSbszG9i36re2bWBVjMe3tMdnFp1Hua34F"
|
||||
);
|
||||
});
|
||||
@ -200,7 +200,7 @@ describe("DNS Node Discovery w/ capabilities", () => {
|
||||
});
|
||||
|
||||
expect(peers.length).to.eq(1);
|
||||
expect(peers[0].peerId?.toB58String()).to.eq(
|
||||
expect(peers[0].peerId?.toString()).to.eq(
|
||||
"16Uiu2HAkv3La3ECgQpdYeEJfrX36EWdhkUDv4C9wvXM8TFZ9dNgd"
|
||||
);
|
||||
});
|
||||
@ -220,7 +220,7 @@ describe("DNS Node Discovery w/ capabilities", () => {
|
||||
});
|
||||
|
||||
expect(peers.length).to.eq(2);
|
||||
const peerIds = peers.map((p) => p.peerId?.toB58String());
|
||||
const peerIds = peers.map((p) => p.peerId?.toString());
|
||||
expect(peerIds).to.contain(
|
||||
"16Uiu2HAm2HyS6brcCspSbszG9i36re2bWBVjMe3tMdnFp1Hua34F"
|
||||
);
|
||||
@ -246,7 +246,7 @@ describe("DNS Node Discovery w/ capabilities", () => {
|
||||
});
|
||||
|
||||
expect(peers.length).to.eq(3);
|
||||
const peerIds = peers.map((p) => p.peerId?.toB58String());
|
||||
const peerIds = peers.map((p) => p.peerId?.toString());
|
||||
expect(peerIds).to.contain(
|
||||
"16Uiu2HAm2HyS6brcCspSbszG9i36re2bWBVjMe3tMdnFp1Hua34F"
|
||||
);
|
||||
|
@ -42,7 +42,7 @@ describe("Fetch nodes until capabilities are fulfilled", function () {
|
||||
);
|
||||
|
||||
expect(res.length).to.eq(1);
|
||||
expect(res[0].peerId!.toB58String()).to.eq(relayNode.peerId?.toB58String());
|
||||
expect(res[0].peerId!.toString()).to.eq(relayNode.peerId?.toString());
|
||||
});
|
||||
|
||||
it("1 Store, 2 fetches", async function () {
|
||||
@ -65,7 +65,7 @@ describe("Fetch nodes until capabilities are fulfilled", function () {
|
||||
);
|
||||
|
||||
expect(res.length).to.eq(1);
|
||||
expect(res[0].peerId!.toB58String()).to.eq(storeNode.peerId?.toB58String());
|
||||
expect(res[0].peerId!.toString()).to.eq(storeNode.peerId?.toString());
|
||||
});
|
||||
|
||||
it("1 Store, 2 relays, 2 fetches", async function () {
|
||||
@ -94,15 +94,9 @@ describe("Fetch nodes until capabilities are fulfilled", function () {
|
||||
);
|
||||
|
||||
expect(res.length).to.eq(3);
|
||||
expect(res[0].peerId!.toB58String()).to.eq(
|
||||
relayNode1.peerId?.toB58String()
|
||||
);
|
||||
expect(res[1].peerId!.toB58String()).to.eq(
|
||||
relayNode2.peerId?.toB58String()
|
||||
);
|
||||
expect(res[2].peerId!.toB58String()).to.eq(
|
||||
relayStoreNode.peerId?.toB58String()
|
||||
);
|
||||
expect(res[0].peerId!.toString()).to.eq(relayNode1.peerId?.toString());
|
||||
expect(res[1].peerId!.toString()).to.eq(relayNode2.peerId?.toString());
|
||||
expect(res[2].peerId!.toString()).to.eq(relayStoreNode.peerId?.toString());
|
||||
});
|
||||
|
||||
it("1 Relay, 1 Filter, gives up", async function () {
|
||||
@ -117,6 +111,6 @@ describe("Fetch nodes until capabilities are fulfilled", function () {
|
||||
);
|
||||
|
||||
expect(res.length).to.eq(1);
|
||||
expect(res[0].peerId!.toB58String()).to.eq(relayNode.peerId?.toB58String());
|
||||
expect(res[0].peerId!.toString()).to.eq(relayNode.peerId?.toString());
|
||||
});
|
||||
});
|
||||
|
@ -36,7 +36,7 @@ describe("ENR Interop: nwaku", function () {
|
||||
|
||||
expect(nwakuInfo.enrUri).to.not.be.undefined;
|
||||
const dec = await ENR.decodeTxt(nwakuInfo.enrUri ?? "");
|
||||
expect(dec.peerId?.toB58String()).to.eq(nimPeerId.toB58String());
|
||||
expect(dec.peerId?.toString()).to.eq(nimPeerId.toString());
|
||||
expect(dec.waku2).to.deep.eq({
|
||||
relay: true,
|
||||
store: false,
|
||||
@ -67,7 +67,7 @@ describe("ENR Interop: nwaku", function () {
|
||||
|
||||
expect(nwakuInfo.enrUri).to.not.be.undefined;
|
||||
const dec = await ENR.decodeTxt(nwakuInfo.enrUri ?? "");
|
||||
expect(dec.peerId?.toB58String()).to.eq(nimPeerId.toB58String());
|
||||
expect(dec.peerId?.toString()).to.eq(nimPeerId.toString());
|
||||
expect(dec.waku2).to.deep.eq({
|
||||
relay: true,
|
||||
store: true,
|
||||
@ -98,7 +98,7 @@ describe("ENR Interop: nwaku", function () {
|
||||
|
||||
expect(nwakuInfo.enrUri).to.not.be.undefined;
|
||||
const dec = await ENR.decodeTxt(nwakuInfo.enrUri ?? "");
|
||||
expect(dec.peerId?.toB58String()).to.eq(nimPeerId.toB58String());
|
||||
expect(dec.peerId?.toString()).to.eq(nimPeerId.toString());
|
||||
expect(dec.waku2).to.deep.eq({
|
||||
relay: true,
|
||||
store: true,
|
||||
|
@ -102,7 +102,7 @@ describe("ENR", function () {
|
||||
expect(enr.ip).to.not.be.undefined;
|
||||
expect(enr.ip).to.be.equal("134.209.139.210");
|
||||
expect(enr.publicKey).to.not.be.undefined;
|
||||
expect(enr.peerId?.toB58String()).to.be.equal(
|
||||
expect(enr.peerId?.toString()).to.be.equal(
|
||||
"16Uiu2HAmPLe7Mzm8TsYUubgCAW1aJoeFScxrLj8ppHFivPo97bUZ"
|
||||
);
|
||||
});
|
||||
|
@ -422,9 +422,7 @@ export class ENR extends Map<ENRKey, ENRValue> {
|
||||
if (this.peerId) {
|
||||
const locationMultiaddr = this.getLocationMultiaddr(protocol);
|
||||
if (locationMultiaddr) {
|
||||
return locationMultiaddr.encapsulate(
|
||||
`/p2p/${this.peerId.toB58String()}`
|
||||
);
|
||||
return locationMultiaddr.encapsulate(`/p2p/${this.peerId.toString()}`);
|
||||
}
|
||||
}
|
||||
return;
|
||||
@ -437,7 +435,7 @@ export class ENR extends Map<ENRKey, ENRValue> {
|
||||
if (this.peerId && this.multiaddrs) {
|
||||
const peerId = this.peerId;
|
||||
return this.multiaddrs.map((ma) => {
|
||||
return ma.encapsulate(`/p2p/${peerId.toB58String()}`);
|
||||
return ma.encapsulate(`/p2p/${peerId.toString()}`);
|
||||
});
|
||||
}
|
||||
return [];
|
||||
|
@ -69,7 +69,7 @@ describe("Waku Dial [node only]", function () {
|
||||
});
|
||||
});
|
||||
|
||||
expect(connectedPeerID.toB58String()).to.eq(multiAddrWithId.getPeerId());
|
||||
expect(connectedPeerID.toString()).to.eq(multiAddrWithId.getPeerId());
|
||||
});
|
||||
|
||||
it("Passing a function", async function () {
|
||||
@ -94,7 +94,7 @@ describe("Waku Dial [node only]", function () {
|
||||
});
|
||||
|
||||
const multiAddrWithId = await nwaku.getMultiaddrWithId();
|
||||
expect(connectedPeerID.toB58String()).to.eq(multiAddrWithId.getPeerId());
|
||||
expect(connectedPeerID.toString()).to.eq(multiAddrWithId.getPeerId());
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -249,7 +249,7 @@ describe("Wait for remote peer / get peers", function () {
|
||||
|
||||
const peers = [];
|
||||
for await (const peer of waku.store.peers) {
|
||||
peers.push(peer.id.toB58String());
|
||||
peers.push(peer.id.toString());
|
||||
}
|
||||
|
||||
const nimPeerId = multiAddrWithId.getPeerId();
|
||||
@ -274,7 +274,7 @@ describe("Wait for remote peer / get peers", function () {
|
||||
|
||||
const peers = [];
|
||||
for await (const peer of waku.store.peers) {
|
||||
peers.push(peer.id.toB58String());
|
||||
peers.push(peer.id.toString());
|
||||
}
|
||||
|
||||
const nimPeerId = multiAddrWithId.getPeerId();
|
||||
@ -297,7 +297,7 @@ describe("Wait for remote peer / get peers", function () {
|
||||
|
||||
const peers = [];
|
||||
for await (const peer of waku.lightPush.peers) {
|
||||
peers.push(peer.id.toB58String());
|
||||
peers.push(peer.id.toString());
|
||||
}
|
||||
|
||||
const nimPeerId = multiAddrWithId.getPeerId();
|
||||
@ -320,7 +320,7 @@ describe("Wait for remote peer / get peers", function () {
|
||||
|
||||
const peers = [];
|
||||
for await (const peer of waku.filter.peers) {
|
||||
peers.push(peer.id.toB58String());
|
||||
peers.push(peer.id.toString());
|
||||
}
|
||||
|
||||
const nimPeerId = multiAddrWithId.getPeerId();
|
||||
|
@ -346,7 +346,7 @@ export class Waku {
|
||||
if (!localMultiaddr || localMultiaddr.toString() === "") {
|
||||
throw "Not listening on localhost";
|
||||
}
|
||||
return localMultiaddr + "/p2p/" + this.libp2p.peerId.toB58String();
|
||||
return localMultiaddr + "/p2p/" + this.libp2p.peerId.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -388,7 +388,7 @@ export class Waku {
|
||||
if (protocols.includes(Protocols.Store)) {
|
||||
const storePromise = (async (): Promise<void> => {
|
||||
for await (const peer of this.store.peers) {
|
||||
dbg("Store peer found", peer.id.toB58String());
|
||||
dbg("Store peer found", peer.id.toString());
|
||||
break;
|
||||
}
|
||||
})();
|
||||
@ -398,7 +398,7 @@ export class Waku {
|
||||
if (protocols.includes(Protocols.LightPush)) {
|
||||
const lightPushPromise = (async (): Promise<void> => {
|
||||
for await (const peer of this.lightPush.peers) {
|
||||
dbg("Light Push peer found", peer.id.toB58String());
|
||||
dbg("Light Push peer found", peer.id.toString());
|
||||
break;
|
||||
}
|
||||
})();
|
||||
@ -408,7 +408,7 @@ export class Waku {
|
||||
if (protocols.includes(Protocols.Filter)) {
|
||||
const filterPromise = (async (): Promise<void> => {
|
||||
for await (const peer of this.filter.peers) {
|
||||
dbg("Filter peer found", peer.id.toB58String());
|
||||
dbg("Filter peer found", peer.id.toString());
|
||||
break;
|
||||
}
|
||||
})();
|
||||
@ -434,7 +434,7 @@ export class Waku {
|
||||
// Just in case a timer already exist for this peer
|
||||
this.stopKeepAlive(peerId);
|
||||
|
||||
const peerIdStr = peerId.toB58String();
|
||||
const peerIdStr = peerId.toString();
|
||||
|
||||
if (pingPeriodSecs !== 0) {
|
||||
const pingService = new PingService(this.libp2p);
|
||||
@ -455,7 +455,7 @@ export class Waku {
|
||||
}
|
||||
|
||||
private stopKeepAlive(peerId: PeerId): void {
|
||||
const peerIdStr = peerId.toB58String();
|
||||
const peerIdStr = peerId.toString();
|
||||
|
||||
if (this.pingKeepAliveTimers[peerIdStr]) {
|
||||
clearInterval(this.pingKeepAliveTimers[peerIdStr]);
|
||||
|
@ -87,7 +87,7 @@ export class WakuFilter {
|
||||
} catch (e) {
|
||||
log(
|
||||
"Error subscribing to peer ",
|
||||
peer.id.toB58String(),
|
||||
peer.id.toString(),
|
||||
"for content topics",
|
||||
contentTopics,
|
||||
": ",
|
||||
@ -200,7 +200,7 @@ export class WakuFilter {
|
||||
peer = await this.libp2p.peerStore.get(peerId);
|
||||
if (!peer) {
|
||||
throw new Error(
|
||||
`Failed to retrieve connection details for provided peer in peer store: ${peerId.toB58String()}`
|
||||
`Failed to retrieve connection details for provided peer in peer store: ${peerId.toString()}`
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
@ -70,8 +70,8 @@ describe("Waku Relay [node only]", () => {
|
||||
waku2.libp2p.pubsub.getSubscribers(DefaultPubSubTopic);
|
||||
|
||||
log("Asserting mutual subscription");
|
||||
expect(subscribers1).to.contain(waku2.libp2p.peerId.toB58String());
|
||||
expect(subscribers2).to.contain(waku1.libp2p.peerId.toB58String());
|
||||
expect(subscribers1).to.contain(waku2.libp2p.peerId.toString());
|
||||
expect(subscribers2).to.contain(waku1.libp2p.peerId.toString());
|
||||
});
|
||||
|
||||
it("Register correct protocols", async function () {
|
||||
@ -338,7 +338,7 @@ describe("Waku Relay [node only]", () => {
|
||||
}
|
||||
|
||||
const nimPeerId = await nwaku.getPeerId();
|
||||
expect(subscribers).to.contain(nimPeerId.toB58String());
|
||||
expect(subscribers).to.contain(nimPeerId.toString());
|
||||
});
|
||||
|
||||
it("Publishes to nwaku", async function () {
|
||||
|
@ -326,7 +326,7 @@ export class WakuRelay extends Gossipsub {
|
||||
*/
|
||||
async _publish(msg: InMessage): Promise<void> {
|
||||
const msgIdStr = await this.getCanonicalMsgIdStr(msg);
|
||||
if (msg.receivedFrom !== this.peerId.toB58String()) {
|
||||
if (msg.receivedFrom !== this.peerId.toString()) {
|
||||
this.score.deliverMessage(msg, msgIdStr);
|
||||
this.gossipTracer.deliverMessage(msgIdStr);
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ export class WakuStore {
|
||||
);
|
||||
|
||||
dbg("Querying history with the following options", {
|
||||
peerId: options?.peerId?.toB58String(),
|
||||
peerId: options?.peerId?.toString(),
|
||||
...options,
|
||||
});
|
||||
|
||||
@ -154,7 +154,7 @@ export class WakuStore {
|
||||
if (opts.peerId) {
|
||||
peer = await this.libp2p.peerStore.get(opts.peerId);
|
||||
if (!peer)
|
||||
throw `Failed to retrieve connection details for provided peer in peer store: ${opts.peerId.toB58String()}`;
|
||||
throw `Failed to retrieve connection details for provided peer in peer store: ${opts.peerId.toString()}`;
|
||||
} else {
|
||||
peer = await this.randomPeer;
|
||||
if (!peer)
|
||||
@ -170,7 +170,7 @@ export class WakuStore {
|
||||
}
|
||||
dbg(`Use store codec ${storeCodec}`);
|
||||
if (!storeCodec)
|
||||
throw `Peer does not register waku store protocol: ${peer.id.toB58String()}`;
|
||||
throw `Peer does not register waku store protocol: ${peer.id.toString()}`;
|
||||
|
||||
Object.assign(opts, { storeCodec });
|
||||
const connection = this.libp2p.connectionManager.get(peer.id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user