1
0
mirror of https://github.com/fluencelabs/js-libp2p synced 2025-06-26 07:21:36 +00:00

chore: update to new multiformats ()

BREAKING CHANGE: uses the CID class from the new multiformats module

Co-authored-by: Vasco Santos <vasco.santos@moxy.studio>
This commit is contained in:
Alex Potsides
2021-07-09 07:43:34 +01:00
committed by GitHub
parent 39b03586e8
commit 13cf476148
19 changed files with 81 additions and 78 deletions
.github/workflows
examples
libp2p-in-the-browser
peer-and-content-routing
webrtc-direct
package.json
src
circuit
content-routing
peer-store
record
peer-record
test

@ -7,6 +7,7 @@ const log = Object.assign(debug('libp2p:persistent-peer-store'), {
const { Key } = require('interface-datastore')
const { Multiaddr } = require('multiaddr')
const PeerId = require('peer-id')
const { base32 } = require('multiformats/bases/base32')
const PeerStore = require('..')
@ -195,7 +196,7 @@ class PersistentPeerStore extends PeerStore {
const batch = this._datastore.batch()
for (const peerIdStr of commitPeers) {
// PeerId
const peerId = this.keyBook.data.get(peerIdStr) || PeerId.createFromCID(peerIdStr)
const peerId = this.keyBook.data.get(peerIdStr) || PeerId.createFromB58String(peerIdStr)
// Address Book
this._batchAddressBook(peerId, batch)
@ -346,7 +347,7 @@ class PersistentPeerStore extends PeerStore {
async _processDatastoreEntry ({ key, value }) {
try {
const keyParts = key.toString().split('/')
const peerId = PeerId.createFromCID(keyParts[3])
const peerId = PeerId.createFromBytes(base32.decode(keyParts[3]))
let decoded
switch (keyParts[2]) {