Browse Source

Merge branch 'master' into release/v0.1

release/v0.1
jl777 8 years ago
parent
commit
15816e5c1c
  1. 17
      basilisk/basilisk.c
  2. 21
      basilisk/basilisk_DEX.c
  3. 2
      basilisk/basilisk_MSG.c
  4. 2
      basilisk/basilisk_tradebot.c
  5. 2
      iguana/iguana777.c
  6. 7
      iguana/iguana_bundles.c
  7. 2
      iguana/iguana_json.c
  8. 2
      iguana/iguana_realtime.c
  9. 22
      iguana/iguana_spendvectors.c
  10. 11
      iguana/iguana_unspents.c
  11. 2
      iguana/main.c
  12. 2
      includes/iguana_defines.h

17
basilisk/basilisk.c

@ -206,15 +206,18 @@ int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *typ
return(-1);
}
if ( basilisk_notarycmd(type) != 0 && myinfo->NOTARY.NUMRELAYS == 0 )
{
printf("no notary nodes to send (%s) to\n",type);
return(-1);
}
//portable_mutex_lock(&myinfo->allcoins_mutex);
alreadysent = calloc(IGUANA_MAXPEERS * IGUANA_MAXCOINS,sizeof(*alreadysent));
HASH_ITER(hh,myinfo->allcoins,coin,tmp)
{
if ( coin->peers == 0 )
continue;
//if ( basilisk_notarycmd(type) != 0 && strcmp(coin->symbol,"NOTARY") != 0 )
// continue;
if ( basilisk_notarycmd(type) != 0 && strcmp(coin->symbol,"NOTARY") != 0 )
continue;
if ( coin->FULLNODE == 0 && coin->VALIDATENODE == 0 )
cmd[0] = 's';
else cmd[0] = 'S';
@ -230,7 +233,7 @@ int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *typ
{
s = 0;
valid = (addr->supernet != 0);
if ( basilisk_notarycmd(type) != 0 )
if ( basilisk_notarycmd(type) != 0 || (strcmp(type,"INF") == 0 && strcmp(coin->symbol,"NOTARY") == 0) )
{
valid = 0;
/*OS_randombytes((void *)&r2,sizeof(r2));
@ -258,7 +261,7 @@ int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *typ
}
if ( s == n && valid == 1 && (destipaddr == 0 || strcmp(addr->ipaddr,destipaddr) == 0) )
{
//fprintf(stderr,"(%s).%u ",addr->ipaddr,coin->chain->portp2p);
//fprintf(stderr,">>> (%s).%u ",addr->ipaddr,coin->chain->portp2p);
//printf("n.%d/fanout.%d i.%d l.%d [%s].tag%u send %s.(%s) [%x] datalen.%d addr->supernet.%u basilisk.%u to (%s).%d destip.%s\n",n,fanout,i,l,cmd,*(uint32_t *)data,type,(char *)&data[4],*(int32_t *)&data[datalen-4],datalen,addr->supernet,addr->basilisk,addr->ipaddr,addr->A.port,destipaddr!=0?destipaddr:"broadcast");
if ( encryptflag != 0 && bits256_nonz(addr->pubkey) != 0 )
{
@ -801,7 +804,7 @@ void basilisk_p2p(void *_myinfo,void *_addr,char *senderip,uint8_t *data,int32_t
void basilisk_requests_poll(struct supernet_info *myinfo)
{
char *retstr; cJSON *outerarray,*retjson; int32_t i,n; struct basilisk_request issueR; double hwm = 0.;
char *retstr; uint8_t data[8192]; cJSON *outerarray,*retjson; int32_t datalen,i,n; struct basilisk_request issueR; double hwm = 0.;
memset(&issueR,0,sizeof(issueR));
if ( (retstr= InstantDEX_incoming(myinfo,0,0,0,0)) != 0 )
{
@ -829,9 +832,11 @@ void basilisk_requests_poll(struct supernet_info *myinfo)
}
else //if ( issueR.quoteid == 0 )
{
printf("other req hwm %f\n",hwm);
printf("other req hwm %f >>>>>>>>>>> send response\n",hwm);
issueR.quoteid = basilisk_quoteid(&issueR);
issueR.desthash = myinfo->myaddr.persistent;
datalen = basilisk_rwDEXquote(1,data,&issueR);
basilisk_channelsend(myinfo,issueR.desthash,'D' + ((uint32_t)'E' << 8) + ((uint32_t)'X' << 16),(uint32_t)time(NULL),data,datalen,0);
if ( (retstr= basilisk_start(myinfo,&issueR,0)) != 0 )
free(retstr);
} //else printf("basilisk_requests_poll unexpected hwm issueR\n");

21
basilisk/basilisk_DEX.c

@ -413,7 +413,7 @@ ZERO_ARGS(InstantDEX,allcoins)
STRING_ARG(InstantDEX,available,source)
{
char *retstr; cJSON *vals,*balancejson,*retjson = 0;
char *retstr; uint64_t total = 0; int32_t i,n; cJSON *item,*vals,*unspents,*balancejson,*retjson = 0;
if ( source != 0 && source[0] != 0 && (coin= iguana_coinfind(source)) != 0 )
{
if ( myinfo->expiration != 0 )
@ -426,9 +426,24 @@ STRING_ARG(InstantDEX,available,source)
printf("available.(%s)\n",retstr);
if ( (balancejson= cJSON_Parse(retstr)) != 0 )
{
if ( (unspents= jarray(&n,balancejson,"unspents")) != 0 )
{
for (i=0; i<n; i++)
{
item = jitem(unspents,i);
if ( jobj(item,"unspent") != 0 )
{
total += jdouble(item,"amount") * SATOSHIDEN;
printf("(%s) -> %.8f\n",jprint(item,0),dstr(total));
}
}
}
if ( total == 0 )
total = 500000;
retjson = cJSON_CreateObject();
jaddnum(retjson,"result",jdouble(balancejson,"balance"));
jaddnum(retjson,"result",dstr(total));
free_json(balancejson);
printf("n.%d total %.8f (%s)\n",n,dstr(total),jprint(retjson,0));
}
free(retstr);
}
@ -447,7 +462,7 @@ STRING_ARG(InstantDEX,available,source)
HASH_ARRAY_STRING(InstantDEX,request,hash,vals,hexstr)
{
uint8_t serialized[512]; struct basilisk_request R; cJSON *reqjson; uint32_t datalen=0,DEX_channel;
myinfo->DEXactive = (uint32_t)time(NULL) + BASILISK_TIMEOUT;
myinfo->DEXactive = (uint32_t)time(NULL) + 3*BASILISK_TIMEOUT;
jadd64bits(vals,"minamount",jdouble(vals,"minprice") * jdouble(vals,"amount") * SATOSHIDEN);
if ( jobj(vals,"srchash") == 0 )
jaddbits256(vals,"srchash",myinfo->myaddr.pubkey);

2
basilisk/basilisk_MSG.c

@ -261,7 +261,7 @@ int32_t basilisk_channelsend(struct supernet_info *myinfo,bits256 hash,uint32_t
jaddnum(valsobj,"msgid",msgid);
jaddnum(valsobj,"duration",duration);
jaddbits256(valsobj,"sender",myinfo->myaddr.persistent);
//char str[65]; printf("sendmessage.[%d] channel.%u msgid.%x -> %s numrelays.%d:%d\n",datalen,channel,msgid,bits256_str(str,hash),myinfo->NOTARY.NUMRELAYS,juint(valsobj,"fanout"));
char str[65]; printf("sendmessage.[%d] channel.%u msgid.%x -> %s numrelays.%d:%d\n",datalen,channel,msgid,bits256_str(str,hash),myinfo->NOTARY.NUMRELAYS,juint(valsobj,"fanout"));
if ( (retstr= basilisk_sendmessage(myinfo,0,0,0,hash,valsobj,hexstr)) != 0 )
free(retstr);
free_json(valsobj);

2
basilisk/basilisk_tradebot.c

@ -249,7 +249,7 @@ double basilisk_process_results(struct supernet_info *myinfo,struct basilisk_req
if ( (hexdata= get_dataptr(0,&allocptr,&hexlen,hexspace,sizeof(hexspace),hexstr)) != 0 )
{
basilisk_rwDEXquote(0,hexdata,&R);
//printf("[%d].(%s)\n",i,jprint(basilisk_requestjson(&R),1));
printf("[%d].(%s)\n",i,jprint(basilisk_requestjson(&R),1));
}
} else basilisk_parsejson(&R,item);
if ( nonz != 0 )

2
iguana/iguana777.c

@ -627,7 +627,7 @@ int32_t iguana_coin_mainiter(struct supernet_info *myinfo,struct iguana_info *co
iguana_alloctxbits(coin,&coin->bundles[j]->ramchain);
sleep(3);
}*/
if ( (iguana_utxofinished(coin) < n || iguana_balancefinished(coin) < n || iguana_validated(coin) < n) )
if ( iguana_utxofinished(coin) < n )//|| iguana_balancefinished(coin) < n || iguana_validated(coin) < n) )
{
//printf("About to generate tables\n"), getchar();
iguana_fastfindreset(coin);

7
iguana/iguana_bundles.c

@ -217,9 +217,10 @@ int32_t iguana_bundlehash2add(struct iguana_info *coin,struct iguana_block **blo
{
if ( block->mainchain != 0 && (block->height % coin->chain->bundlesize) == bundlei && (block->height / coin->chain->bundlesize) == bp->hdrsi )
{
printf("would have bundle block override [%d:%d]\n",bp->hdrsi,bundlei);
//bp->blocks[bundlei] = block;
//bp->hashes[bundlei] = block->RO.hash2;
char str[65],str2[65];
printf("bundle block override [%d:%d] %s <- %s\n",bp->hdrsi,bundlei,bits256_str(str,bp->blocks[bundlei]->RO.hash2),bits256_str(str2,block->RO.hash2));
bp->blocks[bundlei] = block;
bp->hashes[bundlei] = block->RO.hash2;
}
else if ( block->mainchain == 0 )
{

2
iguana/iguana_json.c

@ -651,6 +651,8 @@ TWO_STRINGS(iguana,addnode,activecoin,ipaddr)
struct iguana_peer *addr; int32_t i,n;
if ( coin == 0 )
coin = iguana_coinfind(activecoin);
if ( strcmp(coin->symbol,"NOTARY") == 0 )
basilisk_addrelay_info(myinfo,0,(uint32_t)calc_ipbits(ipaddr),GENESIS_PUBKEY);
printf("coin.%p.[%s] addnode.%s -> %s\n",coin,coin!=0?coin->symbol:"",activecoin,ipaddr);
if ( coin != 0 && coin->peers != 0 && ipaddr != 0 && is_ipaddr(ipaddr) != 0 )
{

2
iguana/iguana_realtime.c

@ -781,7 +781,7 @@ void iguana_RTnewblock(struct supernet_info *myinfo,struct iguana_info *coin,str
}
if ( block != 0 && coin->RTheight > 0 && coin->utxoaddrtable != 0 )//&& coin->RTheight <= coin->blocks.hwmchain.height )
{
if ( block->height <= (coin->RTheight - coin->minconfirms + 1) )
if ( block->height < (coin->RTheight - coin->minconfirms + 1) )
return;
if ( (block= iguana_blockfind("RTnew",coin,iguana_blockhash(coin,block->height-coin->minconfirms))) == 0 )
return;

22
iguana/iguana_spendvectors.c

@ -618,7 +618,7 @@ int32_t iguana_volatilesinit(struct supernet_info *myinfo,struct iguana_info *co
struct sha256_vstate vstate,bstate; int32_t i,from_ro,numpkinds,numunspents; struct iguana_bundle *bp; struct iguana_block *block;
uint32_t crc,filecrc; FILE *fp; char crcfname[512],str[65],str2[65],buf[2048];
from_ro = 1;
for (i=0; i<coin->bundlescount; i++)//balanceswritten; i++)
for (i=0; i<coin->bundlescount; i++)
{
if ( (bp= coin->bundles[i]) == 0 )
continue;
@ -634,11 +634,13 @@ int32_t iguana_volatilesinit(struct supernet_info *myinfo,struct iguana_info *co
from_ro = 0;
}
}
if ( coin->longestchain <= coin->bundlescount*coin->chain->bundlesize-coin->chain->minconfirms )
printf("i.%d volatilesinit\n",i);
/*if ( strcmp("BTC",coin->symbol) == 0 && coin->longestchain > coin->bundlescount*coin->chain->bundlesize-coin->chain->minconfirms )
{
printf("SKIP checking volatile files %d > %d\n",coin->longestchain,coin->bundlescount*coin->chain->bundlesize-coin->chain->minconfirms);
iguana_bundlestats(myinfo,coin,buf,IGUANA_DEFAULTLAG);
return(coin->bundlescount);
}
}*/
/*if ( i < coin->balanceswritten-1 )
{
printf("TRUNCATE balances written.%d -> %d\n",coin->balanceswritten,i);
@ -705,13 +707,13 @@ int32_t iguana_volatilesinit(struct supernet_info *myinfo,struct iguana_info *co
}
else
{
printf("%s MATCHED balancehash numhdrsi.%d crc.%08x\n",coin->symbol,coin->balanceswritten,crc);
printf("%s MATCHED balancehash numhdrsi.%d crc.%08x LONGEST.%d\n",coin->symbol,coin->balanceswritten,crc,coin->longestchain);
if ( (fp= fopen(crcfname,"wb")) != 0 )
{
if ( fwrite(&crc,1,sizeof(crc),fp) != sizeof(crc) || fwrite(&balancehash,1,sizeof(balancehash),fp) != sizeof(balancehash) || fwrite(&allbundles,1,sizeof(allbundles),fp) != sizeof(allbundles) )
printf("error writing.(%s)\n",crcfname);
fclose(fp);
if ( coin->longestchain <= coin->bundlescount*coin->chain->bundlesize-coin->chain->minconfirms )
if ( (coin->longestchain+coin->chain->minconfirms)/coin->chain->bundlesize < coin->bundlescount*coin->chain->bundlesize )
{
for (i=0; i<coin->bundlescount-1; i++)
{
@ -723,9 +725,9 @@ int32_t iguana_volatilesinit(struct supernet_info *myinfo,struct iguana_info *co
coin->matchedfiles = 1;
coin->spendvectorsaved = (uint32_t)time(NULL);
coin->spendvalidated = 0;
printf("%s UTXOGEN spendvectorsaved <- %u\n",coin->symbol,coin->spendvectorsaved);
printf("LONGEST.%d %s UTXOGEN spendvectorsaved <- %u\n",coin->longestchain,coin->symbol,coin->spendvectorsaved);
iguana_utxoaddr_gen(myinfo,coin,(coin->bundlescount - 1) * coin->chain->bundlesize);
}
} else printf("(coin->longestchain+coin->chain->minconfirms)/coin->chain->bundlesize %d < %d coin->bundlescount*coin->chain->bundlesize\n",(coin->longestchain+coin->chain->minconfirms)/coin->chain->bundlesize,coin->bundlescount*coin->chain->bundlesize);
}
else
{
@ -789,7 +791,7 @@ void iguana_initfinal(struct supernet_info *myinfo,struct iguana_info *coin,bits
}
}
printf("%s i.%d bundlescount.%d\n",coin->symbol,i,coin->bundlescount);
if ( coin->balanceswritten > 1 )
//if ( coin->balanceswritten > 1 )
coin->balanceswritten = iguana_volatilesinit(myinfo,coin);
/*if ( coin->balanceswritten > 1 )
{
@ -803,7 +805,7 @@ void iguana_initfinal(struct supernet_info *myinfo,struct iguana_info *coin,bits
}
}*/
printf("%s i.%d balanceswritten.%d\n",coin->symbol,i,coin->balanceswritten);
if ( coin->balanceswritten < coin->bundlescount )
/*if ( coin->balanceswritten < coin->bundlescount )
{
for (i=0*coin->balanceswritten; i<coin->bundlescount; i++)
{
@ -816,7 +818,7 @@ void iguana_initfinal(struct supernet_info *myinfo,struct iguana_info *coin,bits
printf("iguana_bundlesQ %d to %d\n",coin->balanceswritten,coin->bundlescount);
}
if ( (coin->origbalanceswritten= coin->balanceswritten) > 0 )
iguana_volatilesinit(myinfo,coin);
iguana_volatilesinit(myinfo,coin);*/
iguana_savehdrs(coin);
iguana_fastlink(coin,coin->balanceswritten * coin->chain->bundlesize - 1);
iguana_walkchain(coin,0);

11
iguana/iguana_unspents.c

@ -366,8 +366,11 @@ struct iguana_pkhash *iguana_pkhashfind(struct iguana_info *coin,struct iguana_r
return(p);
} else if ( pkind != 0 )
printf("[%d] not found pkind.%d vs num.%d RT.%d rdata.%p\n",i,pkind,rdata->numpkinds,bp->isRT,rdata);
} else if ( coin->spendvectorsaved > 1 && bp != coin->current && bp->bundleheight < coin->firstRTheight )
printf("%s.[%d] skip null rdata isRT.%d [%d]\n",coin->symbol,i,bp->isRT,coin->current!=0?coin->current->hdrsi:-1);
}
else if ( coin->spendvectorsaved > 1 && bp != coin->current && bp->bundleheight < coin->firstRTheight )
{
//printf("%s.[%d] skip null rdata isRT.%d [%d]\n",coin->symbol,i,bp->isRT,coin->current!=0?coin->current->hdrsi:-1);
}
}
}
return(0);
@ -991,12 +994,12 @@ int32_t iguana_unspentfindjson(cJSON *destarray,cJSON *item)
cJSON *iguana_RTlistunspent(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *argarray,int32_t minconf,int32_t maxconf,char *remoteaddr,int32_t includespends)
{
int32_t i,j,m,n,numrmds,numunspents=0; char *coinaddr,*retstr; uint8_t *rmdarray; cJSON *vals,*unspents,*item,*array,*retjson,*retarray; bits256 hash;
uint64_t total = 0; int32_t i,j,m,n,numrmds,numunspents=0; char *coinaddr,*retstr; uint8_t *rmdarray; cJSON *vals,*unspents,*item,*array,*retjson,*retarray; bits256 hash;
if ( coin->FULLNODE != 0 || coin->VALIDATENODE != 0 )
{
retjson = cJSON_CreateArray();
rmdarray = iguana_rmdarray(myinfo,coin,&numrmds,argarray,0);
iguana_RTunspents(myinfo,coin,retjson,minconf,maxconf,rmdarray,numrmds,(1 << 30),0,&numunspents,remoteaddr,includespends);
total = iguana_RTunspents(myinfo,coin,retjson,minconf,maxconf,rmdarray,numrmds,(1 << 30),0,&numunspents,remoteaddr,includespends);
if ( rmdarray != 0 )
free(rmdarray);
}

2
iguana/main.c

@ -293,7 +293,7 @@ char *SuperNET_processJSON(struct supernet_info *myinfo,struct iguana_info *coin
{
if ( coin != 0 )
{
if ( iguana_immediate(coin,immedmillis) != 0 )
if ( immedmillis == 0 || iguana_immediate(coin,immedmillis) != 0 )
retjsonstr = SuperNET_jsonstr(myinfo,jsonstr,remoteaddr,port);
else retjsonstr = clonestr("{\"error\":\"coin is busy processing\"}");
} else retjsonstr = SuperNET_jsonstr(myinfo,jsonstr,remoteaddr,port);

2
includes/iguana_defines.h

@ -45,7 +45,7 @@
#define IGUANA_TAILPERCENTAGE 1.0
#define IGUANA_MAXPENDHDRS 1
#define IGUANA_BTCPENDINGREQUESTS 3
#define IGUANA_PENDINGREQUESTS 512
#define IGUANA_PENDINGREQUESTS 64
#define IGUANA_MINPENDBUNDLES 4
#define IGUANA_MAXPENDBUNDLES 64
#define IGUANA_RPCPORT 7778

Loading…
Cancel
Save