fest: add stop method

This commit is contained in:
Derrick Hammer 2023-09-01 20:55:21 -04:00
parent 90c0614773
commit dfe9e3f082
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 7 additions and 0 deletions

View File

@ -69,6 +69,10 @@ export class S5Node {
await p2p.start();
}
public async stop() {
await this.services.p2p.stop();
}
async readStorageLocationsFromDB(
hash: Multihash,
): Promise<Map<number, Map<string, Map<number, any>>>> {

View File

@ -97,6 +97,9 @@ export class P2PService extends EventEmitter {
this.connectToNode([new URL(p)]);
}
}
async stop() {
[...this.node.services.p2p.peers.values()].forEach((peer) => peer.end());
}
async onNewPeer(peer: Peer, verifyId: boolean): Promise<void> {
peer.challenge = crypto.randomBytes(32);