Verified Commit 7b1f06df authored by Éloïs's avatar Éloïs

fix indentation

parent 720af7eb
Pipeline #714 passed with stage
in 21 seconds
......@@ -82,17 +82,17 @@ module.exports = (req, res, next) => co(function *() {
tabBlockMembers.push ({
uid: idtys[i].uid,
pubkey: idtys[i].pub,
becomeMember: (tmpBecomeMember[0] > begin) ? tmpBecomeMember[0]:begin,
coreCount: 0,
blockCount: 0,
becomeMember: (tmpBecomeMember[0] > begin) ? tmpBecomeMember[0]:begin,
coreCount: 0,
blockCount: 0,
data: 0
});
// initialize tabBlockCountPerNode and tabDataPerNode
if (perNode == 'yes')
{
tabCoreCountPerNode.push(new Array());
tabBlockCountPerNode.push(new Array());
tabDataPerNode.push(new Array());
tabCoreCountPerNode.push(new Array());
tabBlockCountPerNode.push(new Array());
tabDataPerNode.push(new Array());
}
}
......@@ -117,21 +117,21 @@ module.exports = (req, res, next) => co(function *() {
{
if (tabBlockMembers[m].pubkey == blockchain[b].issuer)
{
tabBlockMembers[m].blockCount++;
let nonce = parseInt((blockchain[b].nonce).toString().substr(3));
if (data == 'meanNonce') { tabBlockMembers[m].data += nonce; }
let idCore = parseInt((blockchain[b].nonce).toString().substr(1, 2));
tabBlockMembers[m].coreCount = (tabBlockMembers[m].coreCount < idCore) ? idCore:tabBlockMembers[m].coreCount;
let idNode = parseInt((blockchain[b].nonce).toString().substr(0, 1));
if (perNode == 'yes')
{
maxIdNode = (idNode > maxIdNode) ? idNode:maxIdNode;
tabCoreCountPerNode[m][idNode-1] = (tabCoreCountPerNode[m][idNode-1] < idCore) ? idCore:tabCoreCountPerNode[m][idNode-1];
tabBlockCountPerNode[m][idNode-1]++;
if (data == 'meanNonce') { tabDataPerNode[m][idNode-1] += nonce; }
}
tabBlockMembers[m].blockCount++;
let nonce = parseInt((blockchain[b].nonce).toString().substr(3));
if (data == 'meanNonce') { tabBlockMembers[m].data += nonce; }
let idCore = parseInt((blockchain[b].nonce).toString().substr(1, 2));
tabBlockMembers[m].coreCount = (tabBlockMembers[m].coreCount < idCore) ? idCore:tabBlockMembers[m].coreCount;
let idNode = parseInt((blockchain[b].nonce).toString().substr(0, 1));
if (perNode == 'yes')
{
maxIdNode = (idNode > maxIdNode) ? idNode:maxIdNode;
tabCoreCountPerNode[m][idNode-1] = (tabCoreCountPerNode[m][idNode-1] < idCore) ? idCore:tabCoreCountPerNode[m][idNode-1];
tabBlockCountPerNode[m][idNode-1]++;
if (data == 'meanNonce') { tabDataPerNode[m][idNode-1] += nonce; }
}
}
}
}
......@@ -144,24 +144,24 @@ module.exports = (req, res, next) => co(function *() {
for (let m=0;m<tabBlockMembers.length;m++)
{
let significantLimit = parseInt(tabBlockMembers[m].blockCount * significantPercent / 100);
for (let n=0;n<maxIdNode;n++)
{
if (tabBlockCountPerNode[m][n] <= significantLimit)
for (let n=0;n<maxIdNode;n++)
{
tabBlockMembers[m].blockCount -= tabBlockCountPerNode[m][n];
tabCoreCountPerNode[m][n] = 0;
tabBlockCountPerNode[m][n] = 0;
if (data == 'meanNonce')
{
tabBlockMembers[m].data -= tabDataPerNode[m][n];
tabDataPerNode[m][n] = 0;
}
}
else if (tabBlockCountPerNode[m][n] > 0)
{
maxSignificantIdNode = ((n+1) > maxSignificantIdNode) ? (n+1):maxSignificantIdNode;
}
}
if (tabBlockCountPerNode[m][n] <= significantLimit)
{
tabBlockMembers[m].blockCount -= tabBlockCountPerNode[m][n];
tabCoreCountPerNode[m][n] = 0;
tabBlockCountPerNode[m][n] = 0;
if (data == 'meanNonce')
{
tabBlockMembers[m].data -= tabDataPerNode[m][n];
tabDataPerNode[m][n] = 0;
}
}
else if (tabBlockCountPerNode[m][n] > 0)
{
maxSignificantIdNode = ((n+1) > maxSignificantIdNode) ? (n+1):maxSignificantIdNode;
}
}
}
}
......@@ -170,38 +170,38 @@ module.exports = (req, res, next) => co(function *() {
{
if (data == 'nbBlocks')
{
tabBlockMembers[m].data = tabBlockMembers[m].blockCount;
if (perNode == 'yes') {
for (let n=0;n<maxSignificantIdNode;n++) { tabDataPerNode[m].push(tabBlockCountPerNode[m][n]); }
}
tabBlockMembers[m].data = tabBlockMembers[m].blockCount;
if (perNode == 'yes') {
for (let n=0;n<maxSignificantIdNode;n++) { tabDataPerNode[m].push(tabBlockCountPerNode[m][n]); }
}
}
else if (data == 'writtenPercent')
{
tabBlockMembers[m].data = parseFloat( ((tabBlockMembers[m].blockCount * 100) / (blockchain.length-begin)).toFixed(2) );
if (perNode == 'yes') {
for (let n=0;n<maxSignificantIdNode;n++) {
tabDataPerNode[m].push( parseFloat( ((tabBlockCountPerNode[m][n] * 100) / (blockchain.length-begin)).toFixed(2) ) );
}
}
tabBlockMembers[m].data = parseFloat( ((tabBlockMembers[m].blockCount * 100) / (blockchain.length-begin)).toFixed(2) );
if (perNode == 'yes') {
for (let n=0;n<maxSignificantIdNode;n++) {
tabDataPerNode[m].push( parseFloat( ((tabBlockCountPerNode[m][n] * 100) / (blockchain.length-begin)).toFixed(2) ) );
}
}
}
else if (data == 'meanNonce' && tabBlockMembers[m].blockCount > 0)
{
tabBlockMembers[m].data = parseInt( (tabBlockMembers[m].data / (tabBlockMembers[m].blockCount)).toFixed(0) );
if (perNode == 'yes') {
for (let n=0;n<maxSignificantIdNode;n++) {
tabDataPerNode[m][n] = parseInt( (tabDataPerNode[m][n] / (tabBlockCountPerNode[m][n])).toFixed(0) );
}
}
tabBlockMembers[m].data = parseInt( (tabBlockMembers[m].data / (tabBlockMembers[m].blockCount)).toFixed(0) );
if (perNode == 'yes') {
for (let n=0;n<maxSignificantIdNode;n++) {
tabDataPerNode[m][n] = parseInt( (tabDataPerNode[m][n] / (tabBlockCountPerNode[m][n])).toFixed(0) );
}
}
}
else if (data == 'writtenPercentSinceBecomeMember')
{
let nbBlockwithThisMember = (tabBlockMembers[m].becomeMember > begin) ? (blockchain.length-tabBlockMembers[m].becomeMember) : (blockchain.length-begin);
tabBlockMembers[m].data = parseFloat( ((tabBlockMembers[m].blockCount * 100) / nbBlockwithThisMember).toFixed(2) );
if (perNode == 'yes') {
for (let n=0;n<maxSignificantIdNode;n++) {
tabDataPerNode[m].push( parseFloat( ((tabBlockCountPerNode[m][n] * 100) / nbBlockwithThisMember).toFixed(2) ) );
}
}
let nbBlockwithThisMember = (tabBlockMembers[m].becomeMember > begin) ? (blockchain.length-tabBlockMembers[m].becomeMember) : (blockchain.length-begin);
tabBlockMembers[m].data = parseFloat( ((tabBlockMembers[m].blockCount * 100) / nbBlockwithThisMember).toFixed(2) );
if (perNode == 'yes') {
for (let n=0;n<maxSignificantIdNode;n++) {
tabDataPerNode[m].push( parseFloat( ((tabBlockCountPerNode[m][n] * 100) / nbBlockwithThisMember).toFixed(2) ) );
}
}
}
}
......@@ -231,13 +231,13 @@ module.exports = (req, res, next) => co(function *() {
tabBlockMembersSort.push({
uid: tabBlockMembers[idMax].uid,
pubkey: tabBlockMembers[idMax].pub,
becomeMember: tabBlockMembers[idMax].becomeMember,
coreCount: tabBlockMembers[m].coreCount,
coreCountPerNode: (perNode == 'yes') ? tabCoreCountPerNode[idMax]:null,
blockCount: tabBlockMembers[idMax].blockCount,
blockCountPerNode: (perNode == 'yes') ? tabBlockCountPerNode[idMax]:null,
data: tabBlockMembers[idMax].data,
dataPerNode: (perNode == 'yes') ? tabDataPerNode[idMax]:null
becomeMember: tabBlockMembers[idMax].becomeMember,
coreCount: tabBlockMembers[m].coreCount,
coreCountPerNode: (perNode == 'yes') ? tabCoreCountPerNode[idMax]:null,
blockCount: tabBlockMembers[idMax].blockCount,
blockCountPerNode: (perNode == 'yes') ? tabBlockCountPerNode[idMax]:null,
data: tabBlockMembers[idMax].data,
dataPerNode: (perNode == 'yes') ? tabDataPerNode[idMax]:null
});
tabExcluded.push(tabBlockMembers[idMax].uid);
}
......@@ -264,98 +264,98 @@ module.exports = (req, res, next) => co(function *() {
for (let n=0;n<maxIdNode;n++) { tabDataXperNode.push(new Array()); }
for (let m=0;m<tabBlockMembersSort.length;m++)
{
if (tabBlockMembersSort[m].data > 0)
{
if (perNode == 'yes')
{
tabLabels.push(tabBlockMembersSort[m].uid+"(");
for (let n=0;n<maxSignificantIdNode;n++)
{
tabDataXperNode[n].push(tabBlockMembersSort[m].dataPerNode[n]);
if (tabBlockMembersSort[m].coreCountPerNode[n] > 0) { tabLabels[tabLabels.length-1] += tabBlockMembersSort[m].coreCountPerNode[n]+"c,"; }
}
tabLabels[tabLabels.length-1] = tabLabels[tabLabels.length-1].substr(0, tabLabels[tabLabels.length-1].length-1);
tabLabels[tabLabels.length-1] += ")";
}
else
{
tabLabels.push(tabBlockMembersSort[m].uid);
tabDataX.push(tabBlockMembersSort[m].data);
}
nbMembers++;
}
if (tabBlockMembersSort[m].data > 0)
{
if (perNode == 'yes')
{
tabLabels.push(tabBlockMembersSort[m].uid+"(");
for (let n=0;n<maxSignificantIdNode;n++)
{
tabDataXperNode[n].push(tabBlockMembersSort[m].dataPerNode[n]);
if (tabBlockMembersSort[m].coreCountPerNode[n] > 0) { tabLabels[tabLabels.length-1] += tabBlockMembersSort[m].coreCountPerNode[n]+"c,"; }
}
tabLabels[tabLabels.length-1] = tabLabels[tabLabels.length-1].substr(0, tabLabels[tabLabels.length-1].length-1);
tabLabels[tabLabels.length-1] += ")";
}
else
{
tabLabels.push(tabBlockMembersSort[m].uid);
tabDataX.push(tabBlockMembersSort[m].data);
}
nbMembers++;
}
}
var datasets = [ [] ];
if (perNode == 'yes')
{
for (let n=0;n<maxSignificantIdNode;n++)
{
datasets.push({
label: dataLabel,
data: tabDataXperNode[n],
backgroundColor: colorScale(nbMembers, 0.5),
borderWidth: 0,
hoverBackgroundColor: colorScale(nbMembers, 0.2)
});
}
for (let n=0;n<maxSignificantIdNode;n++)
{
datasets.push({
label: dataLabel,
data: tabDataXperNode[n],
backgroundColor: colorScale(nbMembers, 0.5),
borderWidth: 0,
hoverBackgroundColor: colorScale(nbMembers, 0.2)
});
}
}
else
{
datasets = [{
label: dataLabel,
data: tabDataX,
backgroundColor: colorScale(nbMembers, 0.5),
borderColor: colorScale(nbMembers, 1.0),
borderWidth: 1,
hoverBackgroundColor: colorScale(nbMembers, 0.2),
hoverBorderColor: colorScale(nbMembers, 0.2)
datasets = [{
label: dataLabel,
data: tabDataX,
backgroundColor: colorScale(nbMembers, 0.5),
borderColor: colorScale(nbMembers, 1.0),
borderWidth: 1,
hoverBackgroundColor: colorScale(nbMembers, 0.2),
hoverBorderColor: colorScale(nbMembers, 0.2)
}];
}
res.locals = {
host: req.headers.host.toString(),
tabBlockMembersSort,
begin,
end,
help,
data,
perNode,
description: ``,
chart: {
type: 'bar',
data: {
labels: tabLabels,
datasets: datasets
},
options: {
title: {
display: true,
text: nbMembers+' '+LANG["RANGE"]+' #'+begin+'-#'+end
},
legend: {
display: false
},
scales: {
yAxes: [{
ticks: {
beginAtZero: true,
}
}]
},
categoryPercentage: 1.0,
barPercentage: 1.0
}
},
form: `${LANG['BEGIN']} #<input type="number" name="begin" value="${begin}" size="7" style="width:60px;"> - ${LANG['END']} #<input type="number" name="end" value="${end}" size="7" style="width:60px;">
<select name="data">
<option name="data" value ="nbBlocks">${LANG["NB_BLOCKS"]}
<option name="data" value ="writtenPercent" ${data == 'writtenPercent' ? 'selected' : ''}>${LANG["PERCENT_OF_WRITTEN_BLOCKS"]}
<option name="data" value ="writtenPercentSinceBecomeMember" ${data == 'writtenPercentSinceBecomeMember' ? 'selected' : ''}>${LANG["PERCENT_OF_WRITTEN_BLOCKS"]} ${LANG["SINCE_BECOME_MEMBER"]}
<option name="data" value ="meanNonce" ${data == 'meanNonce' ? 'selected' : ''}>${LANG['MEAN_NONCE']}
</select>
<input type="checkbox" name="perNode" value="yes" ${perNode == 'yes' ? 'checked' : ''}>${LANG['DETAIL_BY_NODE']} -
${LANG['SIGNIFICANT_LIMIT']} <input type="number" name="significantPercent" value="${significantPercent}" size="2" style="width:30px;">${LANG['PERCENT_OF_BLOCKS']}`
host: req.headers.host.toString(),
tabBlockMembersSort,
begin,
end,
help,
data,
perNode,
description: ``,
chart: {
type: 'bar',
data: {
labels: tabLabels,
datasets: datasets
},
options: {
title: {
display: true,
text: nbMembers+' '+LANG["RANGE"]+' #'+begin+'-#'+end
},
legend: {
display: false
},
scales: {
yAxes: [{
ticks: {
beginAtZero: true,
}
}]
},
categoryPercentage: 1.0,
barPercentage: 1.0
}
},
form: `${LANG['BEGIN']} #<input type="number" name="begin" value="${begin}" size="7" style="width:60px;"> - ${LANG['END']} #<input type="number" name="end" value="${end}" size="7" style="width:60px;">
<select name="data">
<option name="data" value ="nbBlocks">${LANG["NB_BLOCKS"]}
<option name="data" value ="writtenPercent" ${data == 'writtenPercent' ? 'selected' : ''}>${LANG["PERCENT_OF_WRITTEN_BLOCKS"]}
<option name="data" value ="writtenPercentSinceBecomeMember" ${data == 'writtenPercentSinceBecomeMember' ? 'selected' : ''}>${LANG["PERCENT_OF_WRITTEN_BLOCKS"]} ${LANG["SINCE_BECOME_MEMBER"]}
<option name="data" value ="meanNonce" ${data == 'meanNonce' ? 'selected' : ''}>${LANG['MEAN_NONCE']}
</select>
<input type="checkbox" name="perNode" value="yes" ${perNode == 'yes' ? 'checked' : ''}>${LANG['DETAIL_BY_NODE']} -
${LANG['SIGNIFICANT_LIMIT']} <input type="number" name="significantPercent" value="${significantPercent}" size="2" style="width:30px;">${LANG['PERCENT_OF_BLOCKS']}`
}
next()
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment