mirror of
https://github.com/waku-org/js-waku.git
synced 2025-01-12 13:34:48 +00:00
Allow passing multiaddr to bootstrap.peers
(#608)
This commit is contained in:
parent
e4024d5c72
commit
ed23332965
@ -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
|
||||
|
@ -185,8 +185,7 @@ async function initWaku(setter: (waku: Waku) => void) {
|
||||
},
|
||||
},
|
||||
bootstrap: {
|
||||
getPeers: () =>
|
||||
Promise.resolve(getPredefinedBootstrapNodes(selectFleetEnv())),
|
||||
peers: getPredefinedBootstrapNodes(selectFleetEnv()),
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -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(
|
||||
|
@ -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) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user