diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 8f7ad60..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.gitignore b/.gitignore index 82d30cc..abb250e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ node_modules/ + +\.DS_Store diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 73b7a5c..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "node", - "request": "launch", - "name": "Launch Program", - "program": "${workspaceFolder}/index.js" - } - ] -} \ No newline at end of file diff --git a/Documentation/.DS_Store b/Documentation/.DS_Store new file mode 100644 index 0000000..40af1ef Binary files /dev/null and b/Documentation/.DS_Store differ diff --git a/Project Start.png b/Documentation/Project Start.png similarity index 100% rename from Project Start.png rename to Documentation/Project Start.png diff --git a/mongoModels/participant.js b/Schemas/participant.js similarity index 100% rename from mongoModels/participant.js rename to Schemas/participant.js diff --git a/mongoModels/transaction.js b/Schemas/transaction.js similarity index 100% rename from mongoModels/transaction.js rename to Schemas/transaction.js diff --git a/mongoModels/wallet.js b/Schemas/wallet.js similarity index 100% rename from mongoModels/wallet.js rename to Schemas/wallet.js diff --git a/composer-logs/trace_20171102-215144-143.log b/composer-logs/trace_20171102-215144-143.log new file mode 100644 index 0000000..e60505f --- /dev/null +++ b/composer-logs/trace_20171102-215144-143.log @@ -0,0 +1,4 @@ +2017-11-01T03:51:46.079Z ERROR HLFConnectionManager :fabric-client() [client-utils.js]: sendPeersProposal - Promise is rejected: Error: chaincode error (status: 500, message: Error: The current identity must be activated (ACTIVATION_REQUIRED)) + at /Users/a01334390/Documents/Git Projects/Lyra/node_modules/fabric-client/node_modules/grpc/src/node/src/client.js:434:17 {}$ +2017-11-01T03:51:46.080Z ERROR HLFConnection :queryChainCode() {"message":"Error trying to query business network. Error: chaincode error (status: 500, message: Error: The current identity must be activated (ACTIVATION_REQUIRED))","stack":"Error: Error trying to query business network. Error: chaincode error (status: 500, message: Error: The current identity must be activated (ACTIVATION_REQUIRED))\n at channel.queryByChaincode.then.catch (/Users/a01334390/Documents/Git Projects/Lyra/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:749:34)\n at "}$ +2017-11-01T03:51:46.080Z ERROR HLFConnection :ping() {"message":"Error trying to ping. Error: Error trying to query business network. Error: chaincode error (status: 500, message: Error: The current identity must be activated (ACTIVATION_REQUIRED))","stack":"Error: Error trying to ping. Error: Error trying to query business network. Error: chaincode error (status: 500, message: Error: The current identity must be activated (ACTIVATION_REQUIRED))\n at _checkRuntimeVersions.then.catch (/Users/a01334390/Documents/Git Projects/Lyra/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:663:34)\n at "}$ diff --git a/config/default.json b/config/default.json index df47247..d014066 100755 --- a/config/default.json +++ b/config/default.json @@ -6,7 +6,6 @@ "connectionProfile": "hlfv1" }, "mongo-connection": { - "mongoURI": "mongodb://localhost:27017/", - "mongoDatabase": "lyra" + "mongoURI": "mongodb://localhost:27017/Lyra" } } \ No newline at end of file diff --git a/index.js b/index.js index 1af0a36..e02914e 100755 --- a/index.js +++ b/index.js @@ -7,7 +7,7 @@ var figlet = require('figlet'); var inquirer = require('inquirer'); //Hyperledger Fabric Code And Connectors -var hyper = require('./blockchainManager'); +var hyper = require('./lib/blockchainManager'); var jsond = require('./package'); var index = require('.'); diff --git a/lib/.DS_Store b/lib/.DS_Store index 1d5d145..7d062cd 100644 Binary files a/lib/.DS_Store and b/lib/.DS_Store differ diff --git a/blockchainManager.js b/lib/blockchainManager.js similarity index 88% rename from blockchainManager.js rename to lib/blockchainManager.js index f095524..230760e 100644 --- a/blockchainManager.js +++ b/lib/blockchainManager.js @@ -1,12 +1,4 @@ 'use strict'; -/* -/ ======== Blockchain Manager ========= -/ This file does all the Blockchain related actions for Lyra -/ As of now, it works with the latest version of Hyperledger -/ Made by Aabo Technologies © 2017 - Servers Division -/ Last revised > October 23rd, 2017 @ 12:00 p.m. by A01334390 -/ ======== ======== ======== ======== -*/ // ______ __ ______ ______ __ __ ______ __ __ ______ __ __ __ // /\ == \/\ \ /\ __ \/\ ___\/\ \/ / /\ ___\/\ \_\ \/\ __ \/\ \/\ "-.\ \ @@ -47,7 +39,7 @@ class BlockchainManager { } /**@name init - * @author Fernando Martin Garcia Del Angel - A01334390 + * @author Aabo Technologies © 2017 - Server's team * @description Initializes the chaincode by making a connection to the composer runtime * @returns {Promise} A promise whose fullfillment means the initialization has completed */ @@ -64,7 +56,7 @@ class BlockchainManager { } /**@name CheckRegisteredAssets - * @author Fernando Martin Garcia Del Angel - A01334390 + * @author Aabo Technologies © 2017 - Server's team * @description Lists all registered assets in the Blockchain * @returns {Promise} */ @@ -94,7 +86,7 @@ class BlockchainManager { } /**@name CheckRegisteredParticipants - * @author Fernando Martin Garcia Del Angel - A01334390 + * @author Aabo Technologies © 2017 - Server's team * @description Lists all registered participants on the Blockchain * @returns {Promise} A promise whose fullfillment means the participants have been registered */ @@ -122,7 +114,7 @@ class BlockchainManager { } /**@name InitializatorDaemon - * @author Fernando Martin Garcia Del Angel - A01334390 + * @author Aabo Technologies © 2017 - Server's team * @description Initializes the Participants and Wallets on the network * @param {Number} clientSeed is the seed for the client * @param {Number} walletSeed is the seed for the wallet @@ -172,7 +164,7 @@ class BlockchainManager { } /**@name ShowCurrentAssets - * @author Fernando Martin Garcia Del Angel - A01334390 + * @author Aabo Technologies © 2017 - Server's team * @description Lists all current wallets on the Ledger * @returns {Promise} A promise whose fullfillment means all wallets have succesfully been listed */ @@ -212,7 +204,7 @@ class BlockchainManager { } /**@name ShowCurrentParticipants - * @author Fernando Martin Garcia Del Angel - A01334390 + * @author Aabo Technologies © 2017 - Server's team * @description Lists all current Participants on the ledger * @returns {Promise} A promise whose fullfillment means all participants have succesfully been listed */ @@ -250,7 +242,7 @@ class BlockchainManager { } /**@name MakeTransactionMethod - * @author Fernando Martin Garcia Del Angel - A01334390 + * @author Aabo Technologies © 2017 - Server's team * @description This method makes a single transaction over the ledger * @param {String} fromID is the md5 related to a Client's wallet on the ledger who's sending money * @param {String} toID is the md5 related to a Client's wallet on the ledger who's receiving money @@ -306,6 +298,7 @@ class BlockchainManager { } /**@name TransactionSchedule + * @author Aabo Technologies © 2017 - Server's team * @description Creates a transaction plan for the testing phase * @param {Number} amount of transactions to simulate * @returns {JSON} document that includes the schedule @@ -336,6 +329,18 @@ class BlockchainManager { }); } + /**@name profilingTime + * @author Aabo Technologies © 2017 - Server's team + * @description Profiles the time that a process took and shows some statistics + * @param {Number} timeStart when the process started + * @param {Number} timeEnd when the process ended + * @param {Number} simTrax is the amount of transactions that were executed + * @param {String} whereFrom where the method is called from + * @returns {Number} executedTime is the overall execution time + * @returns {Number} opTime is the time it took for every operation to run + * @returns {Number} opsPerDay is the amount of operations that could be done in one day + */ + profilingTime(timeStart,timeEnd,simTrax,whereFrom){ const METHOD = 'profilingTime'; @@ -370,8 +375,10 @@ class BlockchainManager { } - /** @description Runs the Check Registered Assets command - * @returns {Promise} resolved when the action is completed + /**@name registeredAssets + * @author Aabo Technologies © 2017 - Server's team + * @description Runs the Check Registered Assets command + * @returns {Promise} resolved when the action is completed */ static registeredAssets() { @@ -389,7 +396,9 @@ class BlockchainManager { }); } - /**@description Runs the Check Registered Participants command + /**@name registeredParticipants + * @author Aabo Technologies © 2017 - Server's team + * @description Runs the Check Registered Participants command * @returns {Promise} resolved when the action is completed */ @@ -408,7 +417,9 @@ class BlockchainManager { }); } - /**@description Runs the Initializator Daemon + /**@name initializeLedger + * @author Aabo Technologies © 2017 - Server's team + * @description Runs the Initializator Daemon * @param {Number} clientSeed is the seed for the client * @param {Number} walletSeed is the seed for the wallet * @param {Number} bottom is the least amount of money a wallet can have @@ -431,7 +442,9 @@ class BlockchainManager { }); } - /**@description Runs the Show Current Assets method + /**@name assetsOnLedger + * @author Aabo Technologies © 2017 - Server's team + * @description Runs the Show Current Assets method * @returns {Promise} A promise whose fullfillment means all wallets have succesfully been listed */ @@ -450,7 +463,9 @@ class BlockchainManager { }); } - /**@description Runs the Show Current Participants method + /**@name participantsOnLedger + * @author Aabo Technologies © 2017 - Server's team + * @description Runs the Show Current Participants method * @returns {Promise} A promise whose fullfillment means all participants have succesfully been listed */ @@ -469,7 +484,9 @@ class BlockchainManager { }); } - /**@description Runs the make transaction method + /**@name transfer + * @author Aabo Technologies © 2017 - Server's team + * @description Executes the make transaction method * @param {String} fromID is the md5 related to a Client's wallet on the ledger who's sending money * @param {String} toID is the md5 related to a Client's wallet on the ledger who's receiving money * @param {Number} funds is an amount of money to be sent from one wallet to the other @@ -491,7 +508,9 @@ class BlockchainManager { }); } - /**@description Create batch accounts and wallets + /**@name batchAccount + * @author Aabo Technologies © 2017 - Server's team + * @description Create batch accounts and wallets * @param {Number} clientSeed is the seed for the client * @param {Number} walletSeed is the seed for the wallet * @param {Number} bottom is the least amount of money a wallet can have @@ -525,7 +544,9 @@ class BlockchainManager { }) } - /**@description Executes the Transaction Schedule Command + /**@name getTransactionSchedule + * @author Aabo Technologies © 2017 - Server's team + * @description Executes the Transaction Schedule Command * @param {Number} amount of transactions to simulate * @returns {JSON} document that includes the schedule */ @@ -545,7 +566,7 @@ class BlockchainManager { }); } /**@name TransactionCannon - * @author Fernando Martin Garcia Del Angel + * @author Aabo Technologies © 2017 - Server's team * @description This is it. This launches as many transactions as possible, it doesn't care about your feelings * @param {Number} amount of transactions to make * @returns {Promise} that it will try it's best, don't sweat it @@ -580,6 +601,17 @@ class BlockchainManager { }); } + /**@name isLedgerStateCorrect + * @author Aabo Technologies © 2017 - Server's team + * @description Checks if transactions within the ledger were indeed executed correctly or not + * @param {Array} Schedule which includes the list of transactions made on the ledger + * @returns {Boolean} if the ledger is indeed synced or not + */ + + static isLedgerStateCorrect(schedule){ + + } + } module.exports = BlockchainManager; \ No newline at end of file diff --git a/mongoManager.js b/lib/mongoManager.js similarity index 97% rename from mongoManager.js rename to lib/mongoManager.js index 70bd73e..61c97b0 100644 --- a/mongoManager.js +++ b/lib/mongoManager.js @@ -24,20 +24,24 @@ var config = require('config').get('mongo-connection'); let connectionURI = config.get('mongoURI'); let databaseName = config.get('mongoDatabase'); -/** Get the data models */ +/** Get the Schemas */ var { Participant -} = require('./mongoModels/participant'); +} = require('../Schemas/participant'); var { Transaction -} = require('./mongoModels/transaction'); +} = require('../Schemas/transaction'); var { Wallet -} = require('./mongoModels/wallet'); +} = require('../Schemas/wallet'); + +/** Get the configuration for the database location */ +var config = require('config').get('mongo-connection'); +let mongoURI = config.get("mongoURI"); //Start the connection to Mongoose mongoose.Promise = global.Promise; -mongoose.connect('mongodb://localhost:27017/Lyra', { +mongoose.connect(mongoURI, { useMongoClient: true }); diff --git a/package.json b/package.json index bfafad4..ee264a6 100755 --- a/package.json +++ b/package.json @@ -1,11 +1,10 @@ { "name": "lyra-cli", - "version": "0.8.7", + "version": "0.8.8", "description": "Hyperledger Composer Super Fast Network", - "author": "Aabo Technologies© 2017", + "author": "Aabo Technologies© 2017 - Server's Team", "main": "index.js", "scripts": { - "preinstall": "composer --version || { echo 'Please first run npm install -g composer-cli'; exit 1;} ", "first-step": "scripts/lyrainstaller-1.sh", "second-step": "scripts/lyrainstaller-2.sh", "test": "echo 'Lyra-cli can be installed now'", @@ -15,7 +14,6 @@ "deployNetwork": "scripts/initHyper.sh", "restart": "scripts/restartAll.sh", "pingNetwork": "composer network ping -n lyra-cli -p hlfv1 -i admin -s adminpw", - "install": "scripts/download-hyperledger.sh && scripts/start-hyperledger.sh && npm run deployNetwork", "start": "node index.js" }, "keywords": [