diff --git a/src/service/p2p.ts b/src/service/p2p.ts index 751c9a0..738df78 100644 --- a/src/service/p2p.ts +++ b/src/service/p2p.ts @@ -28,7 +28,7 @@ import { connect as tcpConnect, TcpPeer } from "../peer/tcp.js"; import { connect as wsConnect, WebSocketPeer } from "../peer/webSocket.js"; export class P2PService { - get peers(): Map { + get peers(): Map { return this._peers; } @@ -37,10 +37,15 @@ export class P2PService { private nodeKeyPair: KeyPairEd25519; private localNodeId?: NodeId; private networkId?: string; - private _peers: Map = new Map(); - private reconnectDelay: Map = new Map(); + private _peers: Map = new Map(); + private reconnectDelay: Map = new Map(); private selfConnectionUris: Array = []; - private nodesDb: AbstractLevel; + private nodesDb?: AbstractSublevel< + AbstractLevel, + Uint8Array, + string, + Uint8Array + >; private hashQueryRoutingTable: Map> = new Map(); @@ -49,13 +54,13 @@ export class P2PService { this.networkId = config?.p2p?.network; this.nodeKeyPair = config.keyPair; this.logger = config.logger; - this.nodesDb = this.config.nodesDb; config.services.p2p = this; } async init(): Promise { this.localNodeId = new NodeId(this.nodeKeyPair.publicKey); // Define the NodeId constructor + this.nodesDb = this.config.db.sublevel("s5-nodes", {}); } async start(): Promise { diff --git a/src/types.ts b/src/types.ts index ce1c0ec..996d37a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -47,7 +47,6 @@ export interface S5Config { logger: Logger; db: AbstractLevel; cacheDb: AbstractLevel; - nodesDb: AbstractLevel; services: { p2p: P2PService; };