Browse Source

Test

etomic
jl777 7 years ago
parent
commit
6efe0edb56
  1. 57
      iguana/dpow/dpow_rpc.c
  2. 71
      iguana/iguana_notary.c
  3. 4
      iguana/main.c

57
iguana/dpow/dpow_rpc.c

@ -171,63 +171,6 @@ int32_t komodo_notaries(char *symbol,uint8_t pubkeys[64][33],int32_t height)
return(num);
}
void iguana_notarystats(char *fname,int32_t totals[64],int32_t dispflag)
{
FILE *fp; uint64_t signedmask; long fpos,startfpos; int32_t i,height,iter,prevheight;
if ( (fp= fopen(fname,"rb")) != 0 )
{
printf("opened %s\n",fname);
startfpos = 0;
prevheight = -1;
for (iter=0; iter<2; iter++)
{
while ( 1 )
{
fpos = ftell(fp);
if (fread(&height,1,sizeof(height),fp) == sizeof(height) && fread(&signedmask,1,sizeof(signedmask),fp) == sizeof(signedmask) )
{
//printf("%6d %016llx\n",height,(long long)signedmask);
if ( height < prevheight )
{
startfpos = fpos;
if ( iter == 0 )
printf("found reversed height %d vs %d\n",height,prevheight);
else printf("fpos.%ld fatal unexpected height reversal %d vs %d\n",fpos,height,prevheight);
}
if ( iter == 1 && height >= 180000 )
{
for (i=0; i<64; i++)
{
if ( ((1LL << i) & signedmask) != 0 )
{
totals[i]++;
printf("%d ",i);
}
}
printf("height.%d %016llx\n",height,(long long)signedmask);
}
prevheight = height;
} else break;
}
if ( iter == 0 )
{
prevheight = -1;
fseek(fp,startfpos,SEEK_SET);
printf("set startfpos %ld\n",startfpos);
}
}
fclose(fp);
//if ( dispflag != 0 )
{
for (i=0; i<64; i++)
{
if ( totals[i] != 0 )
printf("%s, %d\n",Notaries_elected[i][0],totals[i]);
}
}
} else printf("couldnt open.(%s)\n",fname);
}
bits256 dpow_getbestblockhash(struct supernet_info *myinfo,struct iguana_info *coin)
{
char *retstr; bits256 blockhash;

71
iguana/iguana_notary.c

@ -560,6 +560,77 @@ char NOTARY_CURRENCIES[][16] = { "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF"
"CNY", "RUB", "MXN", "BRL", "INR", "HKD", "TRY", "ZAR", "PLN", "NOK", "SEK", "DKK", "CZK", "HUF", "ILS", "KRW", "MYR", "PHP", "RON", "SGD", "THB", "BGN", "IDR", "HRK",
"REVS", "SUPERNET", "DEX", "PANGEA", "JUMBLR", "BET", "CRYPTO", "HODL", "BOTS", "MGW", "COQUI", "WLC", "KV", "CEAL", "MESH", "MNZ", "CHIPS", "MSHARK", "AXO", "ETOMIC", "BTCH" }; // "LTC",
void _iguana_notarystats(char *fname,int32_t totals[64],int32_t dispflag)
{
FILE *fp; uint64_t signedmask; long fpos,startfpos; int32_t i,height,iter,prevheight;
if ( (fp= fopen(fname,"rb")) != 0 )
{
printf("opened %s\n",fname);
startfpos = 0;
prevheight = -1;
for (iter=0; iter<2; iter++)
{
while ( 1 )
{
fpos = ftell(fp);
if (fread(&height,1,sizeof(height),fp) == sizeof(height) && fread(&signedmask,1,sizeof(signedmask),fp) == sizeof(signedmask) )
{
//printf("%6d %016llx\n",height,(long long)signedmask);
if ( height < prevheight )
{
startfpos = fpos;
if ( iter == 0 )
printf("found reversed height %d vs %d\n",height,prevheight);
else printf("fpos.%ld fatal unexpected height reversal %d vs %d\n",fpos,height,prevheight);
}
if ( iter == 1 && height >= 180000 )
{
for (i=0; i<64; i++)
{
if ( ((1LL << i) & signedmask) != 0 )
{
totals[i]++;
if ( dispflag > 1 )
printf("%2d ",i);
}
}
if ( dispflag > 1 )
printf("height.%d %016llx %s\n",height,(long long)signedmask,fname);
}
prevheight = height;
} else break;
}
if ( iter == 0 )
{
prevheight = -1;
fseek(fp,startfpos,SEEK_SET);
printf("set startfpos %ld\n",startfpos);
}
}
fclose(fp);
if ( dispflag != 0 )
{
printf("after %s\n",fname);
for (i=0; i<64; i++)
{
if ( totals[i] != 0 )
printf("%s, %d\n",Notaries_elected[i][0],totals[i]);
}
}
} else printf("couldnt open.(%s)\n",fname);
}
void iguana_notarystats(int32_t totals[64],int32_t dispflag)
{
int32_t i; char fname[512];
_iguana_notarystats("signedmasks",totals,dispflag);
for (i=0; i<sizeof(NOTARY_CURRENCIES)/sizeof(*NOTARY_CURRENCIES); i++)
{
sprintf(fname,"%s/signedmasks",NOTARY_CURRENCIES[i]);
_iguana_notarystats(fname,totals,dispflag);
}
}
ZERO_ARGS(dpow,notarychains)
{
int32_t i; cJSON *array = cJSON_CreateArray();

4
iguana/main.c

@ -2200,10 +2200,10 @@ void iguana_main(void *arg)
do_OStests = 1;
else if ( strcmp((char *)arg,"stats") == 0 )
{
void iguana_notarystats(char *fname,int32_t totals[64],int32_t dispflag);
void iguana_notarystats(int32_t totals[64],int32_t dispflag);
int32_t totals[64];
memset(totals,0,sizeof(totals));
iguana_notarystats("signedmasks",totals,1);
iguana_notarystats(totals,1);
exit(0);
}
else if ( strcmp((char *)arg,"notary") == 0 )

Loading…
Cancel
Save