*Add a publicly accessible bootstrap node

*Setup our bootstrap to start with our node first, and add in the default bootstrap servers
This commit is contained in:
Derrick Hammer 2022-12-22 08:28:58 -05:00
parent 24ec1e6526
commit 47705c2f12
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 11 additions and 1 deletions

View File

@ -11,6 +11,7 @@ import sodium from "sodium-universal";
import b4a from "b4a"; import b4a from "b4a";
import log from "../log.js"; import log from "../log.js";
import { getKeyPair } from "../lib/seed.js"; import { getKeyPair } from "../lib/seed.js";
import { AddressInfo } from "net";
const LUMEWEB = b4a.from("lumeweb"); const LUMEWEB = b4a.from("lumeweb");
export const LUMEWEB_TOPIC_HASH = b4a.allocUnsafe(32); export const LUMEWEB_TOPIC_HASH = b4a.allocUnsafe(32);
@ -22,8 +23,17 @@ let node: Hyperswarm;
export async function start() { export async function start() {
const keyPair = getKeyPair(); const keyPair = getKeyPair();
const bootstrap = DHT.bootstrapper(49737, "0.0.0.0");
await bootstrap.ready();
node = new Hyperswarm({ keyPair, dht: new DHT({ keyPair }) }); const address = bootstrap.address() as AddressInfo;
node = new Hyperswarm({
keyPair,
dht: new DHT({ keyPair }),
bootstrap: [{ host: address.address, port: address.port }].concat(
require("@hyperswarm/dht/lib/constants").BOOTSTRAP_NODES
),
});
// @ts-ignore // @ts-ignore
await node.dht.ready(); await node.dht.ready();