Skip to content

Commit

Permalink
Finished functions isLedgerSynced
Browse files Browse the repository at this point in the history
Moving into bug fixes, ora spinners and first stable release
  • Loading branch information
martin-headspace committed Nov 1, 2017
1 parent 8412168 commit 1a698cc
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 23 deletions.
24 changes: 16 additions & 8 deletions lib/blockchainManager.js → blockchainManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -599,13 +599,15 @@ class BlockchainManager {
//**Set up the time start */
let timeStart;
let timeEnd;
let schedule;
//**Set up the time end */
return bm.init()
.then(() => {
return bm.transactionSchedule(simTrax);
})
.then((result) => {
let cannonBalls = [];
schedule = result;
for (let i = 0; i < result.length; i++) {
cannonBalls.push(bm.makeTransaction(result[i].from, result[i].to, result[i].funds));
}
Expand All @@ -617,6 +619,9 @@ class BlockchainManager {
bm.profilingTime(timeStart, timeEnd, simTrax, 'tx');
console.log('Transaction Cannon Finished');
})
.then(() => {
return schedule;
})
.catch(function (error) {
console.log('An error occured: ', chalk.bold.red(error));
process.exit(1);
Expand All @@ -634,20 +639,23 @@ class BlockchainManager {
let bm = new BlockchainManager();
let modState;
/** Get the state of the database */
console.log(schedule);
return mdb.getAllAst()
return mongo.getAllAst()
.then((result) => {
let arr = result;
for (let i = 0; i < schedule.length; i++) {
for (let x = 0; x < result.length; x++) {
if (result[x].id == schedule[i].from) {
result[x].balance -= schedule[i].funds;
for (let x = 0; x < arr.length; x++) {
if (arr[x].id == schedule[i].from) {
arr[x].balance = arr[x].balance - schedule[i].funds;
}
if (result[x].id == schedule[i].to) {
result[x].balance += schedule[i].funds;
if (arr[x].id == schedule[i].to) {
arr[x].balance = arr[x].balance + schedule[i].funds;
}
}
}
modState = result;
modState = arr;
return bm.init();
})
.then(() => {
return bm.rawAssetsOnLedger();
})
.then((rawLedger) => {
Expand Down
4 changes: 4 additions & 0 deletions composer-logs/trace_20171102-122014-555.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
2017-11-01T18:20:16.049Z 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-01T18:20:16.050Z 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-01T18:20:16.050Z 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>"}$
4 changes: 4 additions & 0 deletions composer-logs/trace_20171102-122615-117.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
2017-11-01T18:26:16.584Z 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-01T18:26:16.585Z 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-01T18:26:16.585Z 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>"}$
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,15 @@ switch (yargs._[0]) {
case 'cannon':
console.log(chalk.bold.cyan('Lyra CLI App'), chalk.bold.green('Made by Aabo Technologies © 2017'));
hyper.transactionCannon(yargs.transactions)
.then(() => {
.then((result) => {
return hyper.isLedgerStateCorrect(result);
})
.then((result) => {
if (result) {
console.log(chalk.bold.green('The ledger is indeed synced'));
} else {
console.log(chalk.bold.red('The ledger is not synced'));
}
process.exit(0);
})
.catch(function (error) {
Expand Down
17 changes: 3 additions & 14 deletions lib/mongoManager.js → mongoManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ let connectionURI = config.get('mongoURI');
/** Get the Schemas */
var {
Participant
} = require('../Schemas/participant');
} = require('./Schemas/participant');
var {
Transaction
} = require('../Schemas/transaction');
} = require('./Schemas/transaction');
var {
Wallet
} = require('../Schemas/wallet');
} = require('./Schemas/wallet');

//Start the connection to Mongoose
mongoose.Promise = global.Promise;
Expand All @@ -40,17 +40,6 @@ mongoose.connect(connectionURI, {
});

class MongoManager {
constructor() {
mongoose.connect(connectionURI, {
useMongoClient: true
})
.then((result)=>{
console.log('Connected to MongoDB');
})
.catch(function(error){
console.log('an error ocurred');
});
}

/**@description Persists a transaction into MongoDB
* @param {JSON} a JSON Document with transaction information
Expand Down

0 comments on commit 1a698cc

Please sign in to comment.