mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-12 08:41:22 +00:00
refactor: peristent peer-store extended class and disabled by defaul
This commit is contained in:
@ -32,18 +32,10 @@ class PeerStore extends EventEmitter {
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {Object} properties
|
||||
* @param {Datastore} [properties.datastore] Datastore to persist data.
|
||||
* @param {boolean} [properties.persistance = true] Persist peerstore data.
|
||||
*/
|
||||
constructor ({ datastore, persistance = true } = {}) {
|
||||
constructor () {
|
||||
super()
|
||||
|
||||
/**
|
||||
* Backend datastore used to persist data.
|
||||
*/
|
||||
this._datastore = datastore
|
||||
|
||||
/**
|
||||
* AddressBook containing a map of peerIdStr to Address.
|
||||
*/
|
||||
@ -60,19 +52,17 @@ class PeerStore extends EventEmitter {
|
||||
* @type {Map<string, Array<PeerId>}
|
||||
*/
|
||||
this.peerIds = new Map()
|
||||
|
||||
this._enabledPersistance = persistance
|
||||
}
|
||||
|
||||
/**
|
||||
* Load data from the datastore to populate the PeerStore.
|
||||
* Start the PeerStore.
|
||||
*/
|
||||
async load () {
|
||||
if (this._enabledPersistance) {
|
||||
await this.addressBook._loadData()
|
||||
await this.protoBook._loadData()
|
||||
}
|
||||
}
|
||||
start () {}
|
||||
|
||||
/**
|
||||
* Stop the PeerStore.
|
||||
*/
|
||||
stop () {}
|
||||
|
||||
/**
|
||||
* Get all the stored information of every peer.
|
||||
|
Reference in New Issue
Block a user