Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions benchmark/sinochain/config-local-duration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"blockchain": {
"type": "sinochain",
"config": "benchmark/sinochain/sinochain.json"
},
"test": {
"name": "sinochain test",
"description": "Sinochain test!",
"clients": {
"type": "local",
"unfinished": 30000,
"number": 2
},
"rounds": [
{
"label": "open-account",
"txDuration": [
180
],
"rateControl": [
{
"type": "fixed-rate",
"opts": {
"tps": 5000
}
}
],
"callback": "benchmark/sinochain/open.js"
}
]
},
"monitor": {
"type": [

],
"process": [
{
"command": "node",
"arguments": "local-client.js",
"multiOutput": "avg"
}
],
"interval": 10
}
}
45 changes: 45 additions & 0 deletions benchmark/sinochain/config-local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"blockchain": {
"type": "sinochain",
"config": "benchmark/sinochain/sinochain.json"
},
"test": {
"name": "sinochain test",
"description": "Sinochain test!",
"clients": {
"type": "local",
"unfinished": 30000,
"number": 2
},
"rounds": [
{
"label": "open-account",
"txNumber": [
100000
],
"rateControl": [
{
"type": "fixed-rate",
"opts": {
"tps": 10000
}
}
],
"callback": "benchmark/sinochain/open.js"
}
]
},
"monitor": {
"type": [

],
"process": [
{
"command": "node",
"arguments": "main.js",
"multiOutput": "avg"
}
],
"interval": 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,27 @@
"description": "Sinochain test!",
"clients": {
"type": "zookeeper",
"unfinished": 30000,
"zoo" : {
"server": "127.0.0.1:12181",
"clientsPerHost": 2
}
},
"rounds": [
{
"label": "create-account",
"label": "open-account",
"txDuration": [
60
180
],
"rateControl": [
{
"type": "fixed-rate",
"opts": {
"tps": 100
"tps": 5000
}
}
],
"callback": "benchmark/sinochain/create.js"
"callback": "benchmark/sinochain/open.js"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,27 @@
"description": "Sinochain test!",
"clients": {
"type": "zookeeper",
"unfinished": 30000,
"zoo" : {
"server": "127.0.0.1:12181",
"clientsPerHost": 2
}
},
"rounds": [
{
"label": "create-account",
"label": "open-account",
"txNumber": [
100
100000
],
"rateControl": [
{
"type": "fixed-rate",
"opts": {
"tps": 10
"tps": 10000
}
}
],
"callback": "benchmark/sinochain/create.js"
"callback": "benchmark/sinochain/open.js"
}
]
},
Expand Down
29 changes: 0 additions & 29 deletions benchmark/sinochain/create.js

This file was deleted.

2 changes: 1 addition & 1 deletion benchmark/sinochain/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function main() {
const fs = require('fs-extra');
let absConfigFile;
if(typeof configFile === 'undefined') {
absConfigFile = path.join(__dirname, 'config.json');
absConfigFile = path.join(__dirname, 'config-local.json');
}
else {
absConfigFile = path.join(__dirname, configFile);
Expand Down
65 changes: 65 additions & 0 deletions benchmark/sinochain/open.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
'use strict';

module.exports.info = 'open account';

let bc, ctx;

let seqnum;

module.exports.init = function(blockchain, context, args) {

bc = blockchain;
ctx = context;
ctx.txNum = args.txNum;
let startIndex = args.txNum * args.clientIndex;
// let endIndex = args.txNum * (args.clientIndex + 1);
seqnum = startIndex;

return Promise.resolve();
};

/* module.exports.run = function() {
return bc.bcObj.sinoSendToCloud(ctx, {
Seqnum: (++seqnum),
Payload: new Buffer('{"name": "simple", "args": ["open", "' + seqnum + '", "10"]}')
});
}; */

const dic = 'abcdefghijklmnopqrstuvwxyz';
/**
* Generate string by picking characters from dic variable
* @param {*} number character to select
* @returns {String} string generated based on @param number
*/
function get26Num(number){
let result = '';
while(number > 0) {
result += dic.charAt(number % 26);
number = parseInt(number/26);
}
return result;
}

let prefix;
/**
* Generate unique account key for the transaction
* @returns {String} account key
*/
function generateAccount() {
// should be [a-z]{1,9}
if(typeof prefix === 'undefined') {
prefix = get26Num(process.pid);
}
return prefix + get26Num(seqnum + 1);
}

module.exports.run = function() {
return bc.bcObj.sinoSendToCloud(ctx, {
Seqnum: (++seqnum),
Payload: new Buffer('{"name": "simple", "args": ["open", "' + generateAccount() + '", "10"]}')
});
};

module.exports.end = function() {
return Promise.resolve();
};
2 changes: 1 addition & 1 deletion benchmark/sinochain/sinochain.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"sinochain": {
"cloud": {
"servers": [
"127.0.0.1:8080"
"127.0.0.1:5050"
]
},
"channel": "mychannel"
Expand Down
7 changes: 7 additions & 0 deletions src/comm/blockchain-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ class BlockchainInterface {
sinoIsConnectionOpen() {
throw new Error('sinoIsConnectionOpen is not implemented for this blockchain system');
}

/**
* wait for recived
*/
sinoWaitRecv() {
throw new Error('sinoWaitRecv is not implemented for this blockchain system');
}
}

module.exports = BlockchainInterface;
10 changes: 10 additions & 0 deletions src/comm/blockchain.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ class Blockchain {
* send data to cloud
* @param {Object} context context object
* @param {Object} payload data send to sinochain cloud
* @returns {Promise} promiseObject
*/
sinoSendToCloud(context, payload) {
return this.bcObj.sinoSendToCloud(context, payload);
Expand All @@ -311,10 +312,19 @@ class Blockchain {

/**
* whether the cloud connection is opened
* @returns {boolean} the cloud connection is opened
*/
sinoIsConnectionOpen() {
return this.bcObj.sinoIsConnectionOpen();
}

/**
* wait for recived
* @returns {Promise} promiseObject
*/
sinoWaitRecv() {
return this.bcObj.sinoWaitRecv();
}
}

module.exports = Blockchain;
5 changes: 5 additions & 0 deletions src/comm/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ class Client{
this.results = [];
this.updates.data = [];
this.updates.id++;
// sinochain: add unfinished control
message.unfinished = -1;
if (this.config.unfinished && this.config.unfinished > 0) {
message.unfinished = this.config.unfinished;
}
switch(this.type) {
case CLIENT_LOCAL:
p = this._startLocalTest(message, clientArgs);
Expand Down
Loading