diff --git a/packages/bitcore-node/src/services/p2p.ts b/packages/bitcore-node/src/services/p2p.ts index 9457817c91c..7eb201a3da6 100644 --- a/packages/bitcore-node/src/services/p2p.ts +++ b/packages/bitcore-node/src/services/p2p.ts @@ -208,6 +208,7 @@ export class P2pWorker { } async connect() { + this.setupListeners(); this.pool.connect(); this.connectInterval = setInterval(this.pool.connect.bind(this.pool), 5000); return new Promise(resolve => { @@ -446,7 +447,6 @@ export class P2pWorker { async start() { logger.debug(`Started worker for chain ${this.chain}`); - this.setupListeners(); await this.connect(); this.registerSyncingNode(); } diff --git a/packages/bitcore-node/test/verification/db-repair.ts b/packages/bitcore-node/test/verification/db-repair.ts index 502879ad318..48d177aa861 100755 --- a/packages/bitcore-node/test/verification/db-repair.ts +++ b/packages/bitcore-node/test/verification/db-repair.ts @@ -18,7 +18,8 @@ import { BlockStorage } from '../../src/models/block'; await Storage.start(); const chainConfig = Config.chainConfig({ chain, network }); const worker = new P2pWorker({ chain, network, chainConfig }); - await worker.start(); + await worker.connect(); + const handleRepair = async data => { switch (data.type) { case 'DUPE_COIN':