ssb-conn-db
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -5,2 +5,3 @@ import { AddressData, Opts } from './types'; | ||
private readonly _map?; | ||
private readonly _feedIdMap?; | ||
private readonly _notify?; | ||
@@ -7,0 +8,0 @@ private readonly _writeTimeout; |
@@ -11,2 +11,3 @@ "use strict"; | ||
const debug = require('debug')('ssb:conn-db'); | ||
const Ref = require('ssb-ref'); | ||
const defaultOpts = { | ||
@@ -23,2 +24,3 @@ path: path.join(os.homedir(), '.ssb'), | ||
this._map = new Map(); | ||
this._feedIdMap = new Map(); | ||
this._notify = Notify(); | ||
@@ -97,5 +99,7 @@ this._writeTimeout = | ||
_load(vals) { | ||
const keys = Object.keys(vals); | ||
for (let key of keys) { | ||
this._map.set(key, vals[key]); | ||
for (const [addr, data] of Object.entries(vals)) { | ||
this._map.set(addr, data); | ||
if (data.key && Ref.isFeed(data.key)) { | ||
this._feedIdMap.set(data.key, addr); | ||
} | ||
} | ||
@@ -219,7 +223,7 @@ this._loadedResolve(true); | ||
this._assertNotClosed(); | ||
for (let [address, data] of this._map.entries()) { | ||
if (data.key === id) | ||
return address; | ||
} | ||
return undefined; | ||
const address = this._feedIdMap.get(id); | ||
if (address) | ||
return address; | ||
else | ||
return undefined; | ||
} | ||
@@ -226,0 +230,0 @@ has(address) { |
{ | ||
"name": "ssb-conn-db", | ||
"description": "Module that manages a local registry of connectable peers", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"homepage": "https://github.com/staltz/ssb-conn-db", | ||
@@ -13,3 +13,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"atomic-file-rw": "^0.2.1", | ||
"atomic-file-rw": "^0.2.2", | ||
"debug": "^4.3.1", | ||
@@ -16,0 +16,0 @@ "multiserver-address": "~1.0.1", |
@@ -120,5 +120,4 @@ import * as fs from 'fs'; | ||
private _load(vals: Record<string, AddressData>): void { | ||
const keys = Object.keys(vals); | ||
for (let key of keys) { | ||
this._map!.set(key, vals[key]); | ||
for (const [addr, data] of Object.entries(vals)) { | ||
this._map!.set(addr, data); | ||
} | ||
@@ -125,0 +124,0 @@ this._loadedResolve(true); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
164585
1424
Updatedatomic-file-rw@^0.2.2