Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
57db8bd60b
  1. 8
      iguana/btcd
  2. 10
      iguana/iguana777.c
  3. 15
      iguana/iguana_init.c
  4. 11
      iguana/iguana_ramchain.c
  5. 4
      iguana/iguana_recv.c
  6. 14
      iguana/iguana_unspents.c
  7. 2088
      iguana/js/BTCD_hdrs.js
  8. 16
      iguana/main.c
  9. BIN
      iguana/pnacl/Release/iguana.pexe
  10. 2
      pnacl_main.h

8
iguana/btcd

@ -0,0 +1,8 @@
curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":-1,\"poll\":1,\"VALIDATE\":1,\"validatedir\":\"/tmp\",\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTCD\",\"startpend\":4,\"endpend\":4,\"services\":1,\"maxpeers\":64,\"tmpdir\":\"/mnt/ramdisk\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"pausecoin\",\"coin\":\"BTC\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"coin\":\"BTCD\",\"ipaddr\":\"89.248.160.241\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"coin\":\"BTCD\",\"ipaddr\":\"89.248.160.244\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"coin\":\"BTCD\",\"ipaddr\":\"89.248.160.239\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"coin\":\"BTCD\",\"ipaddr\":\"96.41.29.70\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"coin\":\"BTCD\",\"ipaddr\":\"68.46.103.181\"}"

10
iguana/iguana777.c

