fix: add getter for networkId and hashQueryRoutingTable

This commit is contained in:
Derrick Hammer 2023-08-31 06:49:33 -04:00
parent b5e491b01a
commit 6ebc477449
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 15 additions and 5 deletions

View File

@ -31,24 +31,34 @@ export class P2PService {
private logger: Logger; private logger: Logger;
private nodeKeyPair: KeyPairEd25519; private nodeKeyPair: KeyPairEd25519;
private localNodeId?: NodeId; private localNodeId?: NodeId;
private networkId?: string;
private nodesDb?: AbstractSublevel< private nodesDb?: AbstractSublevel<
AbstractLevel<Uint8Array, string, Uint8Array>, AbstractLevel<Uint8Array, string, Uint8Array>,
Uint8Array, Uint8Array,
string, string,
Uint8Array Uint8Array
>; >;
private hashQueryRoutingTable: Map<Multihash, Set<NodeId>> = new Map();
constructor(node: S5Node) { constructor(node: S5Node) {
this._node = node; this._node = node;
this.networkId = node.config.p2p?.network; this._networkId = node.config.p2p?.network;
this.nodeKeyPair = node.config.keyPair; this.nodeKeyPair = node.config.keyPair;
this.logger = node.logger; this.logger = node.logger;
node.config.services.p2p = this; node.config.services.p2p = this;
} }
private _hashQueryRoutingTable: Map<Multihash, Set<NodeId>> = new Map();
get hashQueryRoutingTable(): Map<Multihash, Set<NodeId>> {
return this._hashQueryRoutingTable;
}
private _networkId?: string;
get networkId(): string {
return this._networkId as string;
}
private _node: S5Node; private _node: S5Node;
get node(): S5Node { get node(): S5Node {
@ -92,8 +102,8 @@ export class P2PService {
const initialAuthPayloadPacker = new Packer(); const initialAuthPayloadPacker = new Packer();
initialAuthPayloadPacker.packInt(protocolMethodHandshakeOpen); initialAuthPayloadPacker.packInt(protocolMethodHandshakeOpen);
initialAuthPayloadPacker.packBinary(Buffer.from(peer.challenge)); initialAuthPayloadPacker.packBinary(Buffer.from(peer.challenge));
if (this.networkId) { if (this._networkId) {
initialAuthPayloadPacker.packString(this.networkId); initialAuthPayloadPacker.packString(this._networkId);
} }
const completer = defer<void>(); const completer = defer<void>();