Skip to content

Commit

Permalink
Changes on the Project's Structure
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
martin-headspace committed Nov 1, 2017
1 parent adf3325 commit b777153
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 51 deletions.
Binary file removed .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@

node_modules/

\.DS_Store
14 changes: 0 additions & 14 deletions .vscode/launch.json

This file was deleted.

Binary file added Documentation/.DS_Store
Binary file not shown.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions composer-logs/trace_20171102-215144-143.log
Original file line number Diff line number Diff line change
@@ -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 <anonymous>"}$
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 <anonymous>"}$
3 changes: 1 addition & 2 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"connectionProfile": "hlfv1"
},
"mongo-connection": {
"mongoURI": "mongodb://localhost:27017/",
"mongoDatabase": "lyra"
"mongoURI": "mongodb://localhost:27017/Lyra"
}
}
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('.');

Expand Down
Binary file modified lib/.DS_Store
Binary file not shown.
82 changes: 57 additions & 25 deletions blockchainManager.js → lib/blockchainManager.js
Original file line number Diff line number Diff line change
@@ -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
/ ======== ======== ======== ========
*/

// ______ __ ______ ______ __ __ ______ __ __ ______ __ __ __
// /\ == \/\ \ /\ __ \/\ ___\/\ \/ / /\ ___\/\ \_\ \/\ __ \/\ \/\ "-.\ \
Expand Down Expand Up @@ -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
*/
Expand All @@ -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}
*/
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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';

Expand Down Expand Up @@ -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() {
Expand All @@ -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
*/

Expand All @@ -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
Expand All @@ -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
*/

Expand All @@ -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
*/

Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
*/
Expand All @@ -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
Expand Down Expand Up @@ -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;
14 changes: 9 additions & 5 deletions mongoManager.js → lib/mongoManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});

Expand Down
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -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'",
Expand All @@ -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": [
Expand Down

0 comments on commit b777153

Please sign in to comment.