tidy up
This commit is contained in:
@@ -115,15 +115,34 @@ int STAKED_era(int timestamp)
|
||||
era = 2;
|
||||
else if (timestamp <= STAKED_NOTARIES_TIMESTAMP3 && timestamp >= (STAKED_NOTARIES_TIMESTAMP2 + STAKED_ERA_GAP))
|
||||
era = 3;
|
||||
else if (timestamp <= STAKED_NOTARIES_TIMESTAMP4 && timestamp >= (STAKED_NOTARIES_TIMESTAMP3 + STAKED_ERA_GAP))
|
||||
else if timestamp >= (STAKED_NOTARIES_TIMESTAMP3 + STAKED_ERA_GAP))
|
||||
era = 4;
|
||||
else
|
||||
era = 0;
|
||||
// if we are in a gap, return era 0, so any notarizations submitted are invalid.
|
||||
// if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP.
|
||||
return(era);
|
||||
}
|
||||
};
|
||||
|
||||
CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries){
|
||||
CrosschainAuthority Choose_auth_STAKED(int chosen_era) {
|
||||
CrosschainAuthority auth;
|
||||
switch (chosen_era) {
|
||||
case 1:
|
||||
auth = auth_STAKED_chosen(notaries_STAKED1,num_notaries_STAKED1);
|
||||
break;
|
||||
case 2:
|
||||
auth = auth_STAKED_chosen(notaries_STAKED2,num_notaries_STAKED2);
|
||||
break;
|
||||
case 3:
|
||||
auth = auth_STAKED_chosen(notaries_STAKED3,num_notaries_STAKED3);
|
||||
break;
|
||||
case 4:
|
||||
auth = auth_STAKED_chosen(notaries_STAKED4,num_notaries_STAKED4);
|
||||
break;
|
||||
}
|
||||
return(auth);
|
||||
};
|
||||
|
||||
CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries) {
|
||||
CrosschainAuthority auth;
|
||||
auth.requiredSigs = (num_notaries / 5);
|
||||
auth.size = num_notaries;
|
||||
|
||||
@@ -26,7 +26,7 @@ extern int num_notaries_STAKED4;
|
||||
int is_STAKED(const char *chain_name);
|
||||
int STAKED_era(int timestamp);
|
||||
|
||||
//CrosschainAuthority Choose_auth_STAKED(staked_era);
|
||||
CrosschainAuthority Choose_auth_STAKED(int chosen_era);
|
||||
CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -31,50 +31,24 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight)
|
||||
if (strlen(data.symbol) == 0)
|
||||
continue;
|
||||
|
||||
printf("Checked notarisation data for %s \n",data.symbol);
|
||||
//printf("Checked notarisation data for %s \n",data.symbol);
|
||||
int authority = GetSymbolAuthority(data.symbol);
|
||||
|
||||
if (authority == CROSSCHAIN_KOMODO) {
|
||||
if (!eval->CheckNotaryInputs(tx, nHeight, block.nTime))
|
||||
continue;
|
||||
printf("Authorised notarisation data for %s \n",data.symbol);
|
||||
//printf("Authorised notarisation data for %s \n",data.symbol);
|
||||
} else if (authority == CROSSCHAIN_STAKED) {
|
||||
// We need to create auth_STAKED dynamically here based on timestamp
|
||||
int staked_era = STAKED_era(timestamp);
|
||||
printf("ERA.(%d) \n",staked_era);
|
||||
if (staked_era == 0)
|
||||
{
|
||||
if (staked_era == 0) {
|
||||
// this is an ERA GAP, so we will ignore this notarization
|
||||
printf("Notarization for %s occured inside an ERA GAP, we will ignore it! \n",data.symbol);
|
||||
continue;
|
||||
} else if (staked_era == 1)
|
||||
{
|
||||
// era 1
|
||||
auth_STAKED = auth_STAKED_chosen(notaries_STAKED1,num_notaries_STAKED1);
|
||||
} else if (staked_era == 2)
|
||||
{
|
||||
// era 2
|
||||
auth_STAKED.requiredSigs = (num_notaries_STAKED2 / 5);
|
||||
auth_STAKED.size = num_notaries_STAKED2;
|
||||
for (int n=0; n<auth_STAKED.size; n++)
|
||||
for (size_t i=0; i<33; i++)
|
||||
sscanf(notaries_STAKED2[n][1]+(i*2), "%2hhx", auth_STAKED.notaries[n]+i);
|
||||
} else if (staked_era == 3)
|
||||
{
|
||||
// era 3
|
||||
auth_STAKED.requiredSigs = (num_notaries_STAKED3 / 5);
|
||||
auth_STAKED.size = num_notaries_STAKED3;
|
||||
for (int n=0; n<auth_STAKED.size; n++)
|
||||
for (size_t i=0; i<33; i++)
|
||||
sscanf(notaries_STAKED3[n][1]+(i*2), "%2hhx", auth_STAKED.notaries[n]+i);
|
||||
} else if (staked_era == 4)
|
||||
{
|
||||
// era 4
|
||||
auth_STAKED.requiredSigs = (num_notaries_STAKED4 / 5);
|
||||
auth_STAKED.size = num_notaries_STAKED4;
|
||||
for (int n=0; n<auth_STAKED.size; n++)
|
||||
for (size_t i=0; i<33; i++)
|
||||
sscanf(notaries_STAKED4[n][1]+(i*2), "%2hhx", auth_STAKED.notaries[n]+i);
|
||||
} else {
|
||||
// pass era slection off to notaries_staked.cpp file
|
||||
auth_STAKED = Choose_auth_STAKED(staked_era);
|
||||
}
|
||||
if (!CheckTxAuthority(tx, auth_STAKED))
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user