From e89d22919675b970b109a2f3f38ca6edb20768ca Mon Sep 17 00:00:00 2001 From: David McFadzean Date: Wed, 27 Mar 2024 12:57:12 -0400 Subject: [PATCH] Removed deprecated code --- gatekeeper.js | 12 --------- hyperswarm-mediator.js | 4 +-- ipfs.js | 55 ------------------------------------------ 3 files changed, 1 insertion(+), 70 deletions(-) delete mode 100644 ipfs.js diff --git a/gatekeeper.js b/gatekeeper.js index a600bc58..18ea5752 100644 --- a/gatekeeper.js +++ b/gatekeeper.js @@ -3,9 +3,6 @@ import { base58btc } from 'multiformats/bases/base58'; import fs from 'fs'; import canonicalize from 'canonicalize'; import { createHelia } from 'helia'; -import { FsBlockstore } from 'blockstore-fs'; -import { performance } from 'perf_hooks'; - import * as cipher from './cipher.js'; import config from './config.js'; @@ -84,8 +81,6 @@ let ipfs = null; export async function start() { if (!ipfs) { - const blockstore = new FsBlockstore(`${dataFolder}/ipfs`); - //helia = await createHelia({ blockstore }); helia = await createHelia(); ipfs = json(helia); } @@ -120,13 +115,6 @@ function submitTxn(did, registry, operation, time, ordinal = 0) { } export async function anchorSeed(seed) { - // let t0, t1; - - // t0 = performance.now(); - // const cid = await ipfs.add(JSON.parse(canonicalize(seed))); - // t1 = performance.now(); - // console.log("Adding seed to IPFS took " + (t1 - t0) + " milliseconds."); - const cid = await ipfs.add(JSON.parse(canonicalize(seed))); const did = `${config.didPrefix}:${cid.toString(base58btc)}`; const db = loadDb(); diff --git a/hyperswarm-mediator.js b/hyperswarm-mediator.js index ca86ccb8..de54ff0a 100644 --- a/hyperswarm-mediator.js +++ b/hyperswarm-mediator.js @@ -4,12 +4,10 @@ import b4a from 'b4a'; import { sha256 } from '@noble/hashes/sha256'; import fs from 'fs'; import asyncLib from 'async'; - import * as gatekeeper from './gatekeeper-sdk.js'; import * as cipher from './cipher.js'; -import config from './config.js'; - import { EventEmitter } from 'events'; + EventEmitter.defaultMaxListeners = 100; const protocol = '/MDIP/v22.03.21'; diff --git a/ipfs.js b/ipfs.js deleted file mode 100644 index 160008a6..00000000 --- a/ipfs.js +++ /dev/null @@ -1,55 +0,0 @@ -import { noise } from '@chainsafe/libp2p-noise' -import { yamux } from '@chainsafe/libp2p-yamux' -import { bootstrap } from '@libp2p/bootstrap' -import { identify } from '@libp2p/identify' -import { tcp } from '@libp2p/tcp' -import { createHelia } from 'helia'; -import { FsBlockstore } from 'blockstore-fs'; -import { MemoryDatastore } from 'datastore-core' -import { createLibp2p } from 'libp2p' - -export async function createNode() { - // the blockstore is where we store the blocks that make up files - const blockstore = new FsBlockstore('./ipfs'); - - // application-specific data lives in the datastore - const datastore = new MemoryDatastore() - - // libp2p is the networking layer that underpins Helia - const libp2p = await createLibp2p({ - datastore, - addresses: { - listen: [ - '/ip4/127.0.0.1/tcp/0' - ] - }, - transports: [ - tcp() - ], - connectionEncryption: [ - noise() - ], - streamMuxers: [ - yamux() - ], - peerDiscovery: [ - bootstrap({ - list: [ - '/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN', - '/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa', - '/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb', - '/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt' - ] - }) - ], - services: { - identify: identify() - } - }) - - return await createHelia({ - datastore, - blockstore, - libp2p - }) -}