mirror of
https://github.com/Permissionless-Software-Foundation/bch-dex.git
synced 2026-09-21 16:52:00 -07:00
fix(keys): Creating persistent keystore for libp2p v1.0.x
This commit is contained in:
Generated
-1
@@ -25,7 +25,6 @@
|
|||||||
"glob": "7.1.6",
|
"glob": "7.1.6",
|
||||||
"helia": "2.1.0",
|
"helia": "2.1.0",
|
||||||
"helia-coord": "1.2.23",
|
"helia-coord": "1.2.23",
|
||||||
"interface-datastore": "8.2.10",
|
|
||||||
"jsonrpc-lite": "2.2.0",
|
"jsonrpc-lite": "2.2.0",
|
||||||
"jsonwebtoken": "8.5.1",
|
"jsonwebtoken": "8.5.1",
|
||||||
"jwt-bch-lib": "1.3.0",
|
"jwt-bch-lib": "1.3.0",
|
||||||
|
|||||||
@@ -40,7 +40,6 @@
|
|||||||
"glob": "7.1.6",
|
"glob": "7.1.6",
|
||||||
"helia": "2.1.0",
|
"helia": "2.1.0",
|
||||||
"helia-coord": "1.2.23",
|
"helia-coord": "1.2.23",
|
||||||
"interface-datastore": "8.2.10",
|
|
||||||
"jsonrpc-lite": "2.2.0",
|
"jsonrpc-lite": "2.2.0",
|
||||||
"jsonwebtoken": "8.5.1",
|
"jsonwebtoken": "8.5.1",
|
||||||
"jwt-bch-lib": "1.3.0",
|
"jwt-bch-lib": "1.3.0",
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import { multiaddr } from '@multiformats/multiaddr'
|
|||||||
import { webRTC } from '@libp2p/webrtc'
|
import { webRTC } from '@libp2p/webrtc'
|
||||||
import { keychain } from '@libp2p/keychain'
|
import { keychain } from '@libp2p/keychain'
|
||||||
import { defaultLogger } from '@libp2p/logger'
|
import { defaultLogger } from '@libp2p/logger'
|
||||||
import { Key } from 'interface-datastore/key'
|
|
||||||
|
|
||||||
// Local libraries
|
// Local libraries
|
||||||
import config from '../../../config/index.js'
|
import config from '../../../config/index.js'
|
||||||
@@ -122,15 +121,12 @@ class IpfsAdapter {
|
|||||||
datastore,
|
datastore,
|
||||||
logger: defaultLogger()
|
logger: defaultLogger()
|
||||||
})
|
})
|
||||||
const selfKey = new Key('/pkcs8/self')
|
try {
|
||||||
if (await datastore.has(selfKey)) {
|
peerId = await chain.exportPeerId('myKey')
|
||||||
// load the peer id from the keychain
|
} catch (err) {
|
||||||
peerId = await chain.exportPeerId('self')
|
await chain.createKey('myKey', 'RSA', 4096)
|
||||||
} else {
|
|
||||||
// await chain.createKey('myKey', 'RSA', 4096)
|
|
||||||
peerId = await chain.exportPeerId('myKey')
|
peerId = await chain.exportPeerId('myKey')
|
||||||
}
|
}
|
||||||
console.log('Created peer ID: ', peerId)
|
|
||||||
|
|
||||||
// Configure services
|
// Configure services
|
||||||
const services = {
|
const services = {
|
||||||
@@ -144,29 +140,6 @@ class IpfsAdapter {
|
|||||||
console.log('Helia (IPFS) node IS NOT configured as Circuit Relay')
|
console.log('Helia (IPFS) node IS NOT configured as Circuit Relay')
|
||||||
}
|
}
|
||||||
|
|
||||||
// const bootstrapList = [
|
|
||||||
// //
|
|
||||||
// // // launchpad-p2wdb-service (Launchpad pinning service)
|
|
||||||
// // '/ip4/137.184.13.92/tcp/4001/p2p/12D3KooWPpBXhhAeoCZCGuQ3KR4xwHzzvtP57f6zLmo8P7ZFBJFE',
|
|
||||||
// //
|
|
||||||
// // // PSFoundation.info metrics
|
|
||||||
// // '/ip4/5.161.72.148/tcp/4001/p2p/12D3KooWDL1kPixc6hcT4s7teWGufrxXmZFD1kPeGdDrsKgYrFUt',
|
|
||||||
// //
|
|
||||||
// // // PSFoundation.info P2WDB
|
|
||||||
// // '/ip4/5.161.72.148/tcp/4101/p2p/12D3KooWHz1sRB94EEVRQRJvUX9MyRm3xhr4QSyCoJbTdu2AYheq',
|
|
||||||
// //
|
|
||||||
// // // TokenTiger.com backup P2WDB
|
|
||||||
// // '/ip4/161.35.99.207/tcp/4001/p2p/12D3KooWDtj9cfj1SKuLbDNKvKRKSsGN8qivq9M8CYpLPDpcD5pu',
|
|
||||||
// //
|
|
||||||
// // // helia-p2wdb-dev-server-01 prototype P2WDB server using Helia (Token Tiger)
|
|
||||||
// // '/ip4/137.184.93.145/tcp/4001/p2p/12D3KooWGZCpD5Ue3CJCBBEKowcuKEgeVKbTM7VMbJ8xm1bqST1j',
|
|
||||||
// //
|
|
||||||
// // // helia-p2wdb-dev-server-01 prototype P2WDB server using Helia (FullStack.cash)
|
|
||||||
// // '/ip4/78.46.129.7/tcp/7001/p2p/12D3KooWRqe7TwTj8apPxmpPqPgHiv7qv5YBJTo1VeQ7zrdyA2HN'
|
|
||||||
// ]
|
|
||||||
// bootstrapList = bootstrapList.concat(this.config.bootstrapRelays)
|
|
||||||
// console.log('bootstrapList: ', bootstrapList)
|
|
||||||
|
|
||||||
// libp2p is the networking layer that underpins Helia
|
// libp2p is the networking layer that underpins Helia
|
||||||
const libp2p = await this.createLibp2p({
|
const libp2p = await this.createLibp2p({
|
||||||
peerId,
|
peerId,
|
||||||
@@ -191,20 +164,9 @@ class IpfsAdapter {
|
|||||||
streamMuxers: [
|
streamMuxers: [
|
||||||
yamux()
|
yamux()
|
||||||
],
|
],
|
||||||
// peerDiscovery: [
|
|
||||||
// bootstrap({
|
|
||||||
// list: bootstrapList
|
|
||||||
// })
|
|
||||||
// ],
|
|
||||||
services
|
services
|
||||||
})
|
})
|
||||||
|
|
||||||
// Save the identity if it was newly created.
|
|
||||||
if (peerId != null && !await datastore.has(selfKey)) {
|
|
||||||
console.log(`Saving key for peer ID ${libp2p.peerId}`)
|
|
||||||
// a new PeerId would have been generated so store it in the keychain for next time
|
|
||||||
await chain.importPeer('self', libp2p.peerId)
|
|
||||||
}
|
|
||||||
// create a Helia node
|
// create a Helia node
|
||||||
const helia = await createHelia({
|
const helia = await createHelia({
|
||||||
blockstore,
|
blockstore,
|
||||||
|
|||||||
Reference in New Issue
Block a user