Skip to content

Commit

Permalink
Revert some code change
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarhussain committed Oct 13, 2023
1 parent ddcc243 commit 9144fdc
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions packages/beacon-node/src/network/core/networkCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,28 +253,24 @@ export class NetworkCore implements INetworkCore {
/** Destroy this instance. Can only be called once. */
async close(): Promise<void> {
if (this.closed) return;
try {
this.clock.off(ClockEvent.epoch, this.onEpoch);

// Must goodbye and disconnect before stopping libp2p
await this.peerManager.goodbyeAndDisconnectAllPeers();
this.logger.debug("network sent goodbye to all peers");
await this.peerManager.close();
this.logger.debug("network peerManager closed");
await this.gossip.stop();
this.logger.debug("network gossip closed");
await this.reqResp.stop();
await this.reqResp.unregisterAllProtocols();
this.logger.debug("network reqResp closed");
this.attnetsService.close();
this.syncnetsService.close();
await this.libp2p.stop();
this.logger.debug("network lib2p closed");

this.closed = true;
} catch (err) {
this.logger.error("Error on NetworkCore.close()", {}, err as Error);
}
this.clock.off(ClockEvent.epoch, this.onEpoch);

// Must goodbye and disconnect before stopping libp2p
await this.peerManager.goodbyeAndDisconnectAllPeers();
this.logger.debug("network sent goodbye to all peers");
await this.peerManager.close();
this.logger.debug("network peerManager closed");
await this.gossip.stop();
this.logger.debug("network gossip closed");
await this.reqResp.stop();
await this.reqResp.unregisterAllProtocols();
this.logger.debug("network reqResp closed");
this.attnetsService.close();
this.syncnetsService.close();
await this.libp2p.stop();
this.logger.debug("network lib2p closed");

this.closed = true;
}

async scrapeMetrics(): Promise<string> {
Expand Down

0 comments on commit 9144fdc

Please sign in to comment.