From 2ef91a4d9c21452aaec0bb15b70a917c80b775b0 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Thu, 31 Aug 2023 02:32:59 -0400 Subject: [PATCH] refactor: need to use a query chain access --- src/service/p2p.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/service/p2p.ts b/src/service/p2p.ts index bab9076..b59228e 100644 --- a/src/service/p2p.ts +++ b/src/service/p2p.ts @@ -353,7 +353,7 @@ export class P2PService { if (nodeId.equals(this.localNodeId)) { return 1; } - const node = await this.nodesDb.get(stringifyNode(nodeId)); + const node = await this.nodesDb?.get(stringifyNode(nodeId)); if (!node) { return 0.5; } @@ -362,7 +362,7 @@ export class P2PService { } private async _vote(nodeId: NodeId, upvote: boolean): Promise { - const node = await this.nodesDb.get(stringifyNode(nodeId)); + const node = await this.nodesDb?.get(stringifyNode(nodeId)); const map = node ? Unpacker.fromPacked(node).unpackMap() : new Map( @@ -375,7 +375,7 @@ export class P2PService { map.set(2, (map.get(2) ?? 0) + 1); } - await this.nodesDb.put( + await this.nodesDb?.put( stringifyNode(nodeId), new Packer().pack(map).takeBytes(), );