mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-13 17:21:21 +00:00
test: use ed25519 keys in tests (#669)
* chore: use ed25519 keys in tests * fix: persisted keybook recheck keybook content for delete * chore: only store if key not inline * chore: update peer id * chore: identify wait for closed streams
This commit is contained in:
@ -67,7 +67,7 @@ class PersistentPeerStore extends PeerStore {
|
||||
// Handlers for dirty peers
|
||||
this.on('change:protocols', this._addDirtyPeer)
|
||||
this.on('change:multiaddrs', this._addDirtyPeer)
|
||||
this.on('change:pubkey', this._addDirtyPeer)
|
||||
this.on('change:pubkey', this._addDirtyPeerKey)
|
||||
this.on('change:metadata', this._addDirtyPeerMetadata)
|
||||
|
||||
// Load data
|
||||
@ -111,6 +111,31 @@ class PersistentPeerStore extends PeerStore {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add modified peer key to the dirty set
|
||||
* @private
|
||||
* @param {Object} params
|
||||
* @param {PeerId} params.peerId
|
||||
*/
|
||||
_addDirtyPeerKey ({ peerId }) {
|
||||
// Not add if inline key available
|
||||
if (peerId.hasInlinePublicKey()) {
|
||||
return
|
||||
}
|
||||
|
||||
const peerIdstr = peerId.toB58String()
|
||||
|
||||
log('add dirty peer key', peerIdstr)
|
||||
this._dirtyPeers.add(peerIdstr)
|
||||
|
||||
if (this._dirtyPeers.size >= this.threshold) {
|
||||
// Commit current data
|
||||
this._commitData().catch(err => {
|
||||
log.error('error committing data', err)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add modified metadata peer to the set.
|
||||
*
|
||||
@ -164,7 +189,7 @@ class PersistentPeerStore extends PeerStore {
|
||||
this._batchAddressBook(peerId, batch)
|
||||
|
||||
// Key Book
|
||||
this._batchKeyBook(peerId, batch)
|
||||
!peerId.hasInlinePublicKey() && this._batchKeyBook(peerId, batch)
|
||||
|
||||
// Metadata Book
|
||||
this._batchMetadataBook(peerId, batch)
|
||||
|
Reference in New Issue
Block a user