refactor: need to use a query chain access

This commit is contained in:
Derrick Hammer 2023-08-31 02:32:59 -04:00
parent 91034708bc
commit 2ef91a4d9c
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 3 additions and 3 deletions

View File

@ -353,7 +353,7 @@ export class P2PService {
if (nodeId.equals(this.localNodeId)) { if (nodeId.equals(this.localNodeId)) {
return 1; return 1;
} }
const node = await this.nodesDb.get(stringifyNode(nodeId)); const node = await this.nodesDb?.get(stringifyNode(nodeId));
if (!node) { if (!node) {
return 0.5; return 0.5;
} }
@ -362,7 +362,7 @@ export class P2PService {
} }
private async _vote(nodeId: NodeId, upvote: boolean): Promise<void> { private async _vote(nodeId: NodeId, upvote: boolean): Promise<void> {
const node = await this.nodesDb.get(stringifyNode(nodeId)); const node = await this.nodesDb?.get(stringifyNode(nodeId));
const map = node const map = node
? Unpacker.fromPacked(node).unpackMap() ? Unpacker.fromPacked(node).unpackMap()
: new Map<number, number>( : new Map<number, number>(
@ -375,7 +375,7 @@ export class P2PService {
map.set(2, (map.get(2) ?? 0) + 1); map.set(2, (map.get(2) ?? 0) + 1);
} }
await this.nodesDb.put( await this.nodesDb?.put(
stringifyNode(nodeId), stringifyNode(nodeId),
new Packer().pack(map).takeBytes(), new Packer().pack(map).takeBytes(),
); );