Skip to content

Commit

Permalink
[sin] calcul of Stm at begin of network
Browse files Browse the repository at this point in the history
Signed-off-by: crptec <crptec.fr@gmail.com>
  • Loading branch information
crptec committed Apr 28, 2021
1 parent 6a5f2b5 commit c7d106f
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/sinovate/infinitynodeman.cpp
Expand Up @@ -924,6 +924,7 @@ bool CInfinitynodeMan::calculStatementOnValidation(int nHeight)
if(infpair.second.getSINType() == 1) nLIL++;
}
}

mapStatementBIG.insert(mapStatementBIG.begin(), make_pair(nHeight, nBIG));
mapStatementMID.insert(mapStatementMID.begin(), make_pair(nHeight, nMID));
mapStatementLIL.insert(mapStatementLIL.begin(), make_pair(nHeight, nLIL));
Expand All @@ -946,10 +947,6 @@ bool CInfinitynodeMan::calculStatementOnValidation(int nHeight)
int nEndOfStmMID = itLastMID->first + itLastMID->second - nextHeight;
int nEndOfStmLIL = itLastLIL->first + itLastLIL->second - nextHeight;

int nextStmBIG = itLastBIG->first + itLastBIG->second;
int nextStmMID = itLastMID->first + itLastMID->second;
int nextStmLIL = itLastLIL->first + itLastLIL->second;

nBIGLastStmHeight = itLastBIG->first;
nBIGLastStmSize = itLastBIG->second;

Expand All @@ -960,20 +957,34 @@ bool CInfinitynodeMan::calculStatementOnValidation(int nHeight)
nLILLastStmSize = itLastLIL->second;

int nBIGNextStm = 0, nMIDNextStm = 0, nLILNextStm = 0;
int nBIGHeight = 0, nMIDHeight = 0, nLILHeight = 0;

//calcul number of nodes at nHeight
for (auto& infpair : mapInfinitynodes) {
if (infpair.second.getSINType() == 10 && infpair.second.getHeight() < itLastBIG->first && itLastBIG->first <= infpair.second.getExpireHeight()) nBIG++;
if (infpair.second.getSINType() == 5 && infpair.second.getHeight() < itLastMID->first && itLastMID->first <= infpair.second.getExpireHeight()) nMID++;
if (infpair.second.getSINType() == 1 && infpair.second.getHeight() < itLastLIL->first && itLastLIL->first <= infpair.second.getExpireHeight()) nLIL++;

if (infpair.second.getHeight() < nHeight && nHeight <= infpair.second.getExpireHeight()){
if(infpair.second.getSINType() == 10) nBIGHeight++;
if(infpair.second.getSINType() == 5) nMIDHeight++;
if(infpair.second.getSINType() == 1) nLILHeight++;
}

if (infpair.second.getHeight() < nextHeight && nextHeight <= infpair.second.getExpireHeight()){
if(infpair.second.getSINType() == 10) nBIGNextStm++;
if(infpair.second.getSINType() == 5) nMIDNextStm++;
if(infpair.second.getSINType() == 1) nLILNextStm++;
}
}

//begin of network, so not at end of Stm

if(itLastBIG->second == 0 || itLastBIG->second == 1) mapStatementBIG.insert(itBIG, make_pair(nHeight, nBIGHeight));
if(itLastMID->second == 0 || itLastMID->second == 1) mapStatementMID.insert(itMID, make_pair(nHeight, nMIDHeight));
if(itLastLIL->second == 0 || itLastLIL->second == 1) mapStatementLIL.insert(itLIL, make_pair(nHeight, nLILHeight));

//end of Stm
if(nEndOfStmBIG == 0 || nEndOfStmMID == 0 || nEndOfStmLIL == 0 ||
(nEndOfStmLIL > 0 && nEndOfStmLIL <= Params().MaxReorganizationDepth()) ||
(nEndOfStmMID > 0 && nEndOfStmMID <= Params().MaxReorganizationDepth()) ||
Expand Down

0 comments on commit c7d106f

Please sign in to comment.