feat: add eventemitter support on p2p service and have the handshakedone message emit peerConnected
This commit is contained in:
parent
3cc4c27cf2
commit
b34b7a3a01
|
@ -60,4 +60,5 @@ export default async function (
|
|||
p2p.sendPublicPeersToPeer(p, [peer]);
|
||||
}
|
||||
}
|
||||
p2p.emit("peerConnected", peer);
|
||||
}
|
||||
|
|
|
@ -26,8 +26,9 @@ import {
|
|||
createTransportSocket,
|
||||
} from "#transports/index.js";
|
||||
import messages from "#messages/index.js";
|
||||
import { EventEmitter } from "events";
|
||||
|
||||
export class P2PService {
|
||||
export class P2PService extends EventEmitter {
|
||||
private logger: Logger;
|
||||
private nodeKeyPair: KeyPairEd25519;
|
||||
private localNodeId?: NodeId;
|
||||
|
@ -39,6 +40,7 @@ export class P2PService {
|
|||
>;
|
||||
|
||||
constructor(node: S5Node) {
|
||||
super();
|
||||
this._node = node;
|
||||
this._networkId = node.config.p2p?.network;
|
||||
this.nodeKeyPair = node.config.keyPair;
|
||||
|
|
Loading…
Reference in New Issue