Fix n -> static n0/n1

This commit is contained in:
jl777
2018-04-15 22:12:27 +03:00
parent 02626c56b2
commit df280f67b3

View File

@@ -199,8 +199,8 @@ const char *Notaries_elected1[][2] =
int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp) int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp)
{ {
static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1,n0,n1;
int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp; int32_t i,htind; uint64_t mask = 0; struct knotary_entry *kp,*tmp;
if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 ) if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 )
timestamp = komodo_heightstamp(height); timestamp = komodo_heightstamp(height);
else if ( ASSETCHAINS_SYMBOL[0] == 0 ) else if ( ASSETCHAINS_SYMBOL[0] == 0 )
@@ -211,29 +211,30 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam
{ {
if ( did0 == 0 ) if ( did0 == 0 )
{ {
n = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0)); n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0));
for (i=0; i<n; i++) for (i=0; i<n0; i++)
decode_hex(elected_pubkeys0[i],33,(char *)Notaries_elected0[i][1]); decode_hex(elected_pubkeys0[i],33,(char *)Notaries_elected0[i][1]);
did0 = 1; did0 = 1;
} }
memcpy(pubkeys,elected_pubkeys0,n * 33); memcpy(pubkeys,elected_pubkeys0,n0 * 33);
//if ( ASSETCHAINS_SYMBOL[0] != 0 ) //if ( ASSETCHAINS_SYMBOL[0] != 0 )
//fprintf(stderr,"%s height.%d t.%u elected.%d notaries\n",ASSETCHAINS_SYMBOL,height,timestamp,n); //fprintf(stderr,"%s height.%d t.%u elected.%d notaries\n",ASSETCHAINS_SYMBOL,height,timestamp,n0);
return(n0);
} }
else //if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP2) || height <= KOMODO_NOTARIES_HEIGHT2 ) else //if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP2) || height <= KOMODO_NOTARIES_HEIGHT2 )
{ {
if ( did1 == 0 ) if ( did1 == 0 )
{ {
n = (int32_t)(sizeof(Notaries_elected1)/sizeof(*Notaries_elected1)); n1 = (int32_t)(sizeof(Notaries_elected1)/sizeof(*Notaries_elected1));
for (i=0; i<n; i++) for (i=0; i<n1; i++)
decode_hex(elected_pubkeys1[i],33,(char *)Notaries_elected1[i][1]); decode_hex(elected_pubkeys1[i],33,(char *)Notaries_elected1[i][1]);
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
fprintf(stderr,"%s height.%d t.%u elected.%d notaries2\n",ASSETCHAINS_SYMBOL,height,timestamp,n); fprintf(stderr,"%s height.%d t.%u elected.%d notaries2\n",ASSETCHAINS_SYMBOL,height,timestamp,n1);
did1 = 1; did1 = 1;
} }
memcpy(pubkeys,elected_pubkeys1,n * 33); memcpy(pubkeys,elected_pubkeys1,n1 * 33);
return(n1);
} }
return(n);
} }
htind = height / KOMODO_ELECTION_GAP; htind = height / KOMODO_ELECTION_GAP;
if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP )