diff --git a/CHANGELOG.md b/CHANGELOG.md index 742a784a27..1937d6f5d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- When using `Waku.create`, `bootstrap.peers` now accepts an array of `Multiaddr`. + ## [0.19.0] - 2022-03-09 ### Added diff --git a/examples/web-chat/src/App.tsx b/examples/web-chat/src/App.tsx index da1947165e..8eccafb12d 100644 --- a/examples/web-chat/src/App.tsx +++ b/examples/web-chat/src/App.tsx @@ -185,8 +185,7 @@ async function initWaku(setter: (waku: Waku) => void) { }, }, bootstrap: { - getPeers: () => - Promise.resolve(getPredefinedBootstrapNodes(selectFleetEnv())), + peers: getPredefinedBootstrapNodes(selectFleetEnv()), }, }); diff --git a/src/lib/discovery/bootstrap.ts b/src/lib/discovery/bootstrap.ts index a830ed2931..35a382d067 100644 --- a/src/lib/discovery/bootstrap.ts +++ b/src/lib/discovery/bootstrap.ts @@ -31,7 +31,7 @@ export interface BootstrapOptions { /** * Multiaddrs of peers to connect to. */ - peers?: string[]; + peers?: string[] | Multiaddr[]; /** * Getter that retrieve multiaddrs of peers to connect to. */ @@ -64,7 +64,13 @@ export class Bootstrap { }; } else if (opts.peers !== undefined && opts.peers.length > 0) { const allPeers: Multiaddr[] = opts.peers.map( - (node: string) => new Multiaddr(node) + (node: string | Multiaddr) => { + if (typeof node === "string") { + return new Multiaddr(node); + } else { + return node; + } + } ); const peers = getPseudoRandomSubset(allPeers, maxPeers); dbg( diff --git a/src/lib/waku.node.spec.ts b/src/lib/waku.node.spec.ts index 7f9ce4a65e..d6e714b7e6 100644 --- a/src/lib/waku.node.spec.ts +++ b/src/lib/waku.node.spec.ts @@ -62,7 +62,7 @@ describe("Waku Dial [node only]", function () { waku = await Waku.create({ staticNoiseKey: NOISE_KEY_1, - bootstrap: { peers: [multiAddrWithId.toString()] }, + bootstrap: { peers: [multiAddrWithId] }, }); const connectedPeerID: PeerId = await new Promise((resolve) => {