Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!MODE[this.mode]) { throw new Error(`unexpected mode ${this.mode}`) }
this.reconnect = (this.config.reconnect === undefined ? true : false);
const rpcconfig = Object.assign({}, {
protocol: "http",
host: "127.0.0.1",
port: "8332",
}, this.config.rpc);
this.ready = function() {};
this.blockreq = null;
this.queue = new Queue(1, Infinity);
this.rpc = new RPCClient(rpcconfig);
this.currheight = 0;
this.blockheight = 0;
this.peer = new Peer({ host: this.config.peer.host, messages });
this.peer.on("ready", () => {
this.onconnect();
});
this.peer.on("disconnect", async () => {
await this.ondisconnect();
});
this.peer.on("block", async (message) => {
if (this.mode == MODE.MEMPOOL) {