Cleanup notary code

This commit is contained in:
Duke
2023-11-22 09:48:09 -05:00
parent 45a5d25230
commit 620ca45efc
5 changed files with 19 additions and 422 deletions

View File

@@ -62,6 +62,9 @@ const char *Notaries_genesis[][2] =
int32_t gethushseason(int32_t height)
{
return 1; // it is always season 1 for now
bool istush = strncmp(SMART_CHAIN_SYMBOL, "TUSH",4) == 0 ? true : false;
if ( istush ) {
// TUSH is always Season 7 DPoW notaries from genblock
@@ -87,6 +90,8 @@ int32_t gethushseason(int32_t height)
int32_t getacseason(uint32_t timestamp)
{
return 1; // it is always season 1 for now
if ( timestamp <= HUSH_SEASON_TIMESTAMPS[0] )
return(1);
for (int32_t i = 1; i < NUM_HUSH_SEASONS; i++)
@@ -125,7 +130,7 @@ int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp)
if ( didinit[hush_season-1] == 0 )
{
for (i=0; i<NUM_HUSH_NOTARIES; i++)
decode_hex(hush_pubkeys[hush_season-1][i],33,(char *)notaries_elected[hush_season-1][i][1]);
decode_hex(hush_pubkeys[hush_season-1][i],33,(char *)notaries_list[hush_season-1][i][1]);
if ( ASSETCHAINS_PRIVATE != 0 )
{
// we need to populate the address array for the notary exemptions.
@@ -141,7 +146,7 @@ int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp)
return(-1);
}
int32_t hush_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp)
int32_t hush_findnotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp)
{
int32_t i,n; uint8_t pubkeys[64][33];
n = hush_notaries(pubkeys,height,timestamp);
@@ -213,7 +218,7 @@ int32_t hush_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,ui
}
if ( height >= HUSH_NOTARIES_HARDCODED || SMART_CHAIN_SYMBOL[0] != 0 )
{
if ( (*notaryidp= hush_electednotary(&numnotaries,pubkey33,height,timestamp)) >= 0 && numnotaries != 0 )
if ( (*notaryidp= hush_findnotary(&numnotaries,pubkey33,height,timestamp)) >= 0 && numnotaries != 0 )
{
modval = ((height % numnotaries) == *notaryidp);
return(modval);