@ -31,6 +31,10 @@ struct iguana_info *iguana_coinfind(const char *symbol)
struct iguana_info *iguana_coinadd(const char *symbol,cJSON *argjson)
{
struct iguana_info *coin; int32_t i = 0;
#ifdef __PNACL__
if ( strcmp("BTCD",symbol) != 0 )
return(0);
#endif
if ( symbol == 0 )
{
for (i=0; i<sizeof(Coins)/sizeof(*Coins); i++)
@ -40,7 +44,7 @@ struct iguana_info *iguana_coinadd(const char *symbol,cJSON *argjson)
{
if ( Coins[i] == 0 )
{
Coins[i] = mycalloc('c',1,sizeof(*Coins[i]));
Coins[i] = mycalloc('C',1,sizeof(*Coins[i]));
printf("iguana_coin.(new) -> %p\n",Coins[i]);
return(Coins[i]);
} return(0);
@ -59,7 +63,7 @@ struct iguana_info *iguana_coinadd(const char *symbol,cJSON *argjson)
if ( strcmp("endmarker",Hardcoded_coins[i][0]) == 0 || strcmp(symbol,Hardcoded_coins[i][0]) == 0 )
{
if ( Coins[i] == 0 )
Coins[i] = mycalloc('c',1,sizeof(*Coins[i]));
Coins[i] = mycalloc('C',1,sizeof(*Coins[i]));
coin = Coins[i];
if ( coin->chain == 0 )
{
@ -525,6 +529,8 @@ void iguana_coinloop(void *arg)
{
if ( coin->MAXPEERS > IGUANA_MAXPEERS )
coin->MAXPEERS = IGUANA_MAXPEERS;
if ( coin->MAXPEERS < IGUANA_MINPEERS )
coin->MAXPEERS = IGUANA_MAXPEERS;
if ( coin->started == 0 && coin->active != 0 )
{
iguana_rwiAddrind(coin,0,0,0);

15
iguana/iguana_init.c

@ -134,7 +134,12 @@ int32_t iguana_savehdrs(struct iguana_info *coin)
n = coin->blocks.hwmchain.height + 1;
sprintf(oldfname,"confs/%s_oldhdrs.txt",coin->symbol), OS_compatible_path(oldfname);
sprintf(tmpfname,"%s/%s/hdrs.txt",GLOBALTMPDIR,coin->symbol), OS_compatible_path(tmpfname);
sprintf(fname,"confs/%s_hdrs.txt",coin->symbol), OS_compatible_path(fname);
#ifdef __PNACL__
sprintf(fname,"js/%s_hdrs.js",coin->symbol);
#else
sprintf(fname,"confs/%s_hdrs.txt",coin->symbol);
#endif
OS_compatible_path(fname);
if ( (fp= fopen(tmpfname,"w")) != 0 )
{
fprintf(fp,"%d\n",n);
@ -188,7 +193,7 @@ void iguana_parseline(struct iguana_info *coin,int32_t iter,FILE *fp)
lastbundle = zero;
if ( coin->MAXPEERS > IGUANA_MAXPEERS )
coin->MAXPEERS = IGUANA_MAXPEERS;
if ( iter == 1 )
if ( iter == 1 && 0 )
{
int32_t i; FILE *fp; char fname[512]; struct iguana_blockRO blockRO;
sprintf(fname,"blocks.%s",coin->symbol), OS_compatible_path(fname);
@ -435,7 +440,13 @@ struct iguana_info *iguana_coinstart(struct iguana_info *coin,int32_t initialhei
iguana_genesis(coin,coin->chain);
for (iter=coin->peers.numranked>8; iter<2; iter++)
{
#ifdef __PNACL__
sprintf(fname,"js/%s_%s.js",coin->symbol,(iter == 0) ? "peers" : "hdrs");
#else
sprintf(fname,"confs/%s_%s.txt",coin->symbol,(iter == 0) ? "peers" : "hdrs");
#endif
OS_compatible_path(fname);
//sprintf(fname,"confs/%s_%s.txt",coin->symbol,(iter == 0) ? "peers" : "hdrs");
//sprintf(fname,"tmp/%s/%s.txt",coin->symbol,(iter == 0) ? "peers" : "hdrs");
OS_compatible_path(fname);
printf("parsefile.%d %s\n",iter,fname);

11
iguana/iguana_ramchain.c

@ -1358,8 +1358,9 @@ struct iguana_ramchain *iguana_ramchain_map(struct iguana_info *coin,char *fname
if ( iguana_ramchain_size(RAMCHAIN_ARG,ramchain->numblocks,ramchain->H.data->scriptspace) != ramchain->H.data->allocsize || fpos+ramchain->H.data->allocsize > filesize )
{
printf("iguana_ramchain_map.(%s) size mismatch %ld vs %ld vs filesize.%ld numblocks.%d expanded.%d fpos.%d sum %ld\n",fname,(long)iguana_ramchain_size(RAMCHAIN_ARG,ramchain->numblocks,ramchain->H.data->scriptspace),(long)ramchain->H.data->allocsize,(long)filesize,ramchain->numblocks,expanded,(int32_t)fpos,(long)(fpos+ramchain->H.data->allocsize));
exit(-1);
//munmap(ramchain->fileptr,ramchain->filesize);
//exit(-1);
munmap(ramchain->fileptr,ramchain->filesize);
OS_removefile(fname,0);
return(0);
}
else if ( memcmp(hash2.bytes,ramchain->H.data->firsthash2.bytes,sizeof(bits256)) != 0 )
@ -2155,9 +2156,9 @@ int32_t iguana_ramchain_expandedsave(struct iguana_info *coin,RAMCHAIN_FUNC,stru
retval = 0;
}
}
int32_t i; for (i=0; i<IGUANA_NUMLHASHES; i++)
printf("%08x ",mapchain->H.data->lhashes[i].uints[0]);
printf("%x ht.%d bundlehashes.%s\n",(uint32_t)mapchain->H.data->sha256.txid,mapchain->height,coin->symbol);
int32_t i; char buf[512]; for (i=0; i<IGUANA_NUMLHASHES; i++)
sprintf(buf+strlen(buf),"%08x ",mapchain->H.data->lhashes[i].uints[0]);
sprintf("%s %x ht.%d bundlehashes.%s\n",buf,(uint32_t)mapchain->H.data->sha256.txid,mapchain->height,coin->symbol);
iguana_ramchain_free(coin,mapchain,cmpflag);
}
iguana_mempurge(hashmem);

4
iguana/iguana_recv.c

@ -982,7 +982,7 @@ struct iguana_bundlereq *iguana_recvblock(struct iguana_info *coin,struct iguana
if ( (tmpblock= bp->blocks[i]) != 0 && tmpblock->fpipbits != 0 && tmpblock->fpos >= 0 && ((bp->hdrsi == 0 && i == 0) || bits256_nonz(tmpblock->RO.prev_block) != 0) )
numsaved++;
}
fprintf(stderr,"%s [%d:%d] block.%x | s.%d r.%d copy.%d mainchain.%d\n",bits256_str(str,origblock->RO.hash2),bp!=0?bp->hdrsi:-1,bundlei,block!=0?block->fpipbits:0,numsaved,numrecv,req->copyflag,block->mainchain);
//fprintf(stderr,"%s [%d:%d] block.%x | s.%d r.%d copy.%d mainchain.%d\n",bits256_str(str,origblock->RO.hash2),bp!=0?bp->hdrsi:-1,bundlei,block!=0?block->fpipbits:0,numsaved,numrecv,req->copyflag,block->mainchain);
if ( _iguana_chainlink(coin,block) == 0 )
{
next = block;
@ -998,7 +998,7 @@ struct iguana_bundlereq *iguana_recvblock(struct iguana_info *coin,struct iguana
}
next = block;
}
} else printf("RECV MAINCHAIN.%d\n",coin->blocks.hwmchain.height);
} // else printf("RECV MAINCHAIN.%d\n",coin->blocks.hwmchain.height);
}
if ( 0 && bundlei == 1 && bp != 0 && bp->numhashes < bp->n && coin->enableCACHE != 0 && bp->speculative == 0 && bp == coin->current )
{

14
iguana/iguana_unspents.c

@ -1349,11 +1349,11 @@ void iguana_initfinal(struct iguana_info *coin,bits256 lastbundle)
{
if ( (bp= coin->bundles[i]) != 0 && bp->queued == 0 )
{
printf("%d ",i);
//printf("%d ",i);
iguana_bundleQ(coin,bp,1000);
}
}
printf("iguana_bundlesQ\n");
printf("iguana_bundlesQ %d to %d\n",coin->balanceswritten,coin->bundlescount);
}
coin->origbalanceswritten = coin->balanceswritten;
iguana_volatilesinit(coin);
@ -1754,18 +1754,16 @@ int32_t iguana_realtime_update(struct iguana_info *coin)
{
if ( (block= bp->blocks[0]) == 0 || block->txvalid == 0 || block->mainchain == 0 )
{
iguana_walkchain(coin,0);
if ( block != 0 )
{
_iguana_chainlink(coin,block);
block->txvalid = 0;
block->issued = 0;
if ( _iguana_chainlink(coin,block) <= 0 )
iguana_blockunmark(coin,block,bp,0,1);
}
bp->issued[0] = 0;
{
struct iguana_peer *addr; //uint8_t serialized[512]; int32_t len;
hash2 = bp->hashes[0];
char str[65]; printf("RT[0] [%d:%d] %s %p\n",bp->hdrsi,0,bits256_str(str,hash2),block);
//char str[65]; printf("RT[0] [%d:%d] %s %p\n",bp->hdrsi,0,bits256_str(str,hash2),block);
addr = coin->peers.ranked[rand() % 8];
if ( addr != 0 && addr->usock >= 0 && addr->dead == 0 )//&& (len= iguana_getdata(coin,serialized,MSG_BLOCK,&hash2,1)) > 0 )
{
@ -1774,7 +1772,7 @@ int32_t iguana_realtime_update(struct iguana_info *coin)
}
}
}
char str[65]; printf("check longest.%d RTheight.%d hwm.%d %s %p\n",coin->longestchain,coin->RTheight,coin->blocks.hwmchain.height,bits256_str(str,bp->hashes[0]),block);
//char str[65]; printf("check longest.%d RTheight.%d hwm.%d %s %p\n",coin->longestchain,coin->RTheight,coin->blocks.hwmchain.height,bits256_str(str,bp->hashes[0]),block);
if ( bits256_cmp(coin->RThash1,bp->hashes[1]) != 0 )
coin->RThash1 = bp->hashes[1];
bp->lastRT = (uint32_t)time(NULL);

2088
iguana/js/BTCD_hdrs.js

File diff suppressed because it is too large

16
iguana/main.c

@ -1082,7 +1082,7 @@ int maingen(int argc, char** argv)
void iguana_main(void *arg)
{
int32_t usessl = 0, ismainnet = 1; int32_t i; struct iguana_info *btc,*btcd;
int32_t usessl = 0, ismainnet = 1; int32_t i; struct iguana_info *btcd=0; //*btc=0,
struct supernet_info *myinfo; char *tmpstr,*helperargs,*coinargs,helperstr[512];
mycalloc(0,0,0);
myinfo = SuperNET_MYINFO(0);
@ -1138,7 +1138,7 @@ void iguana_main(void *arg)
iguana_initQ(&validateQ,"validateQ");
myinfo->rpcport = IGUANA_RPCPORT;
strcpy(myinfo->rpcsymbol,"BTCD");
if ( arg != 0 )
if ( 0 && arg != 0 )
{
cJSON *argjson;
if ( (argjson= cJSON_Parse(arg)) != 0 )
@ -1163,20 +1163,19 @@ void iguana_main(void *arg)
}
OS_ensure_directory("help");
OS_ensure_directory("confs");
OS_ensure_directory("accounts");
OS_ensure_directory("DB"), OS_ensure_directory("DB/ECB");
OS_ensure_directory("tmp");
OS_ensure_directory("purgeable");
OS_ensure_directory("purgeable/BTC");
OS_ensure_directory("purgeable/BTCD");
OS_ensure_directory(GLOBALTMPDIR);
btc = iguana_coinadd("BTC",0);
btcd = iguana_coinadd("BTCD",0);
if ( btc == 0 || btcd == 0 )
/*btc = 0;//iguana_coinadd("BTC",0);
if ( btc == 0 && btcd == 0 )
{
printf("error adding BTC.%p or BTCD.%p\n",btc,btcd);
exit(-1);
}
}*/
if ( (tmpstr= SuperNET_JSON(myinfo,cJSON_Parse("{\"agent\":\"SuperNET\",\"method\":\"help\"}"),0,myinfo->rpcport)) != 0 )
{
if ( (API_json= cJSON_Parse(tmpstr)) != 0 && (API_json= jobj(API_json,"result")) != 0 )
@ -1194,11 +1193,11 @@ void iguana_main(void *arg)
if ( 0 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"prefetchlag\":2,\"VALIDATE\":1,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTC\",\"startpend\":166,\"services\":1}"),0,myinfo->rpcport)) != 0 )
free(str);
#ifdef __APPLE__
#ifdef __PNACL__
if ( 1 )
{
sleep(1);
if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"VALIDATE\":1,\"prefetchlag\":13,\"startpend\":2048,\"endpend\":2048,\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":0,\"maxpeers\":64,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":8,\"poll\":10}"),0,myinfo->rpcport)) != 0 )
if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"VALIDATE\":1,\"prefetchlag\":13,\"startpend\":1,\"endpend\":1,\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":0,\"maxpeers\":64,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":1,\"poll\":10}"),0,myinfo->rpcport)) != 0 )
{
free(str);
if ( 0 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":1024,\"maxpeers\":256,\"newcoin\":\"BTCD\",\"active\":1}"),0,myinfo->rpcport)) != 0 )
@ -1216,6 +1215,7 @@ void iguana_main(void *arg)
}
sleep(1);
}
if ( 0 )
{
int32_t i,n; int64_t total; char *coinaddr; struct iguana_pkhash *P; struct iguana_info *coin; uint8_t rmd160[20],addrtype,pubkey33[33]; double startmillis;
coin = iguana_coinfind("BTCD");

BIN
iguana/pnacl/Release/iguana.pexe

Binary file not shown.

2
pnacl_main.h

@ -40,7 +40,7 @@ void *CHROMEAPP_NAME(void *arg)
while ( initflag == 0 )
usleep(1000000);
PNACL_message("%s start.(%s)\n",CHROMEAPP_STR,(char *)arg);
CHROMEAPP_MAIN(arg);
CHROMEAPP_MAIN("{}");//arg);
return(0);
}

Loading…
Cancel
Save