diff --git a/batnode.js b/batnode.js index 74d13e0..5e733db 100644 --- a/batnode.js +++ b/batnode.js @@ -248,7 +248,7 @@ class BatNode { this.kadenceNode.iterativeFindValue(shardId, (err, value, responder) => { let kadNodeTarget = value.value; - this.kadenceNode.getOtherBatNodeContact(kadNodeTarget, (err, batNode) => { + this.kadenceNode.getOtherBatNodeContact(kadNodeTarget, (error, batNode) => { this.auditShardData(batNode, shards, shaIdx, shardDupIdx, shardAuditData) }) }) diff --git a/seednode/seed.js b/seednode/seed.js index 28b7d15..59ee764 100644 --- a/seednode/seed.js +++ b/seednode/seed.js @@ -41,7 +41,7 @@ publicIp.v4().then(ip => { console.log("received data: ", receivedData) if (receivedData.messageType === "RETRIEVE_FILE") { - batNode.readFile(`./hosted/${receivedData.fileName}`, (error, data) => { + batNode.readFile(`./hosted/${receivedData.fileName}`, (err, data) => { serverConnection.write(data) }) } else if (receivedData.messageType === "STORE_FILE"){ @@ -49,15 +49,15 @@ publicIp.v4().then(ip => { batNode.kadenceNode.iterativeStore(fileName, [batNode.kadenceNode.identity.toString(), batNode.kadenceNode.contact], (err, stored) => { console.log('nodes who stored this value: ', stored) let fileContent = new Buffer(receivedData.fileContent) - batNode.writeFile(`./hosted/${fileName}`, fileContent, (err) => { - if (err) { - throw err; + batNode.writeFile(`./hosted/${fileName}`, fileContent, (writeErr) => { + if (writeErr) { + throw writeErr; } serverConnection.write(JSON.stringify({messageType: "SUCCESS"})) }) }) } else if (receivedData.messageType === "AUDIT_FILE") { - fs.readFile(`./hosted/${receivedData.fileName}`, (error, data) => { + fs.readFile(`./hosted/${receivedData.fileName}`, (err, data) => { const shardSha1 = fileUtils.sha1HashData(data); serverConnection.write(shardSha1); }); diff --git a/start.js b/start.js index 944c240..223942f 100644 --- a/start.js +++ b/start.js @@ -14,7 +14,7 @@ const fs = require('fs'); const fileUtils = require('./utils/file').fileSystem; publicIp.v4().then(ip => { - kademliaNode = new kad.KademliaNode({ + const kademliaNode = new kad.KademliaNode({ transport: new kad.HTTPTransport(), storage: levelup(encoding(leveldown('./dbbb'))), contact: {hostname: ip, port: kadNodePort} @@ -34,7 +34,7 @@ publicIp.v4().then(ip => { console.log("received data: ", receivedData) if (receivedData.messageType === "RETRIEVE_FILE") { - batNode.readFile(`./hosted/${receivedData.fileName}`, (error, data) => { + batNode.readFile(`./hosted/${receivedData.fileName}`, (err, data) => { serverConnection.write(data) }) } else if (receivedData.messageType === "STORE_FILE"){ @@ -42,15 +42,15 @@ publicIp.v4().then(ip => { batNode.kadenceNode.iterativeStore(fileName, [batNode.kadenceNode.identity.toString(), batNode.kadenceNode.contact], (err, stored) => { console.log('nodes who stored this value: ', stored) let fileContent = new Buffer(receivedData.fileContent) - batNode.writeFile(`./hosted/${fileName}`, fileContent, (err) => { - if (err) { - throw err; + batNode.writeFile(`./hosted/${fileName}`, fileContent, (writeErr) => { + if (writeErr) { + throw writeErr; } serverConnection.write(JSON.stringify({messageType: "SUCCESS"})) }) }) } else if (receivedData.messageType === "AUDIT_FILE") { - fs.readFile(`./hosted/${receivedData.fileName}`, (error, data) => { + fs.readFile(`./hosted/${receivedData.fileName}`, (err, data) => { const shardSha1 = fileUtils.sha1HashData(data); serverConnection.write(shardSha1); }); diff --git a/utils/file.js b/utils/file.js index 1392a59..dbb86a0 100644 --- a/utils/file.js +++ b/utils/file.js @@ -32,11 +32,11 @@ exports.fileSystem = (function(){ const fileData = fileSystem.createReadStream(filepath) const zip = zlib.createGzip() - const encrypt = crypto.createCipher(algorithm, privateKey) + const encryptStream = crypto.createCipher(algorithm, privateKey) const encryptedFileStore = fileSystem.createWriteStream(tmpPath) // read the file, zip it, encrypt it, and write it - fileData.pipe(zip).pipe(encrypt).pipe(encryptedFileStore).on('close', () => { + fileData.pipe(zip).pipe(encryptStream).pipe(encryptedFileStore).on('close', () => { if(callback) { callback(tmpPath) } @@ -47,11 +47,11 @@ exports.fileSystem = (function(){ const privateKey = dotenv.config().parsed.PRIVATE_KEY; const encryptedFileData = fileSystem.createReadStream(filepath) - const decrypt = crypto.createDecipher(algorithm, privateKey) + const decryptStream = crypto.createDecipher(algorithm, privateKey) const unzip = zlib.createGunzip() const writeStream = fileSystem.createWriteStream(tempPath) // - encryptedFileData.pipe(decrypt).pipe(unzip).pipe(writeStream) + encryptedFileData.pipe(decryptStream).pipe(unzip).pipe(writeStream) } const sha1Hash = (file) => { const fileData = fileSystem.readFileSync(file)