From b777153d04cc4f781bce16d68e7e232a7574053a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Mart=C3=ADn=20Garc=C3=ADa=20Del=20Angel?= Date: Tue, 31 Oct 2017 21:59:39 -0600 Subject: [PATCH] Changes on the Project's Structure This commit includes the following change on the project's structure: - The mongoModels folder is now called Schemas - The BlockchainManager and MongoManager are now in the lib folder for better consistency - The last needed methods are already documented into BlockchainManager - The config file was reduced to only have the MongoURI parameter - MongoManager now accepts the MongoURI parameter from the configuration file - The Documentation folder was created and the screenshot was moved into it - The vscode folder has now been deleted - The versioning now is made according to the Semantic Versioning document (can be found on the README) --- .DS_Store | Bin 10244 -> 0 bytes .gitignore | 2 + .vscode/launch.json | 14 --- Documentation/.DS_Store | Bin 0 -> 6148 bytes .../Project Start.png | Bin {mongoModels => Schemas}/participant.js | 0 {mongoModels => Schemas}/transaction.js | 0 {mongoModels => Schemas}/wallet.js | 0 composer-logs/trace_20171102-215144-143.log | 4 + config/default.json | 3 +- index.js | 2 +- lib/.DS_Store | Bin 6148 -> 6148 bytes .../blockchainManager.js | 82 ++++++++++++------ mongoManager.js => lib/mongoManager.js | 14 +-- package.json | 6 +- 15 files changed, 76 insertions(+), 51 deletions(-) delete mode 100644 .DS_Store delete mode 100644 .vscode/launch.json create mode 100644 Documentation/.DS_Store rename Project Start.png => Documentation/Project Start.png (100%) rename {mongoModels => Schemas}/participant.js (100%) rename {mongoModels => Schemas}/transaction.js (100%) rename {mongoModels => Schemas}/wallet.js (100%) create mode 100644 composer-logs/trace_20171102-215144-143.log rename blockchainManager.js => lib/blockchainManager.js (88%) rename mongoManager.js => lib/mongoManager.js (97%) diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 8f7ad607fb0d44457a55b049bbefad6576d2e7a7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10244 zcmeHM&u<$=6n>M2)=nGZq)GYm9SZ zZkmRmT=)YxAwXO}LMnGoNC3MH2PmYD!(+lar7P_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rm(C73u zeNVsAA9SDfvSG=SNtR(#EX(HD3+$3)%WKl}gLyJEwjp+O9qf|tbL$mx{(k}N-{$}S zUA#oq5dskc|7QeP_iTPPhaS}9vT$d_S-XPk1}>3=-nJ{H2{L&c4=Io1aU+i7C2QhY n3T2s4&WZx$wkuIW`q%#q=%53|X#cB|k!ifgGuGIlU`c-*y!IUTct?lVLH#3R zJ6z!nTfE$Dy7g+)t(fhPdPBSX2yi7x0VyB_q<|EV0>>-hy_cAtCCf_zDIf*D74Yvv zp*h#aeR6y{=wbvQPZ$nx9kT?vcz|3R_sNV9mZjt@wKif{mNQ;jUTxebXE`iR=6%}9 z)+Q8-(-|+34y(!XQa}m}6*$f9%=`Z>?U(s~Sfrg4kOKco0h=tAi#cDZ_14kLd9N+B s2ig~y8|ie>ipkN6x$#zf@guMJn%8UNJ~_%6k8-kp1Y8$E3jBovpJkIB4gdfE literal 0 HcmV?d00001 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 1d5d14534a8519547483d0a07e6c4d6efe16ccdb..7d062cdbdb58c6d2f4d2a8649d660b37b9ac2167 100644 GIT binary patch delta 216 zcmZoMXfc=|#>B`mu~2NHo}wr-0|Nsi1A_nqLpDP)Lk2@4LncGs#DmK{K@uViNenp* z`9KLINd{k_qC6l@XGmozV$fsAVkq{^$xlwo$xj065%`Y+7#Jq@7+dl)CJzu~2NHo}wrt0|NsP3otMwGw3m7F%)~| 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": [