add eras for cross chain auth?
This commit is contained in:
@@ -53,6 +53,7 @@ bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
const CrosschainAuthority auth_STAKED = [&](){
|
const CrosschainAuthority auth_STAKED = [&](){
|
||||||
CrosschainAuthority auth;
|
CrosschainAuthority auth;
|
||||||
auth.requiredSigs = (num_notaries_STAKED / 5);
|
auth.requiredSigs = (num_notaries_STAKED / 5);
|
||||||
@@ -62,3 +63,4 @@ const CrosschainAuthority auth_STAKED = [&](){
|
|||||||
sscanf(notaries_STAKED[n][1]+(i*2), "%2hhx", auth.notaries[n]+i);
|
sscanf(notaries_STAKED[n][1]+(i*2), "%2hhx", auth.notaries[n]+i);
|
||||||
return auth;
|
return auth;
|
||||||
}();
|
}();
|
||||||
|
*/
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight)
|
|||||||
{
|
{
|
||||||
EvalRef eval;
|
EvalRef eval;
|
||||||
NotarisationsInBlock vNotarisations;
|
NotarisationsInBlock vNotarisations;
|
||||||
//CrosschainAuthority auth_STAKED;
|
CrosschainAuthority auth_STAKED;
|
||||||
int timestamp = block.nTime;
|
int timestamp = block.nTime;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < block.vtx.size(); i++) {
|
for (unsigned int i = 0; i < block.vtx.size(); i++) {
|
||||||
@@ -43,9 +43,45 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight)
|
|||||||
printf("Authorised notarisation data for %s \n",data.symbol);
|
printf("Authorised notarisation data for %s \n",data.symbol);
|
||||||
} else if (authority == CROSSCHAIN_STAKED) {
|
} else if (authority == CROSSCHAIN_STAKED) {
|
||||||
// We need to create auth_STAKED dynamically here based on timestamp
|
// We need to create auth_STAKED dynamically here based on timestamp
|
||||||
printf("timestamp = %d\n",timestamp);
|
|
||||||
int staked_era = STAKED_era(timestamp);
|
int staked_era = STAKED_era(timestamp);
|
||||||
printf("ERA = %d \n",staked_era);
|
printf("ERA.(%d) \n",staked_era);
|
||||||
|
if (staked_era == 0)
|
||||||
|
{
|
||||||
|
// era 0
|
||||||
|
auth_STAKED.requiredSigs = (num_notaries_STAKED / 5);
|
||||||
|
auth_STAKED.size = num_notaries_STAKED;
|
||||||
|
for (int n=0; n<auth_STAKED.size; n++)
|
||||||
|
for (size_t i=0; i<33; i++)
|
||||||
|
sscanf(notaries_STAKED[n][1]+(i*2), "%2hhx", auth_STAKED.notaries[n]+i);
|
||||||
|
} else if (staked_era == 1)
|
||||||
|
{
|
||||||
|
// era 1
|
||||||
|
auth_STAKED.requiredSigs = (num_notaries_STAKED1 / 5);
|
||||||
|
auth_STAKED.size = num_notaries_STAKED1;
|
||||||
|
for (int n=0; n<auth_STAKED.size; n++)
|
||||||
|
for (size_t i=0; i<33; i++)
|
||||||
|
sscanf(notaries_STAKED1[n][1]+(i*2), "%2hhx", auth_STAKED.notaries[n]+i);
|
||||||
|
} 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 > 3) {
|
||||||
|
printf("Invalid ERA.(%d), this should not happen",staked_era);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!CheckTxAuthority(tx, auth_STAKED))
|
if (!CheckTxAuthority(tx, auth_STAKED))
|
||||||
continue;
|
continue;
|
||||||
printf("Authorised notarisation data for %s \n",data.symbol);
|
printf("Authorised notarisation data for %s \n",data.symbol);
|
||||||
|
|||||||
Reference in New Issue
Block a user