diff --git a/config/env/common.js b/config/env/common.js index c74d9f6..1f79500 100644 --- a/config/env/common.js +++ b/config/env/common.js @@ -27,7 +27,7 @@ const ipfsCoordName = process.env.COORD_NAME export default { // Configure TCP port. - port: process.env.PORT || 5005, + port: process.env.PORT || 5015, // Password for HTML UI that displays logs. logPass: 'test', diff --git a/package-lock.json b/package-lock.json index 1188898..4ede96b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,7 +27,6 @@ "glob": "7.1.6", "helia": "2.1.0", "helia-coord": "1.5.6", - "ipfs-unixfs-exporter": "13.5.0", "jsonrpc-lite": "2.2.0", "jsonwebtoken": "8.5.1", "jwt-bch-lib": "1.3.0", diff --git a/package.json b/package.json index 01ea6e2..29bd76a 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,6 @@ "glob": "7.1.6", "helia": "2.1.0", "helia-coord": "1.5.6", - "ipfs-unixfs-exporter": "13.5.0", "jsonrpc-lite": "2.2.0", "jsonwebtoken": "8.5.1", "jwt-bch-lib": "1.3.0", diff --git a/src/use-cases/ipfs-use-cases.js b/src/use-cases/ipfs-use-cases.js index 8c40c07..391827b 100644 --- a/src/use-cases/ipfs-use-cases.js +++ b/src/use-cases/ipfs-use-cases.js @@ -6,7 +6,7 @@ // import Wallet from 'minimal-slp-wallet' // import { CID } from 'multiformats' // import RetryQueue from '@chris.troutner/retry-queue' -import { exporter } from 'ipfs-unixfs-exporter' +// import { exporter } from 'ipfs-unixfs-exporter' import { Duplex } from 'stream' // Local libraries @@ -26,11 +26,11 @@ class IpfsUseCases { } // Encapsulate dependencies - this.exporter = exporter + // this.exporter = exporter // Bind 'this' object to all class subfunctions. this.downloadCid = this.downloadCid.bind(this) - this.downloadCid2 = this.downloadCid2.bind(this) + // this.downloadCid2 = this.downloadCid2.bind(this) } // Download a pinned file, given its CID. @@ -81,56 +81,56 @@ class IpfsUseCases { } } - async downloadCid2 (inObj = {}) { - try { - const { cid } = inObj - - // console.log(`downloadFile() retrieving this CID: ${cid}, with fileName: ${fileName}, and path: ${path}`) - - const blockstore = this.adapters.ipfs.ipfs.blockstore - const entry = await this.exporter(cid, blockstore) - - console.info(entry.cid) // Qmqux - console.log('entry: ', entry) - // console.info(entry.unixfs.fileSize()) // 4 - - // const filePath = `${path}/${fileName}` - // console.log(`filePath: ${filePath}`) - // const writableStream = this.fs.createWriteStream(filePath) - // - // writableStream.on('error', this.writeStreamError) - // - // writableStream.on('finish', this.writeStreamFinished) - // - - const fileChunks = [] - for await (const buf of entry.content()) { - fileChunks.push(buf) - } - const fileBuf = Buffer.concat(fileChunks) - - // - // writableStream.end() - - // Convert the Buffer into a readable stream - const bufferToStream = (myBuffer) => { - const tmp = new Duplex() - tmp.push(myBuffer) - tmp.push(null) - return tmp - } - const readStream = bufferToStream(fileBuf) - - const filename = 'test.jpg' - - return { filename, readStream } - - // return { cid } - } catch (err) { - console.error('Error in ipfs-use-cases.js/downloadCid()') - throw err - } - } + // async downloadCid2 (inObj = {}) { + // try { + // const { cid } = inObj + // + // // console.log(`downloadFile() retrieving this CID: ${cid}, with fileName: ${fileName}, and path: ${path}`) + // + // const blockstore = this.adapters.ipfs.ipfs.blockstore + // const entry = await this.exporter(cid, blockstore) + // + // console.info(entry.cid) // Qmqux + // console.log('entry: ', entry) + // // console.info(entry.unixfs.fileSize()) // 4 + // + // // const filePath = `${path}/${fileName}` + // // console.log(`filePath: ${filePath}`) + // // const writableStream = this.fs.createWriteStream(filePath) + // // + // // writableStream.on('error', this.writeStreamError) + // // + // // writableStream.on('finish', this.writeStreamFinished) + // // + // + // const fileChunks = [] + // for await (const buf of entry.content()) { + // fileChunks.push(buf) + // } + // const fileBuf = Buffer.concat(fileChunks) + // + // // + // // writableStream.end() + // + // // Convert the Buffer into a readable stream + // const bufferToStream = (myBuffer) => { + // const tmp = new Duplex() + // tmp.push(myBuffer) + // tmp.push(null) + // return tmp + // } + // const readStream = bufferToStream(fileBuf) + // + // const filename = 'test.jpg' + // + // return { filename, readStream } + // + // // return { cid } + // } catch (err) { + // console.error('Error in ipfs-use-cases.js/downloadCid()') + // throw err + // } + // } } export default IpfsUseCases