Browse Source

test

release/v0.1
jl777 8 years ago
parent
commit
2f411f119f
  1. 2
      crypto777/OS_nonportable.c
  2. 40
      iguana/SuperNET_keys.c
  3. 8
      iguana/iguana777.c
  4. 2
      iguana/iguana_bundles.c
  5. 21
      iguana/iguana_exchanges.c
  6. 27
      iguana/iguana_init.c
  7. 61
      iguana/main.c
  8. 3
      includes/iguana_apideclares.h

2
crypto777/OS_nonportable.c

@ -520,7 +520,7 @@ void *OS_nonportable_mapfile(char *fname,uint64_t *filesizep,int32_t enablewrite
_close(fd); _close(fd);
if ( ptr == 0 || ptr == MAP_FAILED ) if ( ptr == 0 || ptr == MAP_FAILED )
{ {
if ( rwflag != 0 ) if ( enablewrite != 0 )
printf("map_file.write%d: mapping %s failed? mp %p\n",enablewrite,fname,ptr); printf("map_file.write%d: mapping %s failed? mp %p\n",enablewrite,fname,ptr);
return(0); return(0);
} }

40
iguana/SuperNET_keys.c

@ -23,6 +23,46 @@
#include "../includes/cJSON.h" #include "../includes/cJSON.h"
/*
if ( 0 )
{
int32_t i,max=10000000; FILE *fp; bits256 check,val,hash = rand256(0);
if ( (fp= fopen("/tmp/seeds2","rb")) != 0 )
{
if ( fread(&check,1,sizeof(check),fp) != sizeof(check) )
printf("check read error\n");
for (i=1; i<max; i++)
{
if ( (i % 1000000) == 0 )
fprintf(stderr,".");
if ( fread(&val,1,sizeof(val),fp) != sizeof(val) )
printf("val read error\n");
hash = bits256_sha256(val);
hash = bits256_sha256(hash);
if ( bits256_cmp(hash,check) != 0 )
printf("hash error at i.%d\n",i);
check = val;
}
printf("validated %d seeds\n",max);
getchar();
}
else if ( (fp= fopen("/tmp/seeds2","wb")) != 0 )
{
for (i=0; i<max; i++)
{
if ( (i % 1000000) == 0 )
fprintf(stderr,".");
hash = bits256_sha256(hash);
hash = bits256_sha256(hash);
fseek(fp,(max-i-1) * sizeof(bits256),SEEK_SET);
if ( fwrite(hash.bytes,1,sizeof(hash),fp) != sizeof(hash) )
printf("error writing hash[%d] i.%d\n",(max-i-1),i);
}
fclose(fp);
}
}
*/
bits256 SuperNET_wallet2shared(bits256 wallethash,bits256 wallet2priv) bits256 SuperNET_wallet2shared(bits256 wallethash,bits256 wallet2priv)
{ {
bits256 wallet2shared,seed,wallet2pub; bits256 wallet2shared,seed,wallet2pub;

8
iguana/iguana777.c

@ -967,14 +967,6 @@ int32_t iguana_launchcoin(struct supernet_info *myinfo,char *symbol,cJSON *json,
coin->launched = iguana_launch(coin,"iguana_coinloop",iguana_coinloop,coins,IGUANA_PERMTHREAD); coin->launched = iguana_launch(coin,"iguana_coinloop",iguana_coinloop,coins,IGUANA_PERMTHREAD);
coin->active = 1; coin->active = 1;
coin->started = 0; coin->started = 0;
if ( strcmp("BTCD",coin->symbol) == 0 )
{
char *str;
if ( (str= basilisk_addrelay_info(myinfo,0,(uint32_t)calc_ipbits("78.47.196.146"),GENESIS_PUBKEY)) != 0 )
free(str);
if ( (str= basilisk_addrelay_info(myinfo,0,(uint32_t)calc_ipbits("5.9.102.210"),GENESIS_PUBKEY)) != 0 )
free(str);
}
return(1); return(1);
} }
else else

2
iguana/iguana_bundles.c

@ -322,6 +322,8 @@ int32_t iguana_bundlehash2add(struct iguana_info *coin,struct iguana_block **blo
} else err |= 128; } else err |= 128;
if ( err != 0 ) if ( err != 0 )
{ {
static uint32_t counter;
if ( counter++ < 100 )
printf("bundlehash2add err.%d\n",err); printf("bundlehash2add err.%d\n",err);
//return(0); //return(0);
} }

21
iguana/iguana_exchanges.c

@ -54,11 +54,13 @@ double instantdex_aveprice(struct supernet_info *myinfo,struct exchange_quote *s
if ( basevolume < 0. ) if ( basevolume < 0. )
basevolume = -basevolume, dir = -1; basevolume = -basevolume, dir = -1;
else dir = 1; else dir = 1;
#ifdef INCLUDE_PAX
if ( rel == 0 || rel[0] == 0 ) if ( rel == 0 || rel[0] == 0 )
{ {
*totalvolp = 1.; *totalvolp = 1.;
return(PAX_aveprice(myinfo,base)); return(PAX_aveprice(myinfo,base));
} }
#endif
memset(sortbuf,0,sizeof(*sortbuf) * max); memset(sortbuf,0,sizeof(*sortbuf) * max);
if ( base != 0 && rel != 0 && basevolume > SMALLVAL ) if ( base != 0 && rel != 0 && basevolume > SMALLVAL )
{ {
@ -118,7 +120,7 @@ double instantdex_aveprice(struct supernet_info *myinfo,struct exchange_quote *s
double instantdex_avehbla(struct supernet_info *myinfo,double retvals[4],char *_base,char *_rel,double basevolume) double instantdex_avehbla(struct supernet_info *myinfo,double retvals[4],char *_base,char *_rel,double basevolume)
{ {
int32_t basenum,relnum; double baseval,relval,avebid,aveask,bidvol,askvol; struct exchange_quote sortbuf[2560]; cJSON *argjson; char base[64],rel[64]; double avebid,aveask,bidvol,askvol; struct exchange_quote sortbuf[2560]; cJSON *argjson; char base[64],rel[64];
if ( retvals == 0 ) if ( retvals == 0 )
return(0); return(0);
strcpy(base,_base); strcpy(base,_base);
@ -132,11 +134,14 @@ double instantdex_avehbla(struct supernet_info *myinfo,double retvals[4],char *_
avebid = instantdex_aveprice(myinfo,sortbuf,sizeof(sortbuf)/(4*sizeof(*sortbuf)),&bidvol,base,rel,-basevolume,argjson); avebid = instantdex_aveprice(myinfo,sortbuf,sizeof(sortbuf)/(4*sizeof(*sortbuf)),&bidvol,base,rel,-basevolume,argjson);
free_json(argjson); free_json(argjson);
retvals[0] = avebid, retvals[1] = bidvol, retvals[2] = aveask, retvals[3] = askvol; retvals[0] = avebid, retvals[1] = bidvol, retvals[2] = aveask, retvals[3] = askvol;
#ifdef INCLUDE_PAX
int32_t basenum,relnum; double baseval,relval;
if ( (basenum= PAX_basenum(base)) >= 0 && (relnum= PAX_basenum(rel)) >= 0 ) if ( (basenum= PAX_basenum(base)) >= 0 && (relnum= PAX_basenum(rel)) >= 0 )
{ {
if ( myinfo->PEGS != 0 && (baseval= myinfo->PEGS->data.RTmatrix[basenum][basenum]) != 0. && (relval= myinfo->PEGS->data.RTmatrix[relnum][relnum]) != 0. ) if ( myinfo->PEGS != 0 && (baseval= myinfo->PEGS->data.RTmatrix[basenum][basenum]) != 0. && (relval= myinfo->PEGS->data.RTmatrix[relnum][relnum]) != 0. )
return(baseval / relval); return(baseval / relval);
} }
#endif
if ( avebid > SMALLVAL && aveask > SMALLVAL ) if ( avebid > SMALLVAL && aveask > SMALLVAL )
return((avebid + aveask) * .5); return((avebid + aveask) * .5);
else return(0); else return(0);
@ -727,9 +732,11 @@ char *exchanges777_process(struct exchange_info *exchange,int32_t *retvalp,struc
void exchanges777_loop(void *ptr) void exchanges777_loop(void *ptr)
{ {
struct peggy_info *PEGS=0; struct supernet_info *myinfo; struct exchange_info *exchange = ptr; struct supernet_info *myinfo; struct exchange_info *exchange = ptr;
int32_t flag,retval,i,peggyflag = 0; struct exchange_request *req; char *retstr; int32_t flag,retval,i; struct exchange_request *req; char *retstr;
myinfo = SuperNET_MYINFO(0); myinfo = SuperNET_MYINFO(0);
#ifdef INCLUDE_PAX
struct peggy_info *PEGS=0; int32_t peggyflag = 0;
if ( strcmp(exchange->name,"PAX") == 0 ) if ( strcmp(exchange->name,"PAX") == 0 )
{ {
if ( (PEGS= myinfo->PEGS) != 0 ) if ( (PEGS= myinfo->PEGS) != 0 )
@ -740,9 +747,11 @@ void exchanges777_loop(void *ptr)
PEGS->lastupdate = (uint32_t)time(NULL); PEGS->lastupdate = (uint32_t)time(NULL);
} }
} }
#endif
printf("exchanges loop.(%s)\n",exchange->name); printf("exchanges loop.(%s)\n",exchange->name);
while ( 1 ) while ( 1 )
{ {
#ifdef INCLUDE_PAX
if ( peggyflag != 0 && PEGS != 0 ) if ( peggyflag != 0 && PEGS != 0 )
{ {
//printf("nonz peggy\n"); //printf("nonz peggy\n");
@ -753,6 +762,7 @@ void exchanges777_loop(void *ptr)
PEGS->lastupdate = (uint32_t)time(NULL); PEGS->lastupdate = (uint32_t)time(NULL);
} }
} }
#endif
flag = retval = 0; flag = retval = 0;
retstr = 0; retstr = 0;
if ( (req= queue_dequeue(&exchange->requestQ,0)) != 0 ) if ( (req= queue_dequeue(&exchange->requestQ,0)) != 0 )
@ -1373,9 +1383,12 @@ THREE_STRINGS_AND_THREE_INTS(iguana,prices,exchange,base,rel,period,start,end)
INT_AND_ARRAY(iguana,rates,unused,quotes) INT_AND_ARRAY(iguana,rates,unused,quotes)
{ {
int32_t i,n,len,j,haveslash,nonz; char *str,*retstr,*quote,base[64][64],rel[64][64],field[64]; double aveprice; cJSON *tmpjson,*item,*array=0,*retjson = cJSON_CreateObject(); int32_t i,n,len,j,haveslash; char *retstr,*quote,base[64][64],rel[64][64],field[64]; double aveprice; cJSON *tmpjson,*item,*array=0,*retjson = cJSON_CreateObject();
#ifdef INCLUDE_PAX
char *str; int32_t nonz;
if ( myinfo->PEGS != 0 && (str= peggy_emitprices(&nonz,myinfo->PEGS,(uint32_t)time(NULL),PEGGY_MAXLOCKDAYS)) != 0 ) if ( myinfo->PEGS != 0 && (str= peggy_emitprices(&nonz,myinfo->PEGS,(uint32_t)time(NULL),PEGGY_MAXLOCKDAYS)) != 0 )
free(str); free(str);
#endif
if ( is_cJSON_Array(quotes) != 0 && (n= cJSON_GetArraySize(quotes)) > 0 ) if ( is_cJSON_Array(quotes) != 0 && (n= cJSON_GetArraySize(quotes)) > 0 )
{ {
if ( n > 64 ) if ( n > 64 )

27
iguana/iguana_init.c

@ -507,10 +507,8 @@ struct iguana_info *iguana_coinstart(struct iguana_info *coin,int32_t initialhei
} }
if ( initialheight < coin->chain->bundlesize*10 ) if ( initialheight < coin->chain->bundlesize*10 )
initialheight = coin->chain->bundlesize*10; initialheight = coin->chain->bundlesize*10;
//iguana_recvalloc(coin,initialheight);
if ( coin->longestchain == 0 ) if ( coin->longestchain == 0 )
coin->longestchain = 1; coin->longestchain = 1;
printf("clear hwmchain\n");
memset(&coin->blocks.hwmchain,0,sizeof(coin->blocks.hwmchain)); memset(&coin->blocks.hwmchain,0,sizeof(coin->blocks.hwmchain));
coin->blocks.hwmchain.height = 0; coin->blocks.hwmchain.height = 0;
coin->blocks.hwmchain.RO.allocsize = coin->chain->zcash != 0 ? sizeof(struct iguana_zblock) : sizeof(struct iguana_block); coin->blocks.hwmchain.RO.allocsize = coin->chain->zcash != 0 ? sizeof(struct iguana_zblock) : sizeof(struct iguana_block);
@ -585,31 +583,6 @@ struct iguana_info *iguana_coinstart(struct iguana_info *coin,int32_t initialhei
} }
else else
{ {
/*#include "confs/BTCD_hdrs.h"
if ( strcmp(coin->symbol,"BTCD") == 0 )
{
bits256 hash2,allhash,hash1; int32_t bundlei,i,nonz,height; struct iguana_bundle *bp;
for (i=nonz=0; i<sizeof(BTCD_hdrs)/sizeof(*BTCD_hdrs); i++)
{
height = atoi(BTCD_hdrs[i][0]);
if ( height > (coin->blocks.maxbits - 1000) )
iguana_recvalloc(coin,height + 100000);
hash2 = bits256_conv(BTCD_hdrs[i][1]);
if ( BTCD_hdrs[i][2][0] != 0 )
allhash = bits256_conv(BTCD_hdrs[i][2]);
if ( BTCD_hdrs[i][3][0] != 0 )
hash1 = bits256_conv(BTCD_hdrs[i][3]);
if ( (bp= iguana_bundlecreate(coin,&bundlei,height,hash2,allhash,0)) != 0 )
{
if ( iguana_bundleinitmap(coin,bp,height,hash2,hash1) == 0 )
lastbundle = hash2, nonz++;
}
}
printf("H file.[%d] nonz.%d\n",i,nonz);
//if ( bits256_nonz(lastbundle) != 0 )
// iguana_initfinal(coin,lastbundle);
//break;
}*/
} }
#endif #endif
sprintf(fname,"%s/%s_%s.txt",GLOBAL_CONFSDIR,coin->symbol,(iter == 0) ? "peers" : "hdrs"), OS_compatible_path(fname); sprintf(fname,"%s/%s_%s.txt",GLOBAL_CONFSDIR,coin->symbol,(iter == 0) ? "peers" : "hdrs"), OS_compatible_path(fname);

61
iguana/main.c

@ -705,7 +705,7 @@ void iguana_launchdaemons(struct supernet_info *myinfo)
printf("helper launch[%d] of %d (%s)\n",i,IGUANA_NUMHELPERS,helperstr); printf("helper launch[%d] of %d (%s)\n",i,IGUANA_NUMHELPERS,helperstr);
iguana_launch(0,"iguana_helper",iguana_helper,helperargs,IGUANA_PERMTHREAD); iguana_launch(0,"iguana_helper",iguana_helper,helperargs,IGUANA_PERMTHREAD);
} }
iguana_launch(0,"rpcloop",iguana_rpcloop,myinfo,IGUANA_PERMTHREAD); iguana_launch(0,"rpcloop",iguana_rpcloop,myinfo,IGUANA_PERMTHREAD); // limit to oneprocess
printf("launch mainloop\n"); printf("launch mainloop\n");
mainloop(myinfo); mainloop(myinfo);
} }
@ -1514,6 +1514,14 @@ FOUR_STRINGS(SuperNET,login,handle,password,permanentfile,passphrase)
#include "../includes/iguana_apiundefs.h" #include "../includes/iguana_apiundefs.h"
void iguana_relays_init(struct supernet_info *myinfo)
{
char *str;
if ( (str= basilisk_addrelay_info(myinfo,0,(uint32_t)calc_ipbits("78.47.196.146"),GENESIS_PUBKEY)) != 0 )
free(str);
if ( (str= basilisk_addrelay_info(myinfo,0,(uint32_t)calc_ipbits("5.9.102.210"),GENESIS_PUBKEY)) != 0 )
free(str);
}
void iguana_main(void *arg) void iguana_main(void *arg)
{ {
@ -1526,45 +1534,6 @@ void iguana_main(void *arg)
mycalloc(0,0,0); mycalloc(0,0,0);
decode_hex(CRYPTO777_RMD160,20,CRYPTO777_RMD160STR); decode_hex(CRYPTO777_RMD160,20,CRYPTO777_RMD160STR);
decode_hex(CRYPTO777_PUBSECP33,33,CRYPTO777_PUBSECPSTR); decode_hex(CRYPTO777_PUBSECP33,33,CRYPTO777_PUBSECPSTR);
if ( 0 )
iguana_signalsinit();
if ( 0 )
{
int32_t i,max=10000000; FILE *fp; bits256 check,val,hash = rand256(0);
if ( (fp= fopen("/tmp/seeds2","rb")) != 0 )
{
if ( fread(&check,1,sizeof(check),fp) != sizeof(check) )
printf("check read error\n");
for (i=1; i<max; i++)
{
if ( (i % 1000000) == 0 )
fprintf(stderr,".");
if ( fread(&val,1,sizeof(val),fp) != sizeof(val) )
printf("val read error\n");
hash = bits256_sha256(val);
hash = bits256_sha256(hash);
if ( bits256_cmp(hash,check) != 0 )
printf("hash error at i.%d\n",i);
check = val;
}
printf("validated %d seeds\n",max);
getchar();
}
else if ( (fp= fopen("/tmp/seeds2","wb")) != 0 )
{
for (i=0; i<max; i++)
{
if ( (i % 1000000) == 0 )
fprintf(stderr,".");
hash = bits256_sha256(hash);
hash = bits256_sha256(hash);
fseek(fp,(max-i-1) * sizeof(bits256),SEEK_SET);
if ( fwrite(hash.bytes,1,sizeof(hash),fp) != sizeof(hash) )
printf("error writing hash[%d] i.%d\n",(max-i-1),i);
}
fclose(fp);
}
}
iguana_ensuredirs(); iguana_ensuredirs();
iguana_Qinit(); iguana_Qinit();
myinfo = SuperNET_MYINFO(0); myinfo = SuperNET_MYINFO(0);
@ -1578,15 +1547,12 @@ void iguana_main(void *arg)
myinfo->rpcport = IGUANA_RPCPORT; myinfo->rpcport = IGUANA_RPCPORT;
strcpy(myinfo->rpcsymbol,"BTCD"); strcpy(myinfo->rpcsymbol,"BTCD");
iguana_urlinit(myinfo,ismainnet,usessl); iguana_urlinit(myinfo,ismainnet,usessl);
//category_init(myinfo);
#if LIQUIDITY_PROVIDER #if LIQUIDITY_PROVIDER
myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("bitcoin"),0); myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("bitcoin"),0);
myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("poloniex"),0); myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("poloniex"),0);
myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("bittrex"),0); myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("bittrex"),0);
myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("btc38"),0); myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("btc38"),0);
myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("huobi"),0); myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("huobi"),0);
//myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("instaforex"),0);
//myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("bitfinex"),0);
myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("coinbase"),0); myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("coinbase"),0);
myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("lakebtc"),0); myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("lakebtc"),0);
myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("quadriga"),0); myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("quadriga"),0);
@ -1594,20 +1560,13 @@ void iguana_main(void *arg)
myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("btce"),0); myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("btce"),0);
myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("bitstamp"),0); myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("bitstamp"),0);
#endif #endif
//argjson = arg != 0 ? cJSON_Parse(arg) : cJSON_Parse("{}");
//iguana_coinadd("BTC",argjson); dont do this here, coin args not set
///iguana_coinadd("LTC",argjson);
//free_json(argjson);
printf("helpinit\n");
iguana_helpinit(myinfo); iguana_helpinit(myinfo);
printf("basilisks_init\n"); iguana_relays_init(myinfo);
basilisks_init(myinfo); basilisks_init(myinfo);
printf("iguana_commandline\n");
iguana_commandline(myinfo,arg); iguana_commandline(myinfo,arg);
#ifdef __APPLE__ #ifdef __APPLE__
iguana_appletests(myinfo); iguana_appletests(myinfo);
#endif #endif
printf("iguana_launchdaemons\n");
iguana_launchdaemons(myinfo); iguana_launchdaemons(myinfo);
} }

3
includes/iguana_apideclares.h

@ -13,7 +13,10 @@
* * * *
******************************************************************************/ ******************************************************************************/
#ifdef INCLUDE_PAX
ZERO_ARGS(pax,start); ZERO_ARGS(pax,start);
#endif
INT_AND_ARRAY(iguana,rates,unused,quotes); INT_AND_ARRAY(iguana,rates,unused,quotes);
TWO_STRINGS(iguana,rate,base,rel); TWO_STRINGS(iguana,rate,base,rel);
THREE_STRINGS_AND_THREE_INTS(iguana,prices,exchange,base,rel,period,start,end); THREE_STRINGS_AND_THREE_INTS(iguana,prices,exchange,base,rel,period,start,end);

Loading…
Cancel
Save