Browse Source

Xcode 8

etomic
jl777 8 years ago
parent
commit
da89efe292
  1. 30
      .gitignore
  2. 7
      basilisk/basilisk.c
  3. 2
      basilisk/basilisk_DEX.c
  4. 2
      basilisk/basilisk_MSG.c
  5. 2
      basilisk/basilisk_ping.c
  6. 4
      basilisk/basilisk_swap.c
  7. 1
      basilisk/basilisk_tradebot.c
  8. 10
      basilisk/tradebots_SVM.h
  9. 6
      basilisk/tradebots_liquidity.c
  10. 2
      crypto777/OS_portable.c
  11. 7
      crypto777/OS_time.c
  12. 3
      crypto777/SaM.c
  13. 10
      crypto777/bitcoind_RPC.c
  14. 2
      crypto777/iguana_OS.c
  15. 8
      crypto777/iguana_utils.c
  16. 4
      crypto777/inet.c
  17. 2
      crypto777/ramcoder.c
  18. 5
      datachain/datachain.c
  19. 4
      gecko/gecko.c
  20. 2
      gecko/gecko_headers.c
  21. 2
      gecko/gecko_miner.c
  22. 4
      iguana/SuperNET_keys.c
  23. 2
      iguana/cards777.c
  24. 1
      iguana/dpow/dpow_fsm.c
  25. 2
      iguana/dpow/dpow_prices.c
  26. 2
      iguana/dpow/dpow_tx.c
  27. 1
      iguana/exchanges/bitcoin.c
  28. 3
      iguana/exchanges/fxcm.c
  29. 8
      iguana/iguana777.c
  30. 2
      iguana/iguana_accept.c
  31. 8
      iguana/iguana_bitmap.c
  32. 8
      iguana/iguana_blocks.c
  33. 37
      iguana/iguana_bundles.c
  34. 8
      iguana/iguana_chains.c
  35. 2
      iguana/iguana_exchanges.c
  36. 4
      iguana/iguana_init.c
  37. 7
      iguana/iguana_interpreter.c
  38. 4
      iguana/iguana_json.c
  39. 7
      iguana/iguana_mofn.c
  40. 14
      iguana/iguana_msg.c
  41. 3
      iguana/iguana_notary.c
  42. 7
      iguana/iguana_payments.c
  43. 10
      iguana/iguana_peers.c
  44. 61
      iguana/iguana_ramchain.c
  45. 10
      iguana/iguana_realtime.c
  46. 62
      iguana/iguana_recv.c
  47. 2
      iguana/iguana_rpc.c
  48. 4
      iguana/iguana_scripts.c
  49. 6
      iguana/iguana_secp.c
  50. 26
      iguana/iguana_sign.c
  51. 26
      iguana/iguana_spendvectors.c
  52. 4
      iguana/iguana_tx.c
  53. 22
      iguana/iguana_txidfind.c
  54. 28
      iguana/iguana_unspents.c
  55. 2
      iguana/iguana_volatiles.c
  56. 4
      iguana/iguana_wallet.c
  57. 9
      iguana/m
  58. 14
      iguana/main.c
  59. 1
      iguana/mini-gmp.c
  60. 2
      iguana/pangea_api.c
  61. 2
      iguana/pangea_hand.c
  62. 2
      iguana/pangea_json.c
  63. 2
      iguana/ramchain_api.c
  64. 2
      iguana/secp256k1/src/ecmult_const_impl.h
  65. 2
      iguana/secp256k1/src/modules/rangeproof/rangeproof_impl.h
  66. 2
      iguana/secp256k1/src/modules/recovery/main_impl.h
  67. 10
      includes/iguana_structs.h

30
.gitignore

@ -37,3 +37,33 @@ iguana/confs/BTC_hdrs.txt
deprecated/.DS_Store deprecated/.DS_Store
.DS_Store .DS_Store
*.pbxproj
iguana/tmp/.tmpmarker
iguana/SVM/rawfeatures/.tmpmarker
iguana/DB/.tmpmarker
iguana/DB/TRANSACTIONS/.tmpmarker
iguana/DB/purgeable/.tmpmarker
iguana/DB/purgeable/BTCD/.tmpmarker
iguana/DB/purgeable/BTC/.tmpmarker
iguana/DB/ECB/.tmpmarker
iguana/genesis/.tmpmarker
iguana/help/.tmpmarker
iguana/SVM/.tmpmarker
iguana/SVM/models/.tmpmarker
SuperNET.xcodeproj/xcuserdata/mac.xcuserdatad/xcschemes/xcschememanagement.plist
SuperNET.xcodeproj/xcuserdata/mac.xcuserdatad/xcschemes/SuperNET.xcscheme

7
basilisk/basilisk.c

@ -265,6 +265,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) ) if ( s == n && valid == 1 && (destipaddr == 0 || strcmp(addr->ipaddr,destipaddr) == 0) )
{ {
val = 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 [%x] datalen.%d addr->supernet.%u basilisk.%u to (%s).%d destip.%s\n",n,fanout,i,l,cmd,*(uint32_t *)data,type,*(int32_t *)&data[datalen-4],datalen,addr->supernet,addr->basilisk,addr->ipaddr,addr->A.port,destipaddr!=0?destipaddr:"broadcast"); //printf("n.%d/fanout.%d i.%d l.%d [%s].tag%u send %s [%x] datalen.%d addr->supernet.%u basilisk.%u to (%s).%d destip.%s\n",n,fanout,i,l,cmd,*(uint32_t *)data,type,*(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 ) if ( encryptflag != 0 && bits256_nonz(addr->pubkey) != 0 )
@ -462,7 +463,7 @@ char *basilisk_standardservice(char *CMD,struct supernet_info *myinfo,void *_add
} }
ptr->finished = OS_milliseconds() + 10000; ptr->finished = OS_milliseconds() + 10000;
} }
if ( 0 && strcmp("MSG",CMD) == 0 ) if ( (0) && strcmp("MSG",CMD) == 0 )
printf("%s.(%s) -> (%s)\n",CMD,jprint(valsobj,0),retstr!=0?retstr:""); printf("%s.(%s) -> (%s)\n",CMD,jprint(valsobj,0),retstr!=0?retstr:"");
return(retstr); return(retstr);
} }
@ -793,10 +794,10 @@ int32_t basilisk_p2pQ_process(struct supernet_info *myinfo,int32_t maxiters)
else else
{ {
len += iguana_rwnum(0,ptr->data,sizeof(basilisktag),&basilisktag); len += iguana_rwnum(0,ptr->data,sizeof(basilisktag),&basilisktag);
if ( 0 && myinfo->IAMLP == 0 ) if ( (0) && myinfo->IAMLP == 0 )
printf("RELAYID.%d ->received.%d basilisk_p2p.(%s) from %s tag.%u\n",myinfo->NOTARY.RELAYID,ptr->datalen,ptr->type,senderip,basilisktag); printf("RELAYID.%d ->received.%d basilisk_p2p.(%s) from %s tag.%u\n",myinfo->NOTARY.RELAYID,ptr->datalen,ptr->type,senderip,basilisktag);
basilisk_msgprocess(myinfo,ptr->addr,ptr->ipbits,ptr->type,basilisktag,&ptr->data[len],ptr->datalen - len); basilisk_msgprocess(myinfo,ptr->addr,ptr->ipbits,ptr->type,basilisktag,&ptr->data[len],ptr->datalen - len);
if ( 0 && myinfo->IAMLP == 0 ) if ( (0) && myinfo->IAMLP == 0 )
printf("processed.%s from %s\n",ptr->type,senderip); printf("processed.%s from %s\n",ptr->type,senderip);
} }
free(ptr); free(ptr);

2
basilisk/basilisk_DEX.c

@ -681,7 +681,7 @@ HASH_ARRAY_STRING(InstantDEX,request,hash,vals,hexstr)
} else printf("error creating request\n"); } else printf("error creating request\n");
if ( datalen > 0 ) if ( datalen > 0 )
{ {
uint32_t msgid,crc,crcs[2],numiters = 0; uint8_t buf[4096]; uint32_t msgid,crc=0,crcs[2],numiters = 0; uint8_t buf[4096];
memset(hash.bytes,0,sizeof(hash)); memset(hash.bytes,0,sizeof(hash));
msgid = (uint32_t)time(NULL); msgid = (uint32_t)time(NULL);
DEX_channel = 'D' + ((uint32_t)'E' << 8) + ((uint32_t)'X' << 16); DEX_channel = 'D' + ((uint32_t)'E' << 8) + ((uint32_t)'X' << 16);

2
basilisk/basilisk_MSG.c

@ -538,7 +538,7 @@ uint32_t basilisk_crcrecv(struct supernet_info *myinfo,int32_t width,uint8_t *ve
uint32_t basilisk_crcsend(struct supernet_info *myinfo,int32_t width,uint8_t *verifybuf,int32_t maxlen,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits,uint8_t *data,int32_t datalen,uint32_t crcs[2]) uint32_t basilisk_crcsend(struct supernet_info *myinfo,int32_t width,uint8_t *verifybuf,int32_t maxlen,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits,uint8_t *data,int32_t datalen,uint32_t crcs[2])
{ {
uint32_t crc; int32_t recvlen; uint32_t crc; int32_t recvlen=0;
if ( crcs != 0 ) if ( crcs != 0 )
{ {
crc = calc_crc32(0,data,datalen); crc = calc_crc32(0,data,datalen);

2
basilisk/basilisk_ping.c

@ -107,7 +107,7 @@ int32_t basilisk_ping_genvirts(struct supernet_info *myinfo,uint8_t *data,int32_
int32_t basilisk_ping_processMSG(struct supernet_info *myinfo,uint32_t senderipbits,uint8_t *data,int32_t datalen) int32_t basilisk_ping_processMSG(struct supernet_info *myinfo,uint32_t senderipbits,uint8_t *data,int32_t datalen)
{ {
int32_t i,msglen,len=0; uint8_t num,keylen,*message,*key; uint32_t duration; int32_t i,msglen=0,len=0; uint8_t num,keylen,*message,*key; uint32_t duration;
if ( (num= data[len++]) > 0 ) if ( (num= data[len++]) > 0 )
{ {
//printf("processMSG num.%d datalen.%d\n",num,datalen); //printf("processMSG num.%d datalen.%d\n",num,datalen);

4
basilisk/basilisk_swap.c

@ -555,6 +555,7 @@ int32_t basilisk_bobpayment_reclaim(struct supernet_info *myinfo,struct basilisk
int32_t basilisk_verify_bobpaid(struct supernet_info *myinfo,void *ptr,uint8_t *data,int32_t datalen) int32_t basilisk_verify_bobpaid(struct supernet_info *myinfo,void *ptr,uint8_t *data,int32_t datalen)
{ {
uint8_t userdata[512]; int32_t i,retval,len = 0; bits256 revAm; struct basilisk_swap *swap = ptr; uint8_t userdata[512]; int32_t i,retval,len = 0; bits256 revAm; struct basilisk_swap *swap = ptr;
memset(revAm.bytes,0,sizeof(revAm));
if ( basilisk_rawtx_spendscript(myinfo,swap,swap->bobcoin->blocks.hwmchain.height,&swap->bobpayment,0,data,datalen,0) == 0 ) if ( basilisk_rawtx_spendscript(myinfo,swap,swap->bobcoin->blocks.hwmchain.height,&swap->bobpayment,0,data,datalen,0) == 0 )
{ {
for (i=0; i<32; i++) for (i=0; i<32; i++)
@ -838,6 +839,7 @@ int32_t basilisk_bobscripts_set(struct supernet_info *myinfo,struct basilisk_swa
int32_t basilisk_verify_privi(struct supernet_info *myinfo,void *ptr,uint8_t *data,int32_t datalen) int32_t basilisk_verify_privi(struct supernet_info *myinfo,void *ptr,uint8_t *data,int32_t datalen)
{ {
int32_t j,wrongfirstbyte,len = 0; bits256 privkey,pubi; char str[65],str2[65]; uint8_t secret160[20],pubkey33[33]; uint64_t txid; struct basilisk_swap *swap = ptr; int32_t j,wrongfirstbyte,len = 0; bits256 privkey,pubi; char str[65],str2[65]; uint8_t secret160[20],pubkey33[33]; uint64_t txid; struct basilisk_swap *swap = ptr;
memset(privkey.bytes,0,sizeof(privkey));
if ( datalen == sizeof(bits256) ) if ( datalen == sizeof(bits256) )
{ {
for (j=0; j<32; j++) for (j=0; j<32; j++)
@ -902,6 +904,7 @@ uint32_t basilisk_swapsend(struct supernet_info *myinfo,struct basilisk_swap *sw
int32_t basilisk_priviextract(struct supernet_info *myinfo,struct iguana_info *coin,char *name,bits256 *destp,uint8_t secret160[20],bits256 srctxid,int32_t srcvout) int32_t basilisk_priviextract(struct supernet_info *myinfo,struct iguana_info *coin,char *name,bits256 *destp,uint8_t secret160[20],bits256 srctxid,int32_t srcvout)
{ {
bits256 txid,privkey; char str[65]; int32_t i,vini,scriptlen; uint8_t rmd160[20],scriptsig[IGUANA_MAXSCRIPTSIZE]; bits256 txid,privkey; char str[65]; int32_t i,vini,scriptlen; uint8_t rmd160[20],scriptsig[IGUANA_MAXSCRIPTSIZE];
memset(privkey.bytes,0,sizeof(privkey));
if ( (vini= iguana_vinifind(myinfo,coin,&txid,srctxid,srcvout)) >= 0 ) if ( (vini= iguana_vinifind(myinfo,coin,&txid,srctxid,srcvout)) >= 0 )
{ {
if ( (scriptlen= iguana_scriptsigextract(myinfo,coin,scriptsig,sizeof(scriptsig),txid,vini)) > 0 ) if ( (scriptlen= iguana_scriptsigextract(myinfo,coin,scriptsig,sizeof(scriptsig),txid,vini)) > 0 )
@ -1327,6 +1330,7 @@ int32_t basilisk_verify_privkeys(struct supernet_info *myinfo,void *ptr,uint8_t
{ {
int32_t i,j,wrongfirstbyte=0,errs=0,len = 0; bits256 otherpriv,pubi; uint8_t secret160[20],otherpubkey[33]; uint64_t txid; struct basilisk_swap *swap = ptr; int32_t i,j,wrongfirstbyte=0,errs=0,len = 0; bits256 otherpriv,pubi; uint8_t secret160[20],otherpubkey[33]; uint64_t txid; struct basilisk_swap *swap = ptr;
//printf("verify privkeys choosei.%d otherchoosei.%d datalen.%d vs %d\n",swap->choosei,swap->otherchoosei,datalen,(int32_t)sizeof(swap->privkeys)+20+32); //printf("verify privkeys choosei.%d otherchoosei.%d datalen.%d vs %d\n",swap->choosei,swap->otherchoosei,datalen,(int32_t)sizeof(swap->privkeys)+20+32);
memset(otherpriv.bytes,0,sizeof(otherpriv));
if ( swap->I.cutverified == 0 && swap->I.otherchoosei >= 0 && datalen == sizeof(swap->privkeys)+20+2*32 ) if ( swap->I.cutverified == 0 && swap->I.otherchoosei >= 0 && datalen == sizeof(swap->privkeys)+20+2*32 )
{ {
for (i=errs=0; i<sizeof(swap->privkeys)/sizeof(*swap->privkeys); i++) for (i=errs=0; i<sizeof(swap->privkeys)/sizeof(*swap->privkeys); i++)

1
basilisk/basilisk_tradebot.c

@ -374,6 +374,7 @@ double basilisk_process_results(struct supernet_info *myinfo,struct basilisk_req
{ {
cJSON *array,*item; uint8_t *hexdata,*allocptr,hexspace[32768]; char *hexstr; int32_t i,hexlen,n,m,nonz; struct basilisk_request tmpR,R,refR,list[BASILISK_MAXRELAYS]; double metric=0.; cJSON *array,*item; uint8_t *hexdata,*allocptr,hexspace[32768]; char *hexstr; int32_t i,hexlen,n,m,nonz; struct basilisk_request tmpR,R,refR,list[BASILISK_MAXRELAYS]; double metric=0.;
memset(&refR,0,sizeof(refR)); memset(&refR,0,sizeof(refR));
memset(&R,0,sizeof(R));
//printf("process.(%s)\n",jprint(retjson,0)); //printf("process.(%s)\n",jprint(retjson,0));
if ( (array= jarray(&n,retjson,"messages")) != 0 ) if ( (array= jarray(&n,retjson,"messages")) != 0 )
{ {

10
basilisk/tradebots_SVM.h

@ -332,7 +332,7 @@ static inline double validate_ocas_model(register struct ocas_vars *vars,registe
{ {
register svmtype *features; register svmtype *features;
register double y,pred,perc,answer=0.,feature; register double y,pred,perc,answer=0.,feature;
register int i,j,pos,neg,good,bad,oldcuts,training_errors,weekind,nonz,posA,negA; register int i,j,pos,neg,good,bad,oldcuts,training_errors,weekind,nonz=0,posA,negA;
for (i=pos=neg=good=bad=oldcuts=training_errors=posA=negA=0; i<numdocs; i++) for (i=pos=neg=good=bad=oldcuts=training_errors=posA=negA=0; i<numdocs; i++)
{ {
weekind = (weekinds == 0) ? i : weekinds[i]; weekind = (weekinds == 0) ? i : weekinds[i];
@ -539,9 +539,9 @@ static inline void calc_ocas_strategy(register struct ocas_vars *vars,register i
static inline double ocas_splx_solver(register int *nonzalphap,register int maxlhs,register double *d,register double *activeH,register double *diag_H,register double *f,register double C,register double *alpha,register int n,register int MaxIter,register double TolAbs,register double TolRel,register double QP_TH) static inline double ocas_splx_solver(register int *nonzalphap,register int maxlhs,register double *d,register double *activeH,register double *diag_H,register double *f,register double C,register double *alpha,register int n,register int MaxIter,register double TolAbs,register double TolRel,register double QP_TH)
{ {
register double *col_u,*col_v; register double *col_u=0,*col_v=0;
register double QP,QD,lastQD,tmp,diff,distA,distB,etaA,etaB,improv,tmp_num,delta,x_neq0,xval,dval,diagval,tmp_den,tau; register double QP,QD,lastQD,tmp,diff,distA,distB,etaA,etaB,improv,tmp_num,delta,x_neq0,xval,dval,diagval=0.,tmp_den,tau=0.;
register int u=0,v=0,i,j,iter,nonzalpha,unlikely = 0; register int u=0,v=0,i,j,iter,nonzalpha=0,unlikely = 0;
QP = distA = distB = OCAS_PLUS_INF; lastQD = QD = OCAS_NEG_INF; QP = distA = distB = OCAS_PLUS_INF; lastQD = QD = OCAS_NEG_INF;
x_neq0 = C; x_neq0 = C;
etaA = etaB = 0.; etaA = etaB = 0.;
@ -838,7 +838,7 @@ static inline int ocas_iter(struct ocas_vars *vars,int max_nohwm)
int inactives[81]; int inactives[81];
register struct ocas_CLbuffers *ptr; register struct ocas_CLbuffers *ptr;
register double netcuts,startmilli,y,psum,pcount,nosum; register double netcuts,startmilli,y,psum,pcount,nosum;
register int i,numfeatures,cutlen,lastanswerind,lwm,numactive,numthreads,answerind,*weekinds; register int i,numfeatures,cutlen,lastanswerind,lwm=(1<<20),numactive,numthreads,answerind,*weekinds;
numactive = 0; numactive = 0;
if ( (numfeatures= vars->numfeatures) > MAX_OCAS_FEATURES ) if ( (numfeatures= vars->numfeatures) > MAX_OCAS_FEATURES )
{ {

6
basilisk/tradebots_liquidity.c

@ -309,8 +309,8 @@ int32_t tradebots_calcpreds(float *RTpreds,struct tradebot_arbpair *pair,double
void tradebots_calcanswers(struct tradebot_arbpair *pair) void tradebots_calcanswers(struct tradebot_arbpair *pair)
{ {
double highbid,lowask,futurebid,futureask,ave,vol,bidaves[TRADEBOTS_NUMDECAYS],askaves[TRADEBOTS_NUMDECAYS],bidslopes[TRADEBOTS_NUMDECAYS],askslopes[TRADEBOTS_NUMDECAYS]; double highbid,lowask,futurebid,futureask,ave,vol,bidaves[TRADEBOTS_NUMDECAYS],askaves[TRADEBOTS_NUMDECAYS],bidslopes[TRADEBOTS_NUMDECAYS],askslopes[TRADEBOTS_NUMDECAYS];
float rawfeatures[sizeof(pair->rawfeatures)/sizeof(*pair->rawfeatures)],futuremin,futuremax,minval,maxval,*hblas = 0; float rawfeatures[sizeof(pair->rawfeatures)/sizeof(*pair->rawfeatures)],futuremin=0,futuremax=0,minval=0,maxval=0,*hblas = 0;
uint32_t timestamp,firsttime = 0; long fpos,savepos; int32_t flag,i,iter,j,ind,maxi; uint32_t timestamp,firsttime = 0; long fpos,savepos; int32_t flag,i,iter,j,ind,maxi=0;
OCAS_PLUS_INF = _OCAS_PLUS_INF; OCAS_NEG_INF = -_OCAS_PLUS_INF; OCAS_PLUS_INF = _OCAS_PLUS_INF; OCAS_NEG_INF = -_OCAS_PLUS_INF;
if ( pair->fp != 0 ) if ( pair->fp != 0 )
{ {
@ -1143,7 +1143,7 @@ double tradebot_liquidity_active(struct supernet_info *myinfo,double *refpricep,
void tradebots_processprices(struct supernet_info *myinfo,struct exchange_info *exchange,char *base,char *rel,struct exchange_quote *bidasks,int32_t numbids,int32_t numasks) void tradebots_processprices(struct supernet_info *myinfo,struct exchange_info *exchange,char *base,char *rel,struct exchange_quote *bidasks,int32_t numbids,int32_t numasks)
{ {
double price,profitmargin,volume; struct tradebot_arbpair *pair; double price,profitmargin=0.,volume; struct tradebot_arbpair *pair;
if ( strcmp(rel,"NXT") == 0 && strcmp(base,"BTC") != 0 && (base= NXT_assetnamefind(base)) == 0 ) if ( strcmp(rel,"NXT") == 0 && strcmp(base,"BTC") != 0 && (base= NXT_assetnamefind(base)) == 0 )
{ {
//printf("reject %s %s/%s\n",exchange,base,rel); //printf("reject %s %s/%s\n",exchange,base,rel);

2
crypto777/OS_portable.c

@ -48,7 +48,7 @@ void OS_portable_randombytes(unsigned char *x,long xlen)
sleep(1); sleep(1);
continue; continue;
} }
if ( 0 ) if ( (0) )
{ {
int32_t j; int32_t j;
for (j=0; j<i; j++) for (j=0; j<i; j++)

7
crypto777/OS_time.c

@ -552,7 +552,7 @@ uint32_t OS_conv_datenum(int32_t datenum,int32_t hour,int32_t minute,int32_t sec
int32_t OS_conv_unixtime(struct tai *tp,int32_t *secondsp,time_t timestamp) // gmtime -> datenum + number of seconds int32_t OS_conv_unixtime(struct tai *tp,int32_t *secondsp,time_t timestamp) // gmtime -> datenum + number of seconds
{ {
struct tm tm,*ptr; int32_t datenum; uint32_t checktime; char buf[64]; struct tai t; struct taitime ct; struct tai t; struct taitime ct;
if ( 1 ) if ( 1 )
{ {
*tp = t = utc2tai((uint32_t)timestamp); *tp = t = utc2tai((uint32_t)timestamp);
@ -560,8 +560,9 @@ int32_t OS_conv_unixtime(struct tai *tp,int32_t *secondsp,time_t timestamp) // g
*secondsp = (ct.hour*3600 + ct.minute*60 + ct.second); *secondsp = (ct.hour*3600 + ct.minute*60 + ct.second);
return(calc_datenum(ct.date.year,ct.date.month,ct.date.day)); return(calc_datenum(ct.date.year,ct.date.month,ct.date.day));
} }
else /*else
{ {
struct tm tm,*ptr; int32_t datenum; uint32_t checktime; char buf[64];
if ( (ptr= gmtime(&timestamp)) != 0 ) if ( (ptr= gmtime(&timestamp)) != 0 )
tm = *ptr;; tm = *ptr;;
strftime(buf,sizeof(buf), "%Y-%m-%dT%H:%M:%SZ",&tm); //printf("%s\n",buf); strftime(buf,sizeof(buf), "%Y-%m-%dT%H:%M:%SZ",&tm); //printf("%s\n",buf);
@ -572,7 +573,7 @@ int32_t OS_conv_unixtime(struct tai *tp,int32_t *secondsp,time_t timestamp) // g
return(-1); return(-1);
} }
return(datenum); return(datenum);
} }*/
} }
int32_t conv_date(int32_t *secondsp,char *date) int32_t conv_date(int32_t *secondsp,char *date)

3
crypto777/SaM.c

@ -285,7 +285,7 @@ int32_t SaM_test()
memset(histo,0,sizeof(histo)); memset(histo,0,sizeof(histo));
for (i=0; i<5; i++) for (i=0; i<5; i++)
{ {
if ( 0 && (i % 100) == 99 ) if ( (0) && (i % 100) == 99 )
{ {
for (j=0; j<32; j++) for (j=0; j<32; j++)
seed.bytes[j] = rand() >> 8; seed.bytes[j] = rand() >> 8;
@ -340,6 +340,7 @@ bits384 SaM_encrypt(uint8_t *dest,uint8_t *src,int32_t len,bits384 password,uint
{ {
bits384 xorpad; int32_t i; struct SaM_info XORpad; bits384 xorpad; int32_t i; struct SaM_info XORpad;
SaM_Initialize(&XORpad), SaM_Absorb(&XORpad,password.bytes,sizeof(password),(void *)&timestamp,sizeof(timestamp)); SaM_Initialize(&XORpad), SaM_Absorb(&XORpad,password.bytes,sizeof(password),(void *)&timestamp,sizeof(timestamp));
memset(xorpad.bytes,0,sizeof(xorpad));
while ( len >= 0 ) while ( len >= 0 )
{ {
SaM_emit(&XORpad); SaM_emit(&XORpad);

10
crypto777/bitcoind_RPC.c

@ -138,7 +138,7 @@ char *bitcoind_RPC(char **retstrp,char *debugstr,char *url,char *userpass,char *
else specialcase = 0; else specialcase = 0;
if ( url[0] == 0 ) if ( url[0] == 0 )
strcpy(url,"http://127.0.0.1:7776"); strcpy(url,"http://127.0.0.1:7776");
if ( specialcase != 0 && 0 ) if ( specialcase != 0 && (0) )
printf("<<<<<<<<<<< bitcoind_RPC: debug.(%s) url.(%s) command.(%s) params.(%s)\n",debugstr,url,command,params); printf("<<<<<<<<<<< bitcoind_RPC: debug.(%s) url.(%s) command.(%s) params.(%s)\n",debugstr,url,command,params);
try_again: try_again:
if ( retstrp != 0 ) if ( retstrp != 0 )
@ -235,7 +235,7 @@ try_again:
} }
else else
{ {
if ( 0 && specialcase != 0 ) if ( (0) && specialcase != 0 )
fprintf(stderr,"<<<<<<<<<<< bitcoind_RPC: BTCD.(%s) -> (%s)\n",params,s.ptr); fprintf(stderr,"<<<<<<<<<<< bitcoind_RPC: BTCD.(%s) -> (%s)\n",params,s.ptr);
count2++; count2++;
elapsedsum2 += (OS_milliseconds() - starttime); elapsedsum2 += (OS_milliseconds() - starttime);
@ -244,9 +244,9 @@ try_again:
return(s.ptr); return(s.ptr);
} }
} }
printf("bitcoind_RPC: impossible case\n"); //printf("bitcoind_RPC: impossible case\n");
free(s.ptr); //free(s.ptr);
return(0); //return(0);
} }
/************************************************************************ /************************************************************************

2
crypto777/iguana_OS.c

@ -594,7 +594,7 @@ void OS_remove_directory(char *dirname)
void OS_ensure_directory(char *dirname) void OS_ensure_directory(char *dirname)
{ {
FILE *fp; int32_t retval; char fname[512]; FILE *fp; int32_t retval; char fname[512];
if ( 0 && OS_removefile(dirname,0) < 0 ) if ( (0) && OS_removefile(dirname,0) < 0 )
{ {
sprintf(fname,"tmp/%d",rand()); sprintf(fname,"tmp/%d",rand());
OS_renamefile(dirname,fname); OS_renamefile(dirname,fname);

8
crypto777/iguana_utils.c

@ -182,7 +182,7 @@ void calc_OP_HASH160(char hexstr[41],uint8_t rmd160[20],char *pubkey)
} }
decode_hex(buf,len,pubkey); decode_hex(buf,len,pubkey);
calc_rmd160_sha256(rmd160,buf,len); calc_rmd160_sha256(rmd160,buf,len);
if ( 0 ) if ( (0) )
{ {
int i; int i;
for (i=0; i<20; i++) for (i=0; i<20; i++)
@ -436,9 +436,9 @@ char *clonestr(char *str)
if ( str == 0 || str[0] == 0 ) if ( str == 0 || str[0] == 0 )
{ {
printf("warning cloning nullstr.%p\n",str); printf("warning cloning nullstr.%p\n",str);
#ifdef __APPLE__ //#ifdef __APPLE__
while ( 1 ) sleep(1); // while ( 1 ) sleep(1);
#endif //#endif
str = (char *)"<nullstr>"; str = (char *)"<nullstr>";
} }
clone = (char *)malloc(strlen(str)+16); clone = (char *)malloc(strlen(str)+16);

4
crypto777/inet.c

@ -373,7 +373,7 @@ uint64_t _calc_ipbits(char *ip_port)
port = parse_ipaddr(ipaddr,ip_port); port = parse_ipaddr(ipaddr,ip_port);
memset(&addr,0,sizeof(addr)); memset(&addr,0,sizeof(addr));
portable_pton(ip_port[0] == '[' ? AF_INET6 : AF_INET,ipaddr,&addr); portable_pton(ip_port[0] == '[' ? AF_INET6 : AF_INET,ipaddr,&addr);
if ( 0 ) if ( (0) )
{ {
int i; int i;
for (i=0; i<16; i++) for (i=0; i<16; i++)
@ -472,7 +472,7 @@ uint32_t conv_domainname(char *ipaddr,char *domain)
int32_t ipv4only = 1; int32_t ipv4only = 1;
uint32_t ipbits; uint32_t ipbits;
struct sockaddr_in ss; struct sockaddr_in ss;
if ( 0 && conv_domain((struct sockaddr_storage *)&ss,(const char *)domain,ipv4only) == 0 ) if ( (0) && conv_domain((struct sockaddr_storage *)&ss,(const char *)domain,ipv4only) == 0 )
{ {
ipbits = *(uint32_t *)&ss.sin_addr; ipbits = *(uint32_t *)&ss.sin_addr;
expand_ipbits(ipaddr,ipbits); expand_ipbits(ipaddr,ipbits);

2
crypto777/ramcoder.c

@ -437,7 +437,7 @@ int32_t ramcoder_compress(uint8_t *bits,int32_t maxlen,uint8_t *data,int32_t dat
if ( ramcoder_encoder(0,1,data,datalen,hp,0,&seed) < 0 ) if ( ramcoder_encoder(0,1,data,datalen,hp,0,&seed) < 0 )
return(-1); return(-1);
numbits = hp->bitoffset; numbits = hp->bitoffset;
if ( 0 ) if ( (0) )
{ {
void *malloc(size_t); void free(void *); void *malloc(size_t); void free(void *);
int32_t i,checklen; uint8_t *checkbuf; int32_t i,checklen; uint8_t *checkbuf;

5
datachain/datachain.c

@ -320,7 +320,8 @@ void datachain_update_spend(struct supernet_info *myinfo,int32_t ordered,struct
int64_t datachain_update(struct supernet_info *myinfo,int32_t ordered,struct iguana_info *coin,uint32_t timestamp,struct iguana_bundle *bp,uint8_t rmd160[20],int64_t crypto777_payment,uint8_t type,int32_t height,uint64_t hdrsi_unspentind,int64_t value,uint32_t fileid,uint64_t scriptpos,int32_t scriptlen,bits256 txid,int32_t vout) int64_t datachain_update(struct supernet_info *myinfo,int32_t ordered,struct iguana_info *coin,uint32_t timestamp,struct iguana_bundle *bp,uint8_t rmd160[20],int64_t crypto777_payment,uint8_t type,int32_t height,uint64_t hdrsi_unspentind,int64_t value,uint32_t fileid,uint64_t scriptpos,int32_t scriptlen,bits256 txid,int32_t vout)
{ {
return(0); if ( (0) )
{
if ( memcmp(rmd160,CRYPTO777_RMD160,20) == 0 ) if ( memcmp(rmd160,CRYPTO777_RMD160,20) == 0 )
{ {
crypto777_payment += value; crypto777_payment += value;
@ -332,4 +333,6 @@ int64_t datachain_update(struct supernet_info *myinfo,int32_t ordered,struct igu
iguana_opreturn(myinfo,ordered,coin,timestamp,bp,crypto777_payment,height,hdrsi_unspentind,value,fileid,scriptpos,scriptlen); iguana_opreturn(myinfo,ordered,coin,timestamp,bp,crypto777_payment,height,hdrsi_unspentind,value,fileid,scriptpos,scriptlen);
} else datachain_update_spend(myinfo,ordered,coin,timestamp,bp,height,txid,vout,rmd160,value); } else datachain_update_spend(myinfo,ordered,coin,timestamp,bp,height,txid,vout,rmd160,value);
return(crypto777_payment); return(crypto777_payment);
}
return(0);
} }

4
gecko/gecko.c

@ -52,7 +52,7 @@ void gecko_iteration(struct supernet_info *myinfo,struct iguana_info *btcd,struc
//iguana_update_balances(virt); //iguana_update_balances(virt);
//iguana_realtime_update(myinfo,virt); //iguana_realtime_update(myinfo,virt);
} }
if ( 0 && hwmhdrsi <= longesthdrsi )//&& virt->blocks.hwmchain.height < virt->longestchain-1 ) if ( (0) && hwmhdrsi <= longesthdrsi )//&& virt->blocks.hwmchain.height < virt->longestchain-1 )
{ {
if ( time(NULL) > virt->hdrstime+3 ) if ( time(NULL) > virt->hdrstime+3 )
{ {
@ -62,7 +62,7 @@ void gecko_iteration(struct supernet_info *myinfo,struct iguana_info *btcd,struc
virt->hdrstime = (uint32_t)time(NULL); virt->hdrstime = (uint32_t)time(NULL);
} }
} }
if ( 0 && btcd->FULLNODE != 0 )//&& virt->blocks.hwmchain.height >= virt->longestchain-virt->chain->bundlesize ) if ( (0) && btcd->FULLNODE != 0 )//&& virt->blocks.hwmchain.height >= virt->longestchain-virt->chain->bundlesize )
{ {
bitcoin_address(mineraddr,virt->chain->pubtype,myinfo->persistent_pubkey33,33); bitcoin_address(mineraddr,virt->chain->pubtype,myinfo->persistent_pubkey33,33);
//fprintf(stderr,"mine.%s %s\n",virt->symbol,mineraddr); //fprintf(stderr,"mine.%s %s\n",virt->symbol,mineraddr);

2
gecko/gecko_headers.c

@ -53,7 +53,7 @@ void gecko_blockhashupdate(struct iguana_info *virt,bits256 hash2,int32_t height
char *gecko_headersarrived(struct supernet_info *myinfo,struct iguana_info *virt,char *remoteaddr,uint8_t *data,int32_t datalen,bits256 firsthash2) char *gecko_headersarrived(struct supernet_info *myinfo,struct iguana_info *virt,char *remoteaddr,uint8_t *data,int32_t datalen,bits256 firsthash2)
{ {
bits256 hash2,prevhash2; struct iguana_block *block; int32_t height,firstheight,i,len=0,n,num; struct iguana_msgzblock zmsgB; char str[65],str2[65]; bits256 hash2,prevhash2; struct iguana_block *block; int32_t height=0,firstheight,i,len=0,n,num; struct iguana_msgzblock zmsgB; char str[65],str2[65];
num = (int32_t)(datalen / 84); num = (int32_t)(datalen / 84);
printf("headers.%s arrived.%d from %s\n",virt->symbol,num,bits256_str(str,firsthash2)); printf("headers.%s arrived.%d from %s\n",virt->symbol,num,bits256_str(str,firsthash2));
if ( (block= iguana_blockfind("geckohdrs",virt,firsthash2)) != 0 && (firstheight= block->height) >= 0 ) if ( (block= iguana_blockfind("geckohdrs",virt,firsthash2)) != 0 && (firstheight= block->height) >= 0 )

2
gecko/gecko_miner.c

@ -62,7 +62,7 @@ int32_t gecko_blocknonce_verify(struct iguana_info *virt,uint8_t *serialized,int
uint32_t gecko_nBits(struct iguana_info *virt,uint32_t *prevtimestampp,struct iguana_block *block,int32_t n) uint32_t gecko_nBits(struct iguana_info *virt,uint32_t *prevtimestampp,struct iguana_block *block,int32_t n)
{ {
uint32_t nBits = GECKO_DEFAULTDIFF,starttime,endtime,est; struct iguana_block *prev=0; int32_t i,diff; bits256 targetval; uint32_t nBits = GECKO_DEFAULTDIFF,starttime=0,endtime=0,est; struct iguana_block *prev=0; int32_t i,diff; bits256 targetval;
*prevtimestampp = 0; *prevtimestampp = 0;
if ( virt->chain->estblocktime == 0 ) if ( virt->chain->estblocktime == 0 )
return(GECKO_EASIESTDIFF); return(GECKO_EASIESTDIFF);

4
iguana/SuperNET_keys.c

@ -220,7 +220,7 @@ int32_t SuperNET_savejsonfile(struct supernet_info *myinfo,char *finalfname,bits
int32_t SuperNET_userkeys(char *passphrase,int32_t passsize,char *fname2fa,int32_t fnamesize) int32_t SuperNET_userkeys(char *passphrase,int32_t passsize,char *fname2fa,int32_t fnamesize)
{ {
return(0); return(0);
#ifndef __PNACL /*#ifndef __PNACL
//if ( (bits256_nonz(*wallethashp) == 0 || bits256_cmp(*wallethashp,GENESIS_PRIVKEY) == 0) && (bits256_nonz(*wallet2privp) == 0 || bits256_cmp(*wallet2privp,GENESIS_PRIVKEY) == 0) ) //if ( (bits256_nonz(*wallethashp) == 0 || bits256_cmp(*wallethashp,GENESIS_PRIVKEY) == 0) && (bits256_nonz(*wallet2privp) == 0 || bits256_cmp(*wallet2privp,GENESIS_PRIVKEY) == 0) )
{ {
sleep(1); sleep(1);
@ -232,7 +232,7 @@ int32_t SuperNET_userkeys(char *passphrase,int32_t passsize,char *fname2fa,int32
return(0); return(0);
} }
#endif #endif
return(-1); return(-1);*/
} }
cJSON *SuperNET_decryptedjson(char *destfname,char *passphrase,int32_t passsize,bits256 wallethash,char *fname2fa,int32_t fnamesize,bits256 wallet2priv) cJSON *SuperNET_decryptedjson(char *destfname,char *passphrase,int32_t passsize,bits256 wallethash,char *fname2fa,int32_t fnamesize,bits256 wallet2priv)

2
iguana/cards777.c

@ -238,7 +238,7 @@ uint8_t *cards777_encode(struct supernet_info *myinfo,bits256 *encoded,bits256 *
init_sharenrs(sharenrs,0,N,N); init_sharenrs(sharenrs,0,N,N);
cards777_calcmofn(myinfo,allshares,myshares,sharenrs,M,xoverz,numcards,N); cards777_calcmofn(myinfo,allshares,myshares,sharenrs,M,xoverz,numcards,N);
memcpy(ciphers,shuffled,numcards * N * sizeof(bits256)); memcpy(ciphers,shuffled,numcards * N * sizeof(bits256));
if ( 0 ) if ( (0) )
{ {
/*{ /*{
init_hexbytes_noT(nrs,dp->hand.sharenrs,dp->N); init_hexbytes_noT(nrs,dp->hand.sharenrs,dp->N);

1
iguana/dpow/dpow_fsm.c

@ -69,6 +69,7 @@ void dpow_entry2utxo(struct dpow_utxoentry *up,struct dpow_block *bp,struct dpow
int32_t dpow_datahandler(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,uint8_t nn_senderind,uint32_t channel,uint32_t height,uint8_t *data,int32_t datalen) int32_t dpow_datahandler(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,uint8_t nn_senderind,uint32_t channel,uint32_t height,uint8_t *data,int32_t datalen)
{ {
int32_t i,src_or_dest,myind = -1; bits256 txid,srchash; struct iguana_info *coin; char str[65],str2[65]; int32_t i,src_or_dest,myind = -1; bits256 txid,srchash; struct iguana_info *coin; char str[65],str2[65];
memset(srchash.bytes,0,sizeof(srchash));
dpow_notaryfind(myinfo,bp,height,&myind,dp->minerkey33); dpow_notaryfind(myinfo,bp,height,&myind,dp->minerkey33);
if ( myind < 0 ) if ( myind < 0 )
{ {

2
iguana/dpow/dpow_prices.c

@ -1635,7 +1635,7 @@ void _crypto_update(double cryptovols[2][9][2],struct PAX_data *dp,int32_t selec
void PAX_RTupdate(double cryptovols[2][9][2],double RTmetals[4],double *RTprices,struct PAX_data *dp) void PAX_RTupdate(double cryptovols[2][9][2],double RTmetals[4],double *RTprices,struct PAX_data *dp)
{ {
char *cryptostrs[9] = { "btc", "nxt", "unity", "eth", "etc", "kmd", "xmr", "bts", "xcp" }; char *cryptostrs[9] = { "btc", "nxt", "unity", "eth", "etc", "kmd", "xmr", "bts", "xcp" };
int32_t iter,i,c,baserel,basenum,relnum; double cnyusd,btcusd,kmdbtc,bid,ask,price,vol,prices[8][2],volumes[8][2]; int32_t iter,i,c,baserel,basenum,relnum; double cnyusd,btcusd,kmdbtc,bid=0.,ask=0.,price,vol,prices[8][2],volumes[8][2];
char base[16],rel[16]; char base[16],rel[16];
PAX_update(dp,&btcusd,&kmdbtc); PAX_update(dp,&btcusd,&kmdbtc);
memset(prices,0,sizeof(prices)); memset(prices,0,sizeof(prices));

2
iguana/dpow/dpow_tx.c

@ -429,6 +429,7 @@ void dpow_rawtxsign(struct supernet_info *myinfo,struct dpow_info *dp,struct igu
return; return;
for (j=0; j<sizeof(srchash); j++) for (j=0; j<sizeof(srchash); j++)
srchash.bytes[j] = dp->minerkey33[j+1]; srchash.bytes[j] = dp->minerkey33[j+1];
memset(srchash.bytes,0,sizeof(srchash));
m = 0; m = 0;
ep = &bp->notaries[myind]; ep = &bp->notaries[myind];
cp = (src_or_dest != 0) ? &bp->notaries[myind].dest : &bp->notaries[myind].src; cp = (src_or_dest != 0) ? &bp->notaries[myind].dest : &bp->notaries[myind].src;
@ -564,6 +565,7 @@ void dpow_sigscheck(struct supernet_info *myinfo,struct dpow_info *dp,struct dpo
bits256 txid,srchash,zero,signedtxid; struct iguana_info *coin; int32_t j,len,numsigs; char *retstr=0,str[65],str2[65]; uint8_t txdata[32768]; uint32_t channel,state; bits256 txid,srchash,zero,signedtxid; struct iguana_info *coin; int32_t j,len,numsigs; char *retstr=0,str[65],str2[65]; uint8_t txdata[32768]; uint32_t channel,state;
coin = (src_or_dest != 0) ? bp->destcoin : bp->srccoin; coin = (src_or_dest != 0) ? bp->destcoin : bp->srccoin;
memset(zero.bytes,0,sizeof(zero)); memset(zero.bytes,0,sizeof(zero));
memset(txid.bytes,0,sizeof(txid));
channel = (src_or_dest != 0) ? DPOW_SIGBTCCHANNEL : DPOW_SIGCHANNEL; channel = (src_or_dest != 0) ? DPOW_SIGBTCCHANNEL : DPOW_SIGCHANNEL;
if ( bestk >= 0 && bp->state != 0xffffffff && coin != 0 ) if ( bestk >= 0 && bp->state != 0xffffffff && coin != 0 )
{ {

1
iguana/exchanges/bitcoin.c

@ -290,6 +290,7 @@ struct bitcoin_spend *iguana_spendset(struct supernet_info *myinfo,struct iguana
ptr = spend->inputs; ptr = spend->inputs;
for (i=0; i<maxinputs; i++,ptr++) for (i=0; i<maxinputs; i++,ptr++)
{ {
up = 0;
for (mode=1; mode>=0; mode--) for (mode=1; mode>=0; mode--)
if ( (up= iguana_bestfit(coin,ups,totalunspents,remains,mode)) != 0 ) if ( (up= iguana_bestfit(coin,ups,totalunspents,remains,mode)) != 0 )
break; break;

3
iguana/exchanges/fxcm.c

@ -99,7 +99,7 @@ int32_t fxcm_setcontracts()
{ {
if ( (json= cJSON_Parse(xmlstr)) != 0 ) if ( (json= cJSON_Parse(xmlstr)) != 0 )
{ {
/*<Rate Symbol="USDJPY"> /* <Rate Symbol="USDJPY">
<Bid>123.763</Bid> <Bid>123.763</Bid>
<Ask>123.786</Ask> <Ask>123.786</Ask>
<High>123.956</High> <High>123.956</High>
@ -153,6 +153,7 @@ int32_t fxcm_ensure()
char *ALLPAIRS(struct exchange_info *exchange,cJSON *argjson) char *ALLPAIRS(struct exchange_info *exchange,cJSON *argjson)
{ {
int32_t i,c,n; char base[32],rel[32]; cJSON *json,*item,*array = cJSON_CreateArray(); int32_t i,c,n; char base[32],rel[32]; cJSON *json,*item,*array = cJSON_CreateArray();
n = 0;
if ( fxcm_ensure() == 0 ) if ( fxcm_ensure() == 0 )
{ {
for (i=0; i<num_FXCM; i++) for (i=0; i<num_FXCM; i++)

8
iguana/iguana777.c

@ -233,7 +233,7 @@ uint32_t iguana_updatemetrics(struct supernet_info *myinfo,struct iguana_info *c
{ {
expand_ipbits(ipaddr,(uint32_t)addr->ipbits); expand_ipbits(ipaddr,(uint32_t)addr->ipbits);
fprintf(fp,"%s\n",ipaddr); fprintf(fp,"%s\n",ipaddr);
if ( 0 && addr->msgcounts.verack == 0 ) if ( (0) && addr->msgcounts.verack == 0 )
{ {
printf("iguana_sendblockreq (%s) addrind.%d hasn't verack'ed yet\n",addr->ipaddr,addr->addrind); printf("iguana_sendblockreq (%s) addrind.%d hasn't verack'ed yet\n",addr->ipaddr,addr->addrind);
iguana_send_version(coin,addr,coin->myservices); iguana_send_version(coin,addr,coin->myservices);
@ -274,7 +274,7 @@ void iguana_emitQ(struct iguana_info *coin,struct iguana_bundle *bp)
void iguana_bundleQ(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp,int32_t timelimit) void iguana_bundleQ(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp,int32_t timelimit)
{ {
struct iguana_helper *ptr; struct iguana_bundle *tmp; int32_t i,n = 0; struct iguana_helper *ptr; struct iguana_bundle *tmp; int32_t i,n = 0;
if ( 0 && bp->queued == 0 && bp->emitfinish <= 1 && iguana_bundleready(myinfo,coin,bp,0) == bp->n ) if ( (0) && bp->queued == 0 && bp->emitfinish <= 1 && iguana_bundleready(myinfo,coin,bp,0) == bp->n )
printf("bundle.[%d] is ready\n",bp->hdrsi); printf("bundle.[%d] is ready\n",bp->hdrsi);
if ( bp->queued != 0 ) if ( bp->queued != 0 )
return; return;
@ -637,7 +637,7 @@ int32_t iguana_coin_mainiter(struct supernet_info *myinfo,struct iguana_info *co
isRT *= (coin->RTheight > 0); isRT *= (coin->RTheight > 0);
if ( coin->peers != 0 ) if ( coin->peers != 0 )
*numpeersp += coin->peers->numranked; *numpeersp += coin->peers->numranked;
if ( 0 && (rand() % 10) == 0 ) if ( (0) && (rand() % 10) == 0 )
printf("%s main.%u vs %u, svs %u %d vs %d\n",coin->symbol,(uint32_t)time(NULL),coin->startutc+10,coin->spendvectorsaved ,coin->blocks.hwmchain.height/coin->chain->bundlesize,(coin->longestchain-coin->minconfirms)/coin->chain->bundlesize); printf("%s main.%u vs %u, svs %u %d vs %d\n",coin->symbol,(uint32_t)time(NULL),coin->startutc+10,coin->spendvectorsaved ,coin->blocks.hwmchain.height/coin->chain->bundlesize,(coin->longestchain-coin->minconfirms)/coin->chain->bundlesize);
if ( time(NULL) > coin->startutc+60 ) if ( time(NULL) > coin->startutc+60 )
{ {
@ -682,7 +682,7 @@ int32_t iguana_coin_mainiter(struct supernet_info *myinfo,struct iguana_info *co
} }
if ( (bp= coin->current) != 0 && coin->stucktime != 0 && coin->isRT == 0 && coin->RTheight == 0 && (time(NULL) - coin->stucktime) > coin->MAXSTUCKTIME ) if ( (bp= coin->current) != 0 && coin->stucktime != 0 && coin->isRT == 0 && coin->RTheight == 0 && (time(NULL) - coin->stucktime) > coin->MAXSTUCKTIME )
{ {
if ( 0 ) if ( (0) )
{ {
printf("%s is stuck too long, restarting due to %d\n",coin->symbol,bp->hdrsi); printf("%s is stuck too long, restarting due to %d\n",coin->symbol,bp->hdrsi);
if ( coin->started != 0 ) if ( coin->started != 0 )

2
iguana/iguana_accept.c

@ -369,7 +369,7 @@ int32_t iguana_peerhdrrequest(struct supernet_info *myinfo,struct iguana_info *c
} else printf("cant find block at ht.%d\n",height+i); } else printf("cant find block at ht.%d\n",height+i);
} }
} }
if ( 0 && flag != 0 && strcmp("BTCD",coin->symbol) != 0 ) if ( (0) && flag != 0 && strcmp("BTCD",coin->symbol) != 0 )
retval = iguana_queue_send(addr,0,serialized,"headers",len); retval = iguana_queue_send(addr,0,serialized,"headers",len);
//printf("hdrs request retval.%d len.%d\n",retval,len); //printf("hdrs request retval.%d len.%d\n",retval,len);
} //else printf("couldnt find header\n"); } //else printf("couldnt find header\n");

8
iguana/iguana_bitmap.c

@ -401,8 +401,8 @@ void disp_yval(register int32_t color,register float yval,register uint32_t *bit
//if ( pixelwt(color) > pixelwt(bitmap[y*rowwidth + x]) ) //if ( pixelwt(color) > pixelwt(bitmap[y*rowwidth + x]) )
bitmap[y*rowwidth + x] = pixel_blend(bitmap[y*rowwidth + x],color); bitmap[y*rowwidth + x] = pixel_blend(bitmap[y*rowwidth + x],color);
return; return;
if ( is_primary_color(color) != 0 || (is_primary_color(bitmap[y*rowwidth+x]) == 0 && pixelwt(color) > pixelwt(bitmap[y*rowwidth + x])) ) //if ( is_primary_color(color) != 0 || (is_primary_color(bitmap[y*rowwidth+x]) == 0 && pixelwt(color) > pixelwt(bitmap[y*rowwidth + x])) )
bitmap[y*rowwidth + x] = color; // bitmap[y*rowwidth + x] = color;
} }
void disp_yvalsum(register int32_t color,register float yval,register uint32_t *bitmap,register int32_t x,register int32_t rowwidth,register int32_t height) void disp_yvalsum(register int32_t color,register float yval,register uint32_t *bitmap,register int32_t x,register int32_t rowwidth,register int32_t height)
@ -509,7 +509,7 @@ void output_line(int32_t calclogflag,double ave,float *buf,int32_t n,int32_t col
double src[1024],dest[1024]; int32_t i; double src[1024],dest[1024]; int32_t i;
memset(src,0,sizeof(src)); memset(src,0,sizeof(src));
memset(dest,0,sizeof(dest)); memset(dest,0,sizeof(dest));
if ( 1 ) if ( (1) )
{ {
for (i=0; i<1024; i++) for (i=0; i<1024; i++)
src[1023-i] = dest[1023-i] = buf[i]; src[1023-i] = dest[1023-i] = buf[i];
@ -1085,7 +1085,7 @@ void iguana_bitmapbundle(struct iguana_info *coin,uint8_t *rect,int32_t rowwidth
struct iguana_bitmap *iguana_bitmapfind(char *name) struct iguana_bitmap *iguana_bitmapfind(char *name)
{ {
struct iguana_info *coin; int32_t width,height,n,hdrsi,x,y; struct iguana_info *coin; int32_t width=1,height=1,n,hdrsi,x,y;
if ( ((coin= iguana_coinfind(name)) != 0 || (coin= iguana_coinfind("BTCD")) != 0) && coin->screen != 0 ) if ( ((coin= iguana_coinfind(name)) != 0 || (coin= iguana_coinfind("BTCD")) != 0) && coin->screen != 0 )
{ {
strcpy(coin->screen->name,coin->symbol); strcpy(coin->screen->name,coin->symbol);

8
iguana/iguana_blocks.c

@ -411,7 +411,7 @@ double PoW_from_compact(uint32_t nBits,uint8_t unitval) // NOT consensus safe, b
nbytes = (nBits >> 24) & 0xFF; nbytes = (nBits >> 24) & 0xFF;
nbits = (8 * (nbytes - 3)); nbits = (8 * (nbytes - 3));
PoW = (nBits & 0xFFFFFF); PoW = (nBits & 0xFFFFFF);
if ( 0 && nbytes > unitval ) if ( (0) && nbytes > unitval )
{ {
printf("illegal nBits.%x unitval.%02x\n",nBits,unitval); printf("illegal nBits.%x unitval.%02x\n",nBits,unitval);
return(0.); return(0.);
@ -590,7 +590,7 @@ struct iguana_block *_iguana_chainlink(struct supernet_info *myinfo,struct iguan
if ( bits256_nonz(prev->RO.hash2) == 0 || (prev->valid == 0 && iguana_blockvalidate(myinfo,coin,&valid,prev,0) < 0) ) if ( bits256_nonz(prev->RO.hash2) == 0 || (prev->valid == 0 && iguana_blockvalidate(myinfo,coin,&valid,prev,0) < 0) )
{ {
char str[65]; char str[65];
if ( 0 && bits256_nonz(prev->RO.hash2) != 0 ) if ( (0) && bits256_nonz(prev->RO.hash2) != 0 )
printf("(%s) notready v.%d m.%d h.%d\n",bits256_str(str,prev->RO.hash2),prev->valid,prev->mainchain,prev->height); printf("(%s) notready v.%d m.%d h.%d\n",bits256_str(str,prev->RO.hash2),prev->valid,prev->mainchain,prev->height);
return(0); return(0);
} else prev->valid = 1; } else prev->valid = 1;
@ -645,7 +645,7 @@ struct iguana_block *_iguana_chainlink(struct supernet_info *myinfo,struct iguan
else str2[0] = 0; else str2[0] = 0;
if ( coin->blocks.maxblocks > coin->longestchain ) if ( coin->blocks.maxblocks > coin->longestchain )
coin->longestchain = coin->blocks.maxblocks; coin->longestchain = coin->blocks.maxblocks;
if ( 0 && (block->height % coin->chain->bundlesize) == 0 ) if ( (0) && (block->height % coin->chain->bundlesize) == 0 )
{ {
printf("EXTENDMAIN %s %d <- (%s) n.%u max.%u PoW %f numtx.%d valid.%d\n",str,block->height,str2,hwmchain->height+1,coin->blocks.maxblocks,block->PoW,block->RO.txn_count,block->valid); printf("EXTENDMAIN %s %d <- (%s) n.%u max.%u PoW %f numtx.%d valid.%d\n",str,block->height,str2,hwmchain->height+1,coin->blocks.maxblocks,block->PoW,block->RO.txn_count,block->valid);
//iguana_walkchain(coin); //iguana_walkchain(coin);
@ -724,7 +724,7 @@ struct iguana_block *_iguana_chainlink(struct supernet_info *myinfo,struct iguan
iguana_RTnewblock(myinfo,coin,block); iguana_RTnewblock(myinfo,coin,block);
block->hdrsi = hdrsi; block->hdrsi = hdrsi;
block->bundlei = bundlei; block->bundlei = bundlei;
if ( 0 && (bp= coin->bundles[hdrsi]) != 0 ) if ( (0) && (bp= coin->bundles[hdrsi]) != 0 )
{ {
if ( bp->blocks[bundlei] != block || bits256_cmp(bp->hashes[bundlei],block->RO.hash2) != 0 ) if ( bp->blocks[bundlei] != block || bits256_cmp(bp->hashes[bundlei],block->RO.hash2) != 0 )
printf("new hwm [%d:%d] mismatched bundle block\n",hdrsi,bundlei); printf("new hwm [%d:%d] mismatched bundle block\n",hdrsi,bundlei);

37
iguana/iguana_bundles.c

@ -21,6 +21,7 @@ static uint16_t iguana_primes[] = { 65353, 65357, 65371, 65381, 65393, 65407, 65
struct iguana_bloominds iguana_calcbloom(bits256 hash2) struct iguana_bloominds iguana_calcbloom(bits256 hash2)
{ {
int32_t i,j,k; struct iguana_bloominds bit; int32_t i,j,k; struct iguana_bloominds bit;
memset(&bit,0,sizeof(bit));
k = (int32_t)(sizeof(bit)/sizeof(uint16_t)) - 1; k = (int32_t)(sizeof(bit)/sizeof(uint16_t)) - 1;
j = 15; j = 15;
for (i=0; i<sizeof(bit)/sizeof(uint16_t); i++,j--,k--) for (i=0; i<sizeof(bit)/sizeof(uint16_t); i++,j--,k--)
@ -158,7 +159,7 @@ int32_t iguana_hash2set(struct iguana_info *coin,char *debugstr,struct iguana_bu
{ {
// printf("bloomset (%s) -> [%d:%d]\n",bits256_str(str,newhash2),bp->hdrsi,bundlei); // printf("bloomset (%s) -> [%d:%d]\n",bits256_str(str,newhash2),bp->hdrsi,bundlei);
iguana_bloomset(coin,&bp->bloom,0,bit); iguana_bloomset(coin,&bp->bloom,0,bit);
if ( 0 ) if ( (0) )
{ {
int32_t i; int32_t i;
if ( iguana_bloomfind(coin,&bp->bloom,0,bit) < 0 ) if ( iguana_bloomfind(coin,&bp->bloom,0,bit) < 0 )
@ -245,7 +246,7 @@ int32_t iguana_bundlehash2add(struct iguana_info *coin,struct iguana_block **blo
return(-1); return(-1);
} }
} }
if ( 0 && bits256_nonz(bp->hashes[bundlei]) != 0 && bits256_cmp(bp->hashes[bundlei],block->RO.hash2) != 0 ) if ( (0) && bits256_nonz(bp->hashes[bundlei]) != 0 && bits256_cmp(bp->hashes[bundlei],block->RO.hash2) != 0 )
{ {
//char str[65],str2[65]; //char str[65],str2[65];
//printf("B bp.[%d]->hashes[%d] mismatch %s != %s%s\n",bp->hdrsi,bundlei,bits256_str(str,bp->hashes[bundlei]),bits256_str(str2,block->RO.hash2),block->mainchain?".main":""); //printf("B bp.[%d]->hashes[%d] mismatch %s != %s%s\n",bp->hdrsi,bundlei,bits256_str(str,bp->hashes[bundlei]),bits256_str(str2,block->RO.hash2),block->mainchain?".main":"");
@ -461,7 +462,7 @@ char *iguana_bundleaddrs(struct iguana_info *coin,int32_t hdrsi)
uint8_t *PKbits; struct iguana_pkhash *P; uint32_t pkind,numpkinds; struct iguana_bundle *bp; struct iguana_ramchain *ramchain; struct iguana_ramchaindata *rdata; cJSON *retjson; char rmdstr[41]; uint8_t *PKbits; struct iguana_pkhash *P; uint32_t pkind,numpkinds; struct iguana_bundle *bp; struct iguana_ramchain *ramchain; struct iguana_ramchaindata *rdata; cJSON *retjson; char rmdstr[41];
if ( (bp= coin->bundles[hdrsi]) != 0 ) if ( (bp= coin->bundles[hdrsi]) != 0 )
{ {
if ( 0 && coin->RTramchain_busy != 0 ) if ( (0) && coin->RTramchain_busy != 0 )
{ {
printf("iguana_bundleaddrs: unexpected access when RTramchain_busy\n"); printf("iguana_bundleaddrs: unexpected access when RTramchain_busy\n");
return(0); return(0);
@ -520,7 +521,7 @@ void iguana_bundlepurgefiles(struct iguana_info *coin,struct iguana_bundle *bp)
sprintf(fname,"%s/%s/%d/%d",GLOBAL_TMPDIR,coin->symbol,subdir,bp->bundleheight), OS_remove_directory(fname); sprintf(fname,"%s/%s/%d/%d",GLOBAL_TMPDIR,coin->symbol,subdir,bp->bundleheight), OS_remove_directory(fname);
//printf("purged hdrsi.[%d] subdir.%d lag.%ld\n",bp->hdrsi,subdir,time(NULL) - bp->emitfinish); //printf("purged hdrsi.[%d] subdir.%d lag.%ld\n",bp->hdrsi,subdir,time(NULL) - bp->emitfinish);
bp->purgetime = (uint32_t)time(NULL); bp->purgetime = (uint32_t)time(NULL);
if ( 0 ) if ( (0) )
{ {
for (i=subdir*IGUANA_SUBDIRDIVISOR; i<(subdir+1)*IGUANA_SUBDIRDIVISOR; i++) for (i=subdir*IGUANA_SUBDIRDIVISOR; i<(subdir+1)*IGUANA_SUBDIRDIVISOR; i++)
{ {
@ -692,14 +693,14 @@ int32_t iguana_bundleissuemissing(struct supernet_info *myinfo,struct iguana_inf
queue_enqueue("missing",&coin->priorityQ,&req->DL); queue_enqueue("missing",&coin->priorityQ,&req->DL);
bp->issued[i] = 1; bp->issued[i] = 1;
n++; n++;
if ( 0 && bp == coin->current ) if ( (0) && bp == coin->current )
printf("%s issuemissing.[%d:%d]\n",bits256_str(str,hash2),bp->hdrsi,i); printf("%s issuemissing.[%d:%d]\n",bits256_str(str,hash2),bp->hdrsi,i);
} //else printf("[z%d] ",i); } //else printf("[z%d] ",i);
} //else printf("%d ",now - (bp->issued[i]+lag)); } //else printf("%d ",now - (bp->issued[i]+lag));
} }
if ( firsti >= 0 )//&& bp == coin->current ) if ( firsti >= 0 )//&& bp == coin->current )
{ {
if ( 0 && bp == coin->current ) if ( (0) && bp == coin->current )
printf("%s [%d] first missing.%d of %d\n",bits256_str(str,hash2),bp->hdrsi,firsti,nonz); printf("%s [%d] first missing.%d of %d\n",bits256_str(str,hash2),bp->hdrsi,firsti,nonz);
iguana_bundleblock(coin,&hash2,bp,firsti); iguana_bundleblock(coin,&hash2,bp,firsti);
if ( bits256_nonz(hash2) != 0 ) if ( bits256_nonz(hash2) != 0 )
@ -773,7 +774,7 @@ int32_t iguana_bundleready(struct supernet_info *myinfo,struct iguana_info *coin
int32_t i,ready,valid; char fname[1024]; struct iguana_block *block; int32_t sum[0x100],counts[0x100]; struct iguana_blockRO *B; struct iguana_bundle *nextbp; void *ptr; long filesize; struct iguana_ramchain R; bits256 prevhash2; int32_t i,ready,valid; char fname[1024]; struct iguana_block *block; int32_t sum[0x100],counts[0x100]; struct iguana_blockRO *B; struct iguana_bundle *nextbp; void *ptr; long filesize; struct iguana_ramchain R; bits256 prevhash2;
memset(sum,0,sizeof(sum)); memset(sum,0,sizeof(sum));
memset(counts,0,sizeof(counts)); memset(counts,0,sizeof(counts));
if ( 0 && bp->queued == 0 ) if ( (0) && bp->queued == 0 )
{ {
for (i=ready=0; i<bp->n; i++) for (i=ready=0; i<bp->n; i++)
if ( (block= bp->blocks[i]) == 0 ) if ( (block= bp->blocks[i]) == 0 )
@ -825,7 +826,7 @@ int32_t iguana_bundleready(struct supernet_info *myinfo,struct iguana_info *coin
char str[65]; char str[65];
if ( requiredflag != 0 ) if ( requiredflag != 0 )
printf(">>>>>>> block contents error at ht.%d [%d:%d]\n",bp->bundleheight+i,bp->hdrsi,i); printf(">>>>>>> block contents error at ht.%d [%d:%d]\n",bp->bundleheight+i,bp->hdrsi,i);
if ( 0 && bits256_nonz(block->RO.hash2) != 0 ) if ( (0) && bits256_nonz(block->RO.hash2) != 0 )
printf("patch.%d and reissue prev.%s %d\n",bp->bundleheight+i,bits256_str(str,block->RO.prev_block),i); printf("patch.%d and reissue prev.%s %d\n",bp->bundleheight+i,bits256_str(str,block->RO.prev_block),i);
iguana_blockunmark(coin,block,bp,i,1); iguana_blockunmark(coin,block,bp,i,1);
} }
@ -845,11 +846,11 @@ int32_t iguana_bundleready(struct supernet_info *myinfo,struct iguana_info *coin
} }
fclose(fp); fclose(fp);
} }
else if ( 0 ) else if ( (0) )
//#endif //#endif
{ {
iguana_blockunmark(coin,block,bp,i,1); iguana_blockunmark(coin,block,bp,i,1);
if ( 0 && requiredflag != 0 ) if ( (0) && requiredflag != 0 )
printf("not ready altpath.(%d %d %d %d %d) [%d:%d]\n",block->txvalid == 0,block->fpipbits == 0 ,block->fpos < 0,(bp->bundleheight+i > 0 && bits256_nonz(block->RO.prev_block) == 0),iguana_blockvalidate(myinfo,coin,&valid,block,1) < 0,bp->hdrsi,i); printf("not ready altpath.(%d %d %d %d %d) [%d:%d]\n",block->txvalid == 0,block->fpipbits == 0 ,block->fpos < 0,(bp->bundleheight+i > 0 && bits256_nonz(block->RO.prev_block) == 0),iguana_blockvalidate(myinfo,coin,&valid,block,1) < 0,bp->hdrsi,i);
} }
else else
@ -877,7 +878,7 @@ int32_t iguana_bundleready(struct supernet_info *myinfo,struct iguana_info *coin
int32_t iguana_bundlehdr(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp,int32_t starti) int32_t iguana_bundlehdr(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp,int32_t starti)
{ {
int32_t i,dist,counter=0; char str[65]; int32_t i,dist,counter=0; char str[65];
if ( 0 && bp->isRT == 0 && (bp->hdrsi == coin->bundlescount-1 || bp == coin->current) ) if ( (0) && bp->isRT == 0 && (bp->hdrsi == coin->bundlescount-1 || bp == coin->current) )
printf("hdr ITERATE.%d bundle.%d vs %d: h.%d n.%d r.%d s.%d c.%d finished.%d spec.%p[%d]\n",bp->hdrsi,bp->bundleheight,coin->longestchain-coin->chain->bundlesize,bp->numhashes,bp->n,bp->numrecv,bp->numsaved,bp->numcached,bp->emitfinish,bp->speculative,bp->numspec); printf("hdr ITERATE.%d bundle.%d vs %d: h.%d n.%d r.%d s.%d c.%d finished.%d spec.%p[%d]\n",bp->hdrsi,bp->bundleheight,coin->longestchain-coin->chain->bundlesize,bp->numhashes,bp->n,bp->numrecv,bp->numsaved,bp->numcached,bp->emitfinish,bp->speculative,bp->numspec);
dist = 30 + (coin->current != 0 ? bp->hdrsi - coin->current->hdrsi : 0); dist = 30 + (coin->current != 0 ? bp->hdrsi - coin->current->hdrsi : 0);
if ( bp == coin->current ) if ( bp == coin->current )
@ -976,7 +977,7 @@ int64_t iguana_bundlecalcs(struct supernet_info *myinfo,struct iguana_info *coin
datasize += block->RO.recvlen; datasize += block->RO.recvlen;
} }
} }
else if ( 0 && bits256_nonz(block->RO.hash2) != 0 && bits256_nonz(bp->hashes[bundlei]) != 0 ) else if ( (0) && bits256_nonz(block->RO.hash2) != 0 && bits256_nonz(bp->hashes[bundlei]) != 0 )
{ {
printf("hash mismatch [%d:%d]\n",bp->hdrsi,bundlei); printf("hash mismatch [%d:%d]\n",bp->hdrsi,bundlei);
iguana_blockunmark(coin,block,bp,bundlei,1); iguana_blockunmark(coin,block,bp,bundlei,1);
@ -996,7 +997,7 @@ int64_t iguana_bundlecalcs(struct supernet_info *myinfo,struct iguana_info *coin
} }
} }
bp->numcached = numcached; bp->numcached = numcached;
if ( 0 && bp->numcached != numsaved ) if ( (0) && bp->numcached != numsaved )
printf("[%d] emit.%u ramchain.%p numcached.%d vs numsaved.%d numhashes.%d\n",bp->hdrsi,bp->emitfinish,bp->ramchain.H.data,bp->numcached,numsaved,numhashes); printf("[%d] emit.%u ramchain.%p numcached.%d vs numsaved.%d numhashes.%d\n",bp->hdrsi,bp->emitfinish,bp->ramchain.H.data,bp->numcached,numsaved,numhashes);
bp->datasize = datasize; bp->datasize = datasize;
bp->numhashes = numhashes; bp->numhashes = numhashes;
@ -1126,7 +1127,7 @@ int32_t iguana_bundleiters(struct supernet_info *myinfo,struct iguana_info *coin
iguana_bundlecalcs(myinfo,coin,bp,lag); iguana_bundlecalcs(myinfo,coin,bp,lag);
if ( coin->blockdepth == 0 && coin->blockdepth == 0 && bp->hdrsi == coin->bundlescount-1 ) if ( coin->blockdepth == 0 && coin->blockdepth == 0 && bp->hdrsi == coin->bundlescount-1 )
iguana_autoextend(myinfo,coin,bp); iguana_autoextend(myinfo,coin,bp);
if ( 0 && bp->hdrsi == 0 ) if ( (0) && bp->hdrsi == 0 )
printf("ITER utxo.%u now.%u spec.%-4d bundle.%-4d h.%-4d r.%-4d s.%-4d F.%d T.%d issued.%d mb.%d/%d\n",bp->utxofinish,(uint32_t)time(NULL),bp->numspec,bp->bundleheight/coin->chain->bundlesize,bp->numhashes,bp->numrecv,bp->numsaved,bp->emitfinish,timelimit,counter,coin->MAXBUNDLES,coin->bundlescount); printf("ITER utxo.%u now.%u spec.%-4d bundle.%-4d h.%-4d r.%-4d s.%-4d F.%d T.%d issued.%d mb.%d/%d\n",bp->utxofinish,(uint32_t)time(NULL),bp->numspec,bp->bundleheight/coin->chain->bundlesize,bp->numhashes,bp->numrecv,bp->numsaved,bp->emitfinish,timelimit,counter,coin->MAXBUNDLES,coin->bundlescount);
bp->nexttime = (uint32_t)time(NULL) + ((bp->hdrsi > starti) ? 0 : -2); bp->nexttime = (uint32_t)time(NULL) + ((bp->hdrsi > starti) ? 0 : -2);
if ( bp->hdrsi == coin->bundlescount-1 || (bp->numhashes < bp->n && bp->bundleheight < coin->longestchain-coin->chain->bundlesize) ) if ( bp->hdrsi == coin->bundlescount-1 || (bp->numhashes < bp->n && bp->bundleheight < coin->longestchain-coin->chain->bundlesize) )
@ -1144,10 +1145,10 @@ int32_t iguana_bundleiters(struct supernet_info *myinfo,struct iguana_info *coin
{ {
max = bp->n; max = bp->n;
counter = iguana_bundleissuemissing(myinfo,coin,bp,1,3.); counter = iguana_bundleissuemissing(myinfo,coin,bp,1,3.);
if ( 0 && counter > 0 ) if ( (0) && counter > 0 )
printf("starti.%d range.%d now.%u spec.%-4d bundle.%-4d h.%-4d r.%-4d s.%-4d F.%d T.%d issued.%d mb.%d/%d\n",starti,range,(uint32_t)time(NULL),bp->numspec,bp->bundleheight/coin->chain->bundlesize,bp->numhashes,bp->numrecv,bp->numsaved,bp->emitfinish,timelimit,counter,coin->MAXBUNDLES,coin->bundlescount); printf("starti.%d range.%d now.%u spec.%-4d bundle.%-4d h.%-4d r.%-4d s.%-4d F.%d T.%d issued.%d mb.%d/%d\n",starti,range,(uint32_t)time(NULL),bp->numspec,bp->bundleheight/coin->chain->bundlesize,bp->numhashes,bp->numrecv,bp->numsaved,bp->emitfinish,timelimit,counter,coin->MAXBUNDLES,coin->bundlescount);
} else bp->nexttime++; } else bp->nexttime++;
if ( 0 && bp->emitfinish <= 1 ) if ( (0) && bp->emitfinish <= 1 )
iguana_bundleQ(myinfo,coin,bp,1000); iguana_bundleQ(myinfo,coin,bp,1000);
else else
{ {
@ -1417,7 +1418,7 @@ void iguana_bundlestats(struct supernet_info *myinfo,struct iguana_info *coin,ch
//sortbuf[m*2] = bp->metric; //sortbuf[m*2] = bp->metric;
//sortbuf[m*2 + 1] = i; //sortbuf[m*2 + 1] = i;
m++; m++;
if ( 0 && lastpending == 0 ) if ( (0) && lastpending == 0 )
printf("%d ",bp->numsaved); printf("%d ",bp->numsaved);
} }
} }
@ -1552,7 +1553,7 @@ void iguana_bundlestats(struct supernet_info *myinfo,struct iguana_info *coin,ch
myallocated(0,0); myallocated(0,0);
coin->lastdisp = (uint32_t)time(NULL); coin->lastdisp = (uint32_t)time(NULL);
} }
if ( 0 && (bp= coin->current) != 0 && coin->RTheight >= bp->bundleheight && coin->RTheight < bp->bundleheight+bp->n ) if ( (0) && (bp= coin->current) != 0 && coin->RTheight >= bp->bundleheight && coin->RTheight < bp->bundleheight+bp->n )
{ {
for (i=coin->RTheight-bp->bundleheight; i<bp->n; i++) for (i=coin->RTheight-bp->bundleheight; i<bp->n; i++)
{ {

8
iguana/iguana_chains.c

@ -126,12 +126,12 @@ int32_t blockhash_scrypt(uint8_t *blockhashp,uint8_t *serialized,int32_t len)
blockhashfunc iguana_hashalgo(char *hashalgostr) blockhashfunc iguana_hashalgo(char *hashalgostr)
{ {
return(blockhash_sha256); // all coins seem to use this for genesis return(blockhash_sha256); // all coins seem to use this for genesis
if ( hashalgostr == 0 || hashalgostr[0] == 0 || strcmp(hashalgostr,"sha256") == 0 ) /*if ( hashalgostr == 0 || hashalgostr[0] == 0 || strcmp(hashalgostr,"sha256") == 0 )
return(blockhash_sha256); return(blockhash_sha256);
else if ( strcmp(hashalgostr,"scrypt") == 0 ) else if ( strcmp(hashalgostr,"scrypt") == 0 )
return(blockhash_scrypt); return(blockhash_scrypt);
else printf("unsupported blockhash algo.(%s)\n",hashalgostr); else printf("unsupported blockhash algo.(%s)\n",hashalgostr);
return(0); return(0);*/
} }
bits256 iguana_calcblockhash(char *symbol,int32_t (*hashalgo)(uint8_t *blockhashp,uint8_t *serialized,int32_t len),uint8_t *serialized,int32_t len) bits256 iguana_calcblockhash(char *symbol,int32_t (*hashalgo)(uint8_t *blockhashp,uint8_t *serialized,int32_t len),uint8_t *serialized,int32_t len)
@ -189,8 +189,8 @@ bits256 iguana_chaingenesis(struct supernet_info *myinfo,char *symbol,uint8_t zc
char *parse_conf_line(char *line,char *field) char *parse_conf_line(char *line,char *field)
{ {
line += strlen(field); line += strlen(field);
for (; *line!='='&&*line!=0; line++) while ( (*line) != '=' && (*line) != 0 )
break; line++;
if ( *line == 0 ) if ( *line == 0 )
return(0); return(0);
if ( *line == '=' ) if ( *line == '=' )

2
iguana/iguana_exchanges.c

@ -1129,7 +1129,7 @@ struct exchange_info *exchanges777_info(char *exchangestr,int32_t sleepflag,cJSO
sleep(sleepflag); sleep(sleepflag);
} }
} }
if ( 0 && exchange != 0 ) if ( (0) && exchange != 0 )
printf("found exchange.(%s) %p %p %p\n",exchange->name,exchange->issue.supports,exchange->issue.price,exchange->issue.allpairs); printf("found exchange.(%s) %p %p %p\n",exchange->name,exchange->issue.supports,exchange->issue.price,exchange->issue.allpairs);
return(exchange); return(exchange);
} }

4
iguana/iguana_init.c

@ -269,7 +269,7 @@ int32_t iguana_bundleinitmap(struct supernet_info *myinfo,struct iguana_info *co
void iguana_parseline(struct supernet_info *myinfo,struct iguana_info *coin,int32_t iter,FILE *fp) void iguana_parseline(struct supernet_info *myinfo,struct iguana_info *coin,int32_t iter,FILE *fp)
{ {
int32_t j,k,m,c,flag,bundlei,lastheight,missing=0,height = -1; char checkstr[1024],line[1024]; int32_t j,k,m,c,flag,bundlei,lastheight=0,missing=0,height = -1; char checkstr[1024],line[1024];
struct iguana_peer *addr; struct iguana_bundle *bp; bits256 allhash,hash2,hash1,zero,lastbundle; struct iguana_peer *addr; struct iguana_bundle *bp; bits256 allhash,hash2,hash1,zero,lastbundle;
if ( coin->FULLNODE == 0 && coin->VALIDATENODE == 0 && iter > 0 ) if ( coin->FULLNODE == 0 && coin->VALIDATENODE == 0 && iter > 0 )
return; return;
@ -318,7 +318,7 @@ void iguana_parseline(struct supernet_info *myinfo,struct iguana_info *coin,int3
{ {
if ( m < coin->MAXPEERS/2 ) if ( m < coin->MAXPEERS/2 )
{ {
if ( 0 && m == 0 && coin->seedipaddr[0] != 0 ) if ( (0) && m == 0 && coin->seedipaddr[0] != 0 )
{ {
addr = &coin->peers->active[m++]; addr = &coin->peers->active[m++];
iguana_initpeer(coin,addr,(uint32_t)calc_ipbits(coin->seedipaddr)); iguana_initpeer(coin,addr,(uint32_t)calc_ipbits(coin->seedipaddr));

7
iguana/iguana_interpreter.c

@ -734,7 +734,7 @@ int32_t iguana_checksig(struct iguana_info *coin,struct iguana_stackdata pubkeya
if ( (retval= (bitcoin_verify(coin->ctx,sig,siglen-1,sigtxid,pubkey,plen) == 0)) == 0 ) if ( (retval= (bitcoin_verify(coin->ctx,sig,siglen-1,sigtxid,pubkey,plen) == 0)) == 0 )
{ {
} }
if ( 0 ) if ( (0) )
{ {
int32_t i; char str[65]; int32_t i; char str[65];
for (i=0; i<siglen; i++) for (i=0; i<siglen; i++)
@ -1000,7 +1000,7 @@ int32_t bitcoin_assembler(struct iguana_info *coin,cJSON *logarray,uint8_t scrip
struct bitcoin_opcode *op; cJSON *array = 0; struct iguana_interpreter STACKS,*stacks = &STACKS; struct bitcoin_opcode *op; cJSON *array = 0; struct iguana_interpreter STACKS,*stacks = &STACKS;
struct iguana_stackdata args[MAX_PUBKEYS_PER_MULTISIG]; struct iguana_stackdata args[MAX_PUBKEYS_PER_MULTISIG];
uint8_t databuf[MAX_SCRIPT_ELEMENT_SIZE]; char *asmstr,*str,*hexstr; cJSON *item; uint8_t databuf[MAX_SCRIPT_ELEMENT_SIZE]; char *asmstr,*str,*hexstr; cJSON *item;
int32_t c,numops,dlen,plen,numvars,numused,numargs=0,i,j,k,n,len,datalen,errs=0; int64_t val; int32_t c,numops,dlen,plen,numvars,numused,numargs=0,i,j,k,n=0,len,datalen,errs=0; int64_t val;
iguana_optableinit(coin); iguana_optableinit(coin);
if ( (asmstr= jstr(interpreter,"interpreter")) == 0 || asmstr[0] == 0 ) if ( (asmstr= jstr(interpreter,"interpreter")) == 0 || asmstr[0] == 0 )
return(0); return(0);
@ -1438,6 +1438,7 @@ int32_t bitcoin_assembler(struct iguana_info *coin,cJSON *logarray,uint8_t scrip
} }
else if ( (op->flags & IGUANA_STACKFLAG) != 0 ) else if ( (op->flags & IGUANA_STACKFLAG) != 0 )
{ {
val = 0;
if ( op->opcode == IGUANA_OP_PICK || op->opcode == IGUANA_OP_ROLL ) if ( op->opcode == IGUANA_OP_PICK || op->opcode == IGUANA_OP_ROLL )
{ {
if ( interpret != 0 && stacks->stackdepth < (val= iguana_num(args[0])) ) if ( interpret != 0 && stacks->stackdepth < (val= iguana_num(args[0])) )
@ -1505,7 +1506,7 @@ int32_t bitcoin_assembler(struct iguana_info *coin,cJSON *logarray,uint8_t scrip
} }
else if ( (op->flags & IGUANA_MATHFLAG) != 0 ) else if ( (op->flags & IGUANA_MATHFLAG) != 0 )
{ {
int64_t numA,numB,numC; int64_t numA=0,numB=0,numC=0;
for (i=0; i<op->stackitems; i++) for (i=0; i<op->stackitems; i++)
{ {
if ( args[i].size != sizeof(int32_t) ) if ( args[i].size != sizeof(int32_t) )

4
iguana/iguana_json.c

@ -200,7 +200,7 @@ cJSON *SuperNET_helpjson()
int32_t agentform(FILE *fp,char *form,int32_t max,char *agent,cJSON *methoditem) int32_t agentform(FILE *fp,char *form,int32_t max,char *agent,cJSON *methoditem)
{ {
cJSON *item,*fieldsarray; int32_t j,m,width,size = 0; cJSON *item,*fieldsarray; int32_t j,m,width=1,size = 0;
char *methodstr,*typestr,outstr[2048],outstr2[2048],fields[8192],str[2],agent_method[256],*fieldname; char *methodstr,*typestr,outstr[2048],outstr2[2048],fields[8192],str[2],agent_method[256],*fieldname;
form[0] = 0; form[0] = 0;
if ( (methodstr= jstr(methoditem,"method")) == 0 ) if ( (methodstr= jstr(methoditem,"method")) == 0 )
@ -293,7 +293,7 @@ int32_t templates_emit(char *retbuf,int32_t maxsize,char *template,char *agent,c
int32_t pretty_form(FILE *fp,char *formheader,char *formfooter,char *fieldtemplate,char *agent,cJSON *methoditem,cJSON *helpitem,char *suffix) int32_t pretty_form(FILE *fp,char *formheader,char *formfooter,char *fieldtemplate,char *agent,cJSON *methoditem,cJSON *helpitem,char *suffix)
{ {
cJSON *item,*fieldsarray; int32_t j,m,formsize,fieldsize,iter,width,size = 0; cJSON *item,*fieldsarray; int32_t j,m,formsize,fieldsize,iter,width=1,size = 0;
char *methodstr,*typestr,*fieldname,*helpstr,*curlstr,*urlstr,*itemhelp; char *methodstr,*typestr,*fieldname,*helpstr,*curlstr,*urlstr,*itemhelp;
char outstr[2048],outstr2[2048],str[2],widthstr[16],both[512]; char outstr[2048],outstr2[2048],str[2],widthstr[16],both[512];
if ( (methodstr= jstr(methoditem,"method")) == 0 ) if ( (methodstr= jstr(methoditem,"method")) == 0 )

7
iguana/iguana_mofn.c

@ -262,7 +262,7 @@ void libgfshare_init(struct supernet_info *myinfo,uint8_t _logs[256],uint8_t _ex
for (i=255; i<510; i++) for (i=255; i<510; i++)
_exps[i] = _exps[i % 255]; _exps[i] = _exps[i % 255];
_logs[0] = 0; // can't log(0) so just set it neatly to 0 _logs[0] = 0; // can't log(0) so just set it neatly to 0
if ( 0 ) if ( (0) )
{ {
void test_mofn(struct supernet_info *myinfo); void test_mofn(struct supernet_info *myinfo);
gfshare_test(myinfo,6,11,32); gfshare_test(myinfo,6,11,32);
@ -602,7 +602,7 @@ void test_mofn(struct supernet_info *myinfo)
{ {
if ( memcmp(secret.bytes,recover.bytes,sizeof(secret)) != 0 ) if ( memcmp(secret.bytes,recover.bytes,sizeof(secret)) != 0 )
printf("FAILED m.%d M.%d N.%d\n",m,M,N); printf("FAILED m.%d M.%d N.%d\n",m,M,N);
else if ( 0 ) else if ( (0) )
{ {
char str[65]; char str[65];
printf("%s PASSED m.%d M.%d N.%d\n",bits256_str(str,recover),m,M,N); printf("%s PASSED m.%d M.%d N.%d\n",bits256_str(str,recover),m,M,N);
@ -658,6 +658,7 @@ int32_t iguana_schnorr_peersign(void *ctx,uint8_t *allpub33,uint8_t *partialsig6
bits256 iguana_schnorr_noncepair(void *ctx,bits256 *pubkey,uint8_t odd_even,bits256 msg256,bits256 privkey,int32_t maxj) bits256 iguana_schnorr_noncepair(void *ctx,bits256 *pubkey,uint8_t odd_even,bits256 msg256,bits256 privkey,int32_t maxj)
{ {
bits256 privnonce; int32_t j; uint8_t pubkey33[33]; bits256 privnonce; int32_t j; uint8_t pubkey33[33];
memset(privnonce.bytes,0,sizeof(privnonce));
for (j=0; j<maxj; j++) for (j=0; j<maxj; j++)
{ {
privnonce = bitcoin_schnorr_noncepair(ctx,pubkey33,msg256,privkey); privnonce = bitcoin_schnorr_noncepair(ctx,pubkey33,msg256,privkey);
@ -780,7 +781,7 @@ void iguana_schnorr(struct supernet_info *myinfo)
printf("error combining k.%d sig64 iter.%d\n",k,iter); printf("error combining k.%d sig64 iter.%d\n",k,iter);
else if ( bitcoin_schnorr_verify(myinfo->ctx,sig64,msg256,allpub2,33) < 0 ) else if ( bitcoin_schnorr_verify(myinfo->ctx,sig64,msg256,allpub2,33) < 0 )
printf("allpub2 error verifying combined sig k.%d\n",k); printf("allpub2 error verifying combined sig k.%d\n",k);
else if ( 0 ) // doesnt replicate with subsets else if ( (0) ) // doesnt replicate with subsets
{ {
if ( bitcoin_pubkey_combine(myinfo->ctx,allpub,0,pubkeys,n,0,0) == 0 ) if ( bitcoin_pubkey_combine(myinfo->ctx,allpub,0,pubkeys,n,0,0) == 0 )
{ {

14
iguana/iguana_msg.c

@ -449,7 +449,7 @@ void iguana_gotaddr(struct iguana_info *coin,struct iguana_peer *addr,struct igu
expand_ipbits(ipaddr,ipbits); expand_ipbits(ipaddr,ipbits);
if ( port != 0 ) if ( port != 0 )
sprintf(ipport,"%s:%d",ipaddr,port); sprintf(ipport,"%s:%d",ipaddr,port);
if ( 0 ) if ( (0) )
{ {
int32_t i; int32_t i;
printf("{{"); printf("{{");
@ -459,7 +459,7 @@ void iguana_gotaddr(struct iguana_info *coin,struct iguana_peer *addr,struct igu
} }
if ( strcmp(coin->symbol,"BTC") != 0 || (rand() % 10) == 0 ) if ( strcmp(coin->symbol,"BTC") != 0 || (rand() % 10) == 0 )
iguana_possible_peer(coin,ipport); iguana_possible_peer(coin,ipport);
if ( 0 && strcmp("TAZ",coin->symbol) == 0 ) if ( (0) && strcmp("TAZ",coin->symbol) == 0 )
printf("iguana_gotaddr: %s from %s\n",ipaddr,addr->ipaddr); printf("iguana_gotaddr: %s from %s\n",ipaddr,addr->ipaddr);
} }
@ -713,7 +713,7 @@ int32_t iguana_rwtx(struct supernet_info *myinfo,uint8_t zcash,int32_t rwflag,st
memcpy(joinsplitsig,&serialized[len],64), len += 64; memcpy(joinsplitsig,&serialized[len],64), len += 64;
} }
} }
if ( 0 ) if ( (0) )
{ {
*txidp = bits256_doublesha256(txidstr,txstart,len); *txidp = bits256_doublesha256(txidstr,txstart,len);
char str[65]; char str[65];
@ -955,7 +955,7 @@ int32_t iguana_msgparser(struct supernet_info *myinfo,struct iguana_info *coin,s
} }
if ( addr != 0 ) if ( addr != 0 )
{ {
if ( 0 && addr->msgcounts.verack == 0 ) if ( (0) && addr->msgcounts.verack == 0 )
printf("iguana_msgparser verack.%d from (%s) parse.(%s) len.%d\n",addr->msgcounts.verack,addr->ipaddr,H->command,recvlen); printf("iguana_msgparser verack.%d from (%s) parse.(%s) len.%d\n",addr->msgcounts.verack,addr->ipaddr,H->command,recvlen);
//iguana_peerblockrequest(coin,addr->blockspace,IGUANA_MAXPACKETSIZE,addr,iguana_blockhash(coin,100),0); //iguana_peerblockrequest(coin,addr->blockspace,IGUANA_MAXPACKETSIZE,addr,iguana_blockhash(coin,100),0);
addr->lastcontact = (uint32_t)time(NULL); addr->lastcontact = (uint32_t)time(NULL);
@ -1010,7 +1010,7 @@ int32_t iguana_msgparser(struct supernet_info *myinfo,struct iguana_info *coin,s
else else
{ {
intvectors = 'I', addr->msgcounts.inv++; intvectors = 'I', addr->msgcounts.inv++;
if ( 0 && strcmp(H->command,"inv2") == 0 ) if ( (0) && strcmp(H->command,"inv2") == 0 )
printf("GOT INV2.%d\n",recvlen); printf("GOT INV2.%d\n",recvlen);
len = iguana_intvectors(coin,addr,1,data,recvlen); // indirectly issues getdata len = iguana_intvectors(coin,addr,1,data,recvlen); // indirectly issues getdata
} }
@ -1056,7 +1056,7 @@ int32_t iguana_msgparser(struct supernet_info *myinfo,struct iguana_info *coin,s
} }
len += iguana_rwvarint32(0,&data[len],&tmp); len += iguana_rwvarint32(0,&data[len],&tmp);
char str[65],str2[65]; char str[65],str2[65];
if ( 0 && coin->chain->auxpow != 0 ) if ( (0) && coin->chain->auxpow != 0 )
printf("%d %d of %d: %s %s v.%08x numtx.%d cmp.%d\n",len,i,n,bits256_str(str,hash2),bits256_str(str2,zmsg.zH.prev_block),zmsg.zH.version,tmp,bits256_cmp(prevhash2,zmsg.zH.prev_block)); printf("%d %d of %d: %s %s v.%08x numtx.%d cmp.%d\n",len,i,n,bits256_str(str,hash2),bits256_str(str2,zmsg.zH.prev_block),zmsg.zH.version,tmp,bits256_cmp(prevhash2,zmsg.zH.prev_block));
} }
else len += iguana_rwblock(myinfo,coin->chain->symbol,coin->chain->zcash,coin->chain->auxpow,coin->chain->hashalgo,0,&hash2,&data[len],(void *)&zmsg,recvlen); else len += iguana_rwblock(myinfo,coin->chain->symbol,coin->chain->zcash,coin->chain->auxpow,coin->chain->hashalgo,0,&hash2,&data[len],(void *)&zmsg,recvlen);
@ -1151,7 +1151,7 @@ int32_t iguana_msgparser(struct supernet_info *myinfo,struct iguana_info *coin,s
len = 0; len = 0;
if ( (sendlen= iguana_peeraddrrequest(coin,addr,&addr->blockspace[sizeof(H)],IGUANA_MAXPACKETSIZE)) > 0 ) if ( (sendlen= iguana_peeraddrrequest(coin,addr,&addr->blockspace[sizeof(H)],IGUANA_MAXPACKETSIZE)) > 0 )
{ {
if ( 0 ) if ( (0) )
{ {
int32_t checklen; uint32_t checkbits; char checkaddr[64]; int32_t checklen; uint32_t checkbits; char checkaddr[64];
checklen = iguana_rwvarint(0,&addr->blockspace[sizeof(H)],&x); checklen = iguana_rwvarint(0,&addr->blockspace[sizeof(H)],&x);

3
iguana/iguana_notary.c

@ -38,7 +38,7 @@ void dpow_fifoupdate(struct supernet_info *myinfo,struct dpow_checkpoint *fifo,s
memset(newfifo,0,sizeof(newfifo)); memset(newfifo,0,sizeof(newfifo));
for (i=DPOW_FIFOSIZE-1; i>0; i--) for (i=DPOW_FIFOSIZE-1; i>0; i--)
{ {
if ( 0 && bits256_nonz(fifo[i-1].blockhash.hash) != 0 && (tip.blockhash.height - fifo[i-1].blockhash.height) != i ) if ( (0) && bits256_nonz(fifo[i-1].blockhash.hash) != 0 && (tip.blockhash.height - fifo[i-1].blockhash.height) != i )
printf("(%d != %d) ",(tip.blockhash.height - fifo[i-1].blockhash.height),i); printf("(%d != %d) ",(tip.blockhash.height - fifo[i-1].blockhash.height),i);
if ( (ind= (tip.blockhash.height - fifo[i-1].blockhash.height)) >= 0 && ind < DPOW_FIFOSIZE ) if ( (ind= (tip.blockhash.height - fifo[i-1].blockhash.height)) >= 0 && ind < DPOW_FIFOSIZE )
newfifo[ind] = fifo[i-1]; newfifo[ind] = fifo[i-1];
@ -228,6 +228,7 @@ void dpow_addresses()
TWO_STRINGS(iguana,dpow,symbol,pubkey) TWO_STRINGS(iguana,dpow,symbol,pubkey)
{ {
char *retstr,srcaddr[64],destaddr[64]; struct iguana_info *src,*dest; cJSON *ismine; int32_t i,srcvalid,destvalid; struct dpow_info *dp = &myinfo->DPOWS[myinfo->numdpows]; char *retstr,srcaddr[64],destaddr[64]; struct iguana_info *src,*dest; cJSON *ismine; int32_t i,srcvalid,destvalid; struct dpow_info *dp = &myinfo->DPOWS[myinfo->numdpows];
destvalid = srcvalid = 0;
if ( myinfo->NOTARY.RELAYID < 0 ) if ( myinfo->NOTARY.RELAYID < 0 )
{ {
if ( (retstr= basilisk_addrelay_info(myinfo,0,(uint32_t)calc_ipbits(myinfo->ipaddr),myinfo->myaddr.persistent)) != 0 ) if ( (retstr= basilisk_addrelay_info(myinfo,0,(uint32_t)calc_ipbits(myinfo->ipaddr),myinfo->myaddr.persistent)) != 0 )

7
iguana/iguana_payments.c

@ -565,7 +565,7 @@ char *sendtoaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *
jaddnum(valsobj,"basilisktag",basilisktag); jaddnum(valsobj,"basilisktag",basilisktag);
jaddnum(valsobj,"locktime",locktime); jaddnum(valsobj,"locktime",locktime);
jaddnum(valsobj,"timeout",30000); jaddnum(valsobj,"timeout",30000);
if ( 0 && comment != 0 && is_hexstr(comment,0) > 0 ) if ( (0) && comment != 0 && is_hexstr(comment,0) > 0 )
jaddstr(valsobj,"opreturn",comment); jaddstr(valsobj,"opreturn",comment);
if ( (retstr= basilisk_bitcoinrawtx(myinfo,coin,remoteaddr,basilisktag,jint(valsobj,"timeout"),valsobj,V)) != 0 ) if ( (retstr= basilisk_bitcoinrawtx(myinfo,coin,remoteaddr,basilisktag,jint(valsobj,"timeout"),valsobj,V)) != 0 )
{ {
@ -981,6 +981,7 @@ HASH_AND_INT(bitcoinrpc,getrawtransaction,txid,verbose)
if ( coin->notarychain >= 0 && coin->FULLNODE == 0 ) if ( coin->notarychain >= 0 && coin->FULLNODE == 0 )
return(_dex_getrawtransaction(myinfo,coin->symbol,txid)); return(_dex_getrawtransaction(myinfo,coin->symbol,txid));
HASH_FIND(hh,coin->RTdataset,txid.bytes,sizeof(txid),RTptr); HASH_FIND(hh,coin->RTdataset,txid.bytes,sizeof(txid),RTptr);
memset(checktxid.bytes,0,sizeof(checktxid));
if ( RTptr != 0 && RTptr->rawtxbytes != 0 && RTptr->txlen > 0 ) if ( RTptr != 0 && RTptr->rawtxbytes != 0 && RTptr->txlen > 0 )
{ {
checktxid = RTptr->txid; checktxid = RTptr->txid;
@ -1069,7 +1070,7 @@ char *iguana_validaterawtx(struct supernet_info *myinfo,struct iguana_info *coin
if ( (txobj= bitcoin_hex2json(coin,coin->blocks.hwmchain.height,&msgtx->txid,msgtx,rawtx,extraspace,extralen,0,0,suppress_pubkeys)) != 0 ) if ( (txobj= bitcoin_hex2json(coin,coin->blocks.hwmchain.height,&msgtx->txid,msgtx,rawtx,extraspace,extralen,0,0,suppress_pubkeys)) != 0 )
{ {
//printf("txobj.(%s)\n",jprint(txobj,0)); //printf("txobj.(%s)\n",jprint(txobj,0));
if ( 0 && (checkstr= bitcoin_json2hex(myinfo,coin,&txid,txobj,0)) != 0 ) if ( (0) && (checkstr= bitcoin_json2hex(myinfo,coin,&txid,txobj,0)) != 0 )
{ {
// no guarantee byte for byte identical tx is recreated // no guarantee byte for byte identical tx is recreated
if ( strcmp(rawtx,checkstr) != 0 ) if ( strcmp(rawtx,checkstr) != 0 )
@ -1082,7 +1083,7 @@ char *iguana_validaterawtx(struct supernet_info *myinfo,struct iguana_info *coin
break; break;
jaddnum(retjson,"mismatch position",i); jaddnum(retjson,"mismatch position",i);
jadd(retjson,"origtx",txobj); jadd(retjson,"origtx",txobj);
if ( 0 && (txobj= bitcoin_hex2json(coin,coin->blocks.hwmchain.height,&txid,msgtx,checkstr,extraspace,extralen,0,0,suppress_pubkeys)) != 0 ) if ( (0) && (txobj= bitcoin_hex2json(coin,coin->blocks.hwmchain.height,&txid,msgtx,checkstr,extraspace,extralen,0,0,suppress_pubkeys)) != 0 )
jadd(retjson,"checktx",txobj); jadd(retjson,"checktx",txobj);
free(checkstr); free(checkstr);
return(jprint(retjson,1)); return(jprint(retjson,1));

10
iguana/iguana_peers.c

@ -594,7 +594,7 @@ int32_t iguana_send(struct iguana_info *coin,struct iguana_peer *addr,uint8_t *s
} }
} }
addr->totalsent += len; addr->totalsent += len;
if ( 0 && addr->basilisk != 0 ) if ( (0) && addr->basilisk != 0 )
printf("verack.%d (%s) sent.%d bytes to %s\n",addr->msgcounts.verack,cmdstr,len,addr->ipaddr); printf("verack.%d (%s) sent.%d bytes to %s\n",addr->msgcounts.verack,cmdstr,len,addr->ipaddr);
return(len); return(len);
} }
@ -623,7 +623,7 @@ int32_t iguana_queue_send(struct iguana_peer *addr,int32_t delay,uint8_t *serial
packet->embargo.millis += delay; packet->embargo.millis += delay;
} }
memcpy(packet->serialized,serialized,datalen); memcpy(packet->serialized,serialized,datalen);
if ( 0 && addr->supernet != 0 ) if ( (0) && addr->supernet != 0 )
printf("%p queue send.(%s) %d to (%s)\n",packet,serialized+4,datalen,addr->ipaddr); printf("%p queue send.(%s) %d to (%s)\n",packet,serialized+4,datalen,addr->ipaddr);
queue_enqueue("sendQ",&addr->sendQ,&packet->DL); queue_enqueue("sendQ",&addr->sendQ,&packet->DL);
return(datalen); return(datalen);
@ -1050,7 +1050,7 @@ int32_t iguana_pollsendQ(struct iguana_info *coin,struct iguana_peer *addr)
struct iguana_packet *packet; struct iguana_packet *packet;
if ( (packet= queue_dequeue(&addr->sendQ)) != 0 ) if ( (packet= queue_dequeue(&addr->sendQ)) != 0 )
{ {
if ( 0 && (addr->supernet != 0 || strcmp((char *)&packet->serialized[4],"SuperNET") == 0) ) if ( (0) && (addr->supernet != 0 || strcmp((char *)&packet->serialized[4],"SuperNET") == 0) )
printf("%s: send.(%s).%d usock.%d dead.%u ready.%u supernet.%d\n",addr->ipaddr,packet->serialized+4,packet->datalen,addr->usock,addr->dead,addr->ready,addr->supernet); printf("%s: send.(%s).%d usock.%d dead.%u ready.%u supernet.%d\n",addr->ipaddr,packet->serialized+4,packet->datalen,addr->usock,addr->dead,addr->ready,addr->supernet);
if ( strcmp((char *)&packet->serialized[4],"getdata") == 0 ) if ( strcmp((char *)&packet->serialized[4],"getdata") == 0 )
{ {
@ -1385,7 +1385,7 @@ void iguana_dedicatedloop(struct supernet_info *myinfo,struct iguana_info *coin,
} }
} }
//printf(">>>>>>>>>>>>>> finish %s dedicatedloop.%s\n",coin->symbol,addr->ipaddr); //printf(">>>>>>>>>>>>>> finish %s dedicatedloop.%s\n",coin->symbol,addr->ipaddr);
if ( 0 ) if ( (0) )
{ {
if ( addr->vinsfp != 0 ) if ( addr->vinsfp != 0 )
fclose(addr->vinsfp), addr->vinsfp = 0; fclose(addr->vinsfp), addr->vinsfp = 0;
@ -1396,7 +1396,7 @@ void iguana_dedicatedloop(struct supernet_info *myinfo,struct iguana_info *coin,
myfree(buf,bufsize); myfree(buf,bufsize);
//if ( addr->filehash2 != 0 ) //if ( addr->filehash2 != 0 )
// myfree(addr->filehash2,addr->maxfilehash2*sizeof(*addr->filehash2)), addr->filehash2 = 0; // myfree(addr->filehash2,addr->maxfilehash2*sizeof(*addr->filehash2)), addr->filehash2 = 0;
if ( 0 ) if ( (0) )
{ {
iguana_mempurge(&addr->RAWMEM); iguana_mempurge(&addr->RAWMEM);
iguana_mempurge(&addr->TXDATA); iguana_mempurge(&addr->TXDATA);

61
iguana/iguana_ramchain.c

@ -56,7 +56,7 @@ struct iguana_kvitem *iguana_hashsetPT(struct iguana_ramchain *ramchain,int32_t
printf("fatal alloc errorC in hashset\n"); printf("fatal alloc errorC in hashset\n");
iguana_exit(0,0); iguana_exit(0,0);
} }
if ( 0 && ramchain->expanded && selector == 'T' ) if ( (0) && ramchain->expanded && selector == 'T' )
printf("hashmem.%p selector.%c added.(%s) itemind.%x ptr.%p\n",ramchain->hashmem,selector,str,itemind,ptr); printf("hashmem.%p selector.%c added.(%s) itemind.%x ptr.%p\n",ramchain->hashmem,selector,str,itemind,ptr);
if ( selector == 'T' ) if ( selector == 'T' )
HASH_ADD_KEYPTR(hh,ramchain->txids,key,keylen,ptr); HASH_ADD_KEYPTR(hh,ramchain->txids,key,keylen,ptr);
@ -64,14 +64,14 @@ struct iguana_kvitem *iguana_hashsetPT(struct iguana_ramchain *ramchain,int32_t
ptr->hh.itemind = itemind; ptr->hh.itemind = itemind;
//if ( strcmp(str,"0000000000000000000000000000000000000000000000000000000000000000") == 0 ) //if ( strcmp(str,"0000000000000000000000000000000000000000000000000000000000000000") == 0 )
// printf("added null txid?\n"), getchar(); // printf("added null txid?\n"), getchar();
if ( 0 && ramchain->expanded && selector == 'T' ) if ( (0) && ramchain->expanded && selector == 'T' )
printf("selector.%c added.(%s) itemind.%x ptr.%p tmp.%p\n",selector,str,itemind,ptr,tmp); printf("selector.%c added.(%s) itemind.%x ptr.%p tmp.%p\n",selector,str,itemind,ptr,tmp);
if ( itemind == 0 ) if ( itemind == 0 )
{ {
printf("negative itemind\n"); printf("negative itemind\n");
iguana_exit(0,0); iguana_exit(0,0);
} }
if ( 0 ) if ( (0) )
{ {
if ( selector == 'T' ) if ( selector == 'T' )
HASH_FIND(hh,ramchain->txids,key,keylen,tmp); HASH_FIND(hh,ramchain->txids,key,keylen,tmp);
@ -88,7 +88,7 @@ struct iguana_kvitem *iguana_hashsetPT(struct iguana_ramchain *ramchain,int32_t
void iguana_blocksetcounters(struct iguana_info *coin,struct iguana_block *block,struct iguana_ramchain * ramchain) void iguana_blocksetcounters(struct iguana_info *coin,struct iguana_block *block,struct iguana_ramchain * ramchain)
{ {
if ( 0 && coin->virtualchain != 0 ) if ( (0) && coin->virtualchain != 0 )
printf("iguana_blocksetcounters.%s 1st txidind.%u <- ht.%d\n",coin->symbol,ramchain->H.txidind,block->height); printf("iguana_blocksetcounters.%s 1st txidind.%u <- ht.%d\n",coin->symbol,ramchain->H.txidind,block->height);
block->RO.firsttxidind = ramchain->H.txidind; block->RO.firsttxidind = ramchain->H.txidind;
block->RO.firstvout = ramchain->H.unspentind; block->RO.firstvout = ramchain->H.unspentind;
@ -110,7 +110,7 @@ int32_t iguana_peerfname(struct iguana_info *coin,int32_t *hdrsip,char *dirname,
bp = 0, bundlei = -2; bp = 0, bundlei = -2;
if ( bits256_nonz(prevhash2) == 0 || (bp= iguana_bundlefind(coin,&bp,&bundlei,prevhash2)) == 0 || bundlei >= coin->chain->bundlesize-1 ) if ( bits256_nonz(prevhash2) == 0 || (bp= iguana_bundlefind(coin,&bp,&bundlei,prevhash2)) == 0 || bundlei >= coin->chain->bundlesize-1 )
{ {
if ( 0 && dispflag != 0 ) if ( (0) && dispflag != 0 )
printf("iguana_peerfname %s error finding.(%s) spec.%p bp.%p\n",coin->symbol,bits256_str(str,hash2),bp!=0?bp->speculative:0,bp); printf("iguana_peerfname %s error finding.(%s) spec.%p bp.%p\n",coin->symbol,bits256_str(str,hash2),bp!=0?bp->speculative:0,bp);
return(-2); return(-2);
} else bundlei++; } else bundlei++;
@ -191,7 +191,7 @@ uint32_t iguana_ramchain_addtxid(struct iguana_info *coin,RAMCHAIN_FUNC,bits256
} }
else else
{ {
if ( 0 && ramchain->expanded != 0 ) if ( (0) && ramchain->expanded != 0 )
printf("T.%p txidind.%d numvouts.%d numvins.%d\n",T,txidind,numvouts,numvins); printf("T.%p txidind.%d numvouts.%d numvins.%d\n",T,txidind,numvouts,numvins);
t->txidind = txidind, t->txid = txid, t->numvouts = numvouts, t->numvins = numvins; t->txidind = txidind, t->txid = txid, t->numvouts = numvouts, t->numvins = numvins;
t->bundlei = bundlei; t->bundlei = bundlei;
@ -464,7 +464,7 @@ uint32_t iguana_ramchain_addspend(struct iguana_info *coin,RAMCHAIN_FUNC,bits256
{ {
external = 1; external = 1;
txidind = ramchain->externalind++; txidind = ramchain->externalind++;
if ( 0 && ramchain->expanded != 0 ) if ( (0) && ramchain->expanded != 0 )
{ char str[65]; printf("%p X[%d] <- %s\n",X,txidind,bits256_str(str,prev_hash)); } { char str[65]; printf("%p X[%d] <- %s\n",X,txidind,bits256_str(str,prev_hash)); }
if ( ramchain->H.ROflag != 0 ) if ( ramchain->H.ROflag != 0 )
{ {
@ -580,7 +580,7 @@ uint32_t iguana_ramchain_addspend256(struct iguana_info *coin,struct iguana_peer
} else s->scriptpos = 0; } else s->scriptpos = 0;
//else printf("spend256 scriptfpos.%d\n",s->scriptfpos); //else printf("spend256 scriptfpos.%d\n",s->scriptfpos);
char str[65]; char str[65];
if ( 0 && coin->virtualchain != 0 ) if ( (0) && coin->virtualchain != 0 )
printf("W.%p s.%d vout.%d/%d [%d] %s fpos.%u slen.%d\n",s,spendind,s->prevout,prev_vout,bp->hdrsi,bits256_str(str,prev_hash),(uint32_t)s->scriptpos,(int32_t)s->vinscriptlen); printf("W.%p s.%d vout.%d/%d [%d] %s fpos.%u slen.%d\n",s,spendind,s->prevout,prev_vout,bp->hdrsi,bits256_str(str,prev_hash),(uint32_t)s->scriptpos,(int32_t)s->vinscriptlen);
} }
return(spendind); return(spendind);
@ -813,7 +813,7 @@ int64_t _iguana_rdata_action(char *fname,FILE *fp,bits256 lhashes[IGUANA_NUMLHAS
//P2 = 0;//iguana_ramchain_offset(fname,rdata,RAMCHAIN_LARG(IGUANA_LHASH_FIRSTSPENDS),fparg,fpos,P2,&offset,(sizeof(struct iguana_pkextra) * numpkinds),srcsize); //P2 = 0;//iguana_ramchain_offset(fname,rdata,RAMCHAIN_LARG(IGUANA_LHASH_FIRSTSPENDS),fparg,fpos,P2,&offset,(sizeof(struct iguana_pkextra) * numpkinds),srcsize);
A = iguana_ramchain_offset(fname,rdata,RAMCHAIN_LARG(IGUANA_LHASH_ACCOUNTS),fparg,fpos,A,&offset,(sizeof(struct iguana_account) * numpkinds),srcsize); A = iguana_ramchain_offset(fname,rdata,RAMCHAIN_LARG(IGUANA_LHASH_ACCOUNTS),fparg,fpos,A,&offset,(sizeof(struct iguana_account) * numpkinds),srcsize);
char str[65]; char str[65];
if ( 0 && X != 0 ) if ( (0) && X != 0 )
printf("%p X[1] -> %s\n",&X[1],bits256_str(str,X[1])); printf("%p X[1] -> %s\n",&X[1],bits256_str(str,X[1]));
X = iguana_ramchain_offset(fname,rdata,RAMCHAIN_LARG(IGUANA_LHASH_EXTERNALS),fparg,fpos,X,&offset,(sizeof(bits256) * numexternaltxids),srcsize); X = iguana_ramchain_offset(fname,rdata,RAMCHAIN_LARG(IGUANA_LHASH_EXTERNALS),fparg,fpos,X,&offset,(sizeof(bits256) * numexternaltxids),srcsize);
TXbits = iguana_ramchain_offset(fname,rdata,RAMCHAIN_LARG(IGUANA_LHASH_TXBITS),fparg,fpos,TXbits,&offset,hconv_bitlen(txbits),srcsize); TXbits = iguana_ramchain_offset(fname,rdata,RAMCHAIN_LARG(IGUANA_LHASH_TXBITS),fparg,fpos,TXbits,&offset,hconv_bitlen(txbits),srcsize);
@ -823,7 +823,7 @@ int64_t _iguana_rdata_action(char *fname,FILE *fp,bits256 lhashes[IGUANA_NUMLHAS
{ {
Ux = destptr, Sx = destptr, P = destptr, A = destptr, X = destptr, TXbits = destptr, PKbits = destptr, Kspace = destptr; //U2 = destptr, P2 = destptr, Ux = destptr, Sx = destptr, P = destptr, A = destptr, X = destptr, TXbits = destptr, PKbits = destptr, Kspace = destptr; //U2 = destptr, P2 = destptr,
U = iguana_ramchain_offset(fname,rdata,RAMCHAIN_LARG(IGUANA_LHASH_UNSPENTS),fparg,fpos,U,&offset,(sizeof(struct iguana_unspent20) * numunspents),srcsize); U = iguana_ramchain_offset(fname,rdata,RAMCHAIN_LARG(IGUANA_LHASH_UNSPENTS),fparg,fpos,U,&offset,(sizeof(struct iguana_unspent20) * numunspents),srcsize);
if ( 0 && lhashes != 0 ) if ( (0) && lhashes != 0 )
printf("iter.%d lhashes.%p offset.%ld destptr.%p len.%ld fparg.%p fpos.%ld srcsize.%ld\n",iter,RAMCHAIN_LARG(IGUANA_LHASH_SPENDS),(long)offset,destptr,(long)sizeof(struct iguana_spend256) * numspends,fparg,(long)fpos,(long)srcsize); printf("iter.%d lhashes.%p offset.%ld destptr.%p len.%ld fparg.%p fpos.%ld srcsize.%ld\n",iter,RAMCHAIN_LARG(IGUANA_LHASH_SPENDS),(long)offset,destptr,(long)sizeof(struct iguana_spend256) * numspends,fparg,(long)fpos,(long)srcsize);
S = iguana_ramchain_offset(fname,rdata,RAMCHAIN_LARG(IGUANA_LHASH_SPENDS),fparg,fpos,S,&offset,(sizeof(struct iguana_spend256) * numspends),srcsize); S = iguana_ramchain_offset(fname,rdata,RAMCHAIN_LARG(IGUANA_LHASH_SPENDS),fparg,fpos,S,&offset,(sizeof(struct iguana_spend256) * numspends),srcsize);
} }
@ -871,7 +871,7 @@ int64_t _iguana_rdata_action(char *fname,FILE *fp,bits256 lhashes[IGUANA_NUMLHAS
int64_t iguana_ramchain_action(char *fname,RAMCHAIN_FUNC,FILE *fp,bits256 lhashes[IGUANA_NUMLHASHES],struct iguana_ramchaindata *destdata,uint64_t fpos,struct iguana_ramchaindata *srcdata,int32_t numblocks,int32_t scriptspace,uint8_t zcash) int64_t iguana_ramchain_action(char *fname,RAMCHAIN_FUNC,FILE *fp,bits256 lhashes[IGUANA_NUMLHASHES],struct iguana_ramchaindata *destdata,uint64_t fpos,struct iguana_ramchaindata *srcdata,int32_t numblocks,int32_t scriptspace,uint8_t zcash)
{ {
if ( 0 && ramchain->expanded == 0 ) if ( (0) && ramchain->expanded == 0 )
printf("action.%p (%p %p %p) %ld allocated.%ld [%d:%d %d:%d]\n",srcdata,fp,lhashes,destdata,(long)fpos,(long)srcdata->allocsize,srcdata->txsparsebits,srcdata->numtxsparse,srcdata->pksparsebits,srcdata->numpksparse); printf("action.%p (%p %p %p) %ld allocated.%ld [%d:%d %d:%d]\n",srcdata,fp,lhashes,destdata,(long)fpos,(long)srcdata->allocsize,srcdata->txsparsebits,srcdata->numtxsparse,srcdata->pksparsebits,srcdata->numpksparse);
return(_iguana_rdata_action(fname,fp,lhashes,destdata,fpos,ramchain->expanded,srcdata->numtxids,srcdata->numunspents,srcdata->numspends,srcdata->numpkinds,srcdata->numexternaltxids,scriptspace,srcdata->txsparsebits,srcdata->numtxsparse,srcdata->pksparsebits,srcdata->numpksparse,srcdata->allocsize,RAMCHAIN_ARG,numblocks,zcash)); return(_iguana_rdata_action(fname,fp,lhashes,destdata,fpos,ramchain->expanded,srcdata->numtxids,srcdata->numunspents,srcdata->numspends,srcdata->numpkinds,srcdata->numexternaltxids,scriptspace,srcdata->txsparsebits,srcdata->numtxsparse,srcdata->pksparsebits,srcdata->numpksparse,srcdata->allocsize,RAMCHAIN_ARG,numblocks,zcash));
} }
@ -882,7 +882,7 @@ int64_t iguana_ramchain_size(char *fname,RAMCHAIN_FUNC,int32_t numblocks,int32_t
if ( (rdata= ramchain->H.data) != 0 ) if ( (rdata= ramchain->H.data) != 0 )
{ {
allocsize = iguana_ramchain_action(fname,RAMCHAIN_ARG,0,0,0,0,rdata,numblocks,scriptspace,zcash); allocsize = iguana_ramchain_action(fname,RAMCHAIN_ARG,0,0,0,0,rdata,numblocks,scriptspace,zcash);
if ( 0 && ramchain->expanded != 0 ) if ( (0) && ramchain->expanded != 0 )
printf("%p iguana_ramchain_size.expanded.%d %u: Koffset.%u scriptoffset.%u stacksize.%u stackspace.%u [%u]\n",ramchain,ramchain->expanded,(int32_t)allocsize,(int32_t)rdata->Koffset,(int32_t)ramchain->H.scriptoffset,(int32_t)ramchain->H.stacksize,(int32_t)rdata->stackspace,scriptspace); printf("%p iguana_ramchain_size.expanded.%d %u: Koffset.%u scriptoffset.%u stacksize.%u stackspace.%u [%u]\n",ramchain,ramchain->expanded,(int32_t)allocsize,(int32_t)rdata->Koffset,(int32_t)ramchain->H.scriptoffset,(int32_t)ramchain->H.stacksize,(int32_t)rdata->stackspace,scriptspace);
} }
return(allocsize); return(allocsize);
@ -902,7 +902,7 @@ long iguana_ramchain_setsize(char *fname,struct iguana_ramchain *ramchain,struct
rdata->scriptspace = ramchain->H.scriptoffset; rdata->scriptspace = ramchain->H.scriptoffset;
rdata->stackspace = ramchain->H.stacksize; rdata->stackspace = ramchain->H.stacksize;
rdata->allocsize = iguana_ramchain_size(fname,RAMCHAIN_ARG,numblocks,rdata->scriptspace,zcash); rdata->allocsize = iguana_ramchain_size(fname,RAMCHAIN_ARG,numblocks,rdata->scriptspace,zcash);
if ( 0 && rdata->scriptspace != 0 ) if ( (0) && rdata->scriptspace != 0 )
printf("iguana_ramchain_setsize: Koffset.%d scriptspace.%d stackspace.%d (scriptoffset.%d stacksize.%d) allocsize.%d\n",(int32_t)rdata->Koffset,(int32_t)rdata->scriptspace,(int32_t)rdata->stackspace,(int32_t)ramchain->H.scriptoffset,(int32_t)ramchain->H.stacksize,(int32_t)rdata->allocsize); printf("iguana_ramchain_setsize: Koffset.%d scriptspace.%d stackspace.%d (scriptoffset.%d stacksize.%d) allocsize.%d\n",(int32_t)rdata->Koffset,(int32_t)rdata->scriptspace,(int32_t)rdata->stackspace,(int32_t)ramchain->H.scriptoffset,(int32_t)ramchain->H.stacksize,(int32_t)rdata->allocsize);
ramchain->datasize = rdata->allocsize; ramchain->datasize = rdata->allocsize;
return((long)rdata->allocsize); return((long)rdata->allocsize);
@ -929,7 +929,7 @@ int64_t iguana_ramchain_saveaction(char *fname,RAMCHAIN_FUNC,FILE *fp,struct igu
before = ftell(fp); before = ftell(fp);
iguana_ramchain_action(fname,RAMCHAIN_ARG,fp,0,rdata,0,rdata,numblocks,scriptspace,zcash); iguana_ramchain_action(fname,RAMCHAIN_ARG,fp,0,rdata,0,rdata,numblocks,scriptspace,zcash);
after = ftell(fp); after = ftell(fp);
if ( 0 && ramchain->expanded == 0 ) if ( (0) && ramchain->expanded == 0 )
{ {
int32_t i; for (i=0; i<scriptspace&&i<25; i++) int32_t i; for (i=0; i<scriptspace&&i<25; i++)
printf("%02x",Kspace[i]); printf("%02x",Kspace[i]);
@ -964,7 +964,7 @@ int64_t iguana_ramchain_init(char *fname,struct iguana_ramchain *ramchain,struct
numpkinds = numunspents; numpkinds = numunspents;
_iguana_rdata_action(fname,0,0,rdata,0,expanded,numtxids,numunspents,numspends,numpkinds,numexternaltxids,scriptspace,0,0,0,0,0,RAMCHAIN_ARG,numblocks,zcash); _iguana_rdata_action(fname,0,0,rdata,0,expanded,numtxids,numunspents,numspends,numpkinds,numexternaltxids,scriptspace,0,0,0,0,0,RAMCHAIN_ARG,numblocks,zcash);
offset += rdata->allocsize; offset += rdata->allocsize;
if ( 0 && expanded != 0 ) if ( (0) && expanded != 0 )
printf("init T.%d U.%d S.%d P.%d X.%d -> %ld\n",numtxids,numunspents,numspends,numpkinds,numexternaltxids,(long)offset); printf("init T.%d U.%d S.%d P.%d X.%d -> %ld\n",numtxids,numunspents,numspends,numpkinds,numexternaltxids,(long)offset);
if ( rdata->allocsize != iguana_ramchain_size(fname,RAMCHAIN_ARG,numblocks,scriptspace,zcash) ) if ( rdata->allocsize != iguana_ramchain_size(fname,RAMCHAIN_ARG,numblocks,scriptspace,zcash) )
{ {
@ -997,12 +997,12 @@ int32_t iguana_ramchain_alloc(char *fname,struct iguana_info *coin,struct iguana
memset(ramchain,0,sizeof(*ramchain)); memset(ramchain,0,sizeof(*ramchain));
ramchain->height = height; ramchain->height = height;
allocsize = _iguana_rdata_action(fname,0,0,0,0,1,numtxids,numunspents,numspends,numpkinds,numexternaltxids,scriptspace,0,0,0,0,0,RAMCHAIN_ARG,numblocks,zcash); allocsize = _iguana_rdata_action(fname,0,0,0,0,1,numtxids,numunspents,numspends,numpkinds,numexternaltxids,scriptspace,0,0,0,0,0,RAMCHAIN_ARG,numblocks,zcash);
if ( 0 && ramchain->expanded != 0 ) if ( (0) && ramchain->expanded != 0 )
printf("T.%d U.%d S.%d P.%d X.%d -> %ld\n",numtxids,numunspents,numspends,numpkinds,numexternaltxids,(long)allocsize); printf("T.%d U.%d S.%d P.%d X.%d -> %ld\n",numtxids,numunspents,numspends,numpkinds,numexternaltxids,(long)allocsize);
memset(mem,0,sizeof(*mem)); memset(mem,0,sizeof(*mem));
memset(hashmem,0,sizeof(*hashmem)); memset(hashmem,0,sizeof(*hashmem));
hashsize = iguana_hashmemsize(numtxids,numunspents,numspends,numpkinds,numexternaltxids,scriptspace); hashsize = iguana_hashmemsize(numtxids,numunspents,numspends,numpkinds,numexternaltxids,scriptspace);
while ( 0 && (x= (myallocated(0,-1)+hashsize+allocsize + 65536)) > coin->MAXMEM ) while ( (0) && (x= (myallocated(0,-1)+hashsize+allocsize + 65536)) > coin->MAXMEM )
{ {
char str[65],str2[65]; fprintf(stderr,"ht.%d wait for allocated %s < MAXMEM %s | elapsed %.2f minutes hashsize.%ld allocsize.%ld\n",height,mbstr(str,myallocated(0,-1)+hashsize+allocsize),mbstr(str2,coin->MAXMEM),(double)(time(NULL)-coin->startutc)/60.,(long)hashsize,(long)allocsize); char str[65],str2[65]; fprintf(stderr,"ht.%d wait for allocated %s < MAXMEM %s | elapsed %.2f minutes hashsize.%ld allocsize.%ld\n",height,mbstr(str,myallocated(0,-1)+hashsize+allocsize),mbstr(str2,coin->MAXMEM),(double)(time(NULL)-coin->startutc)/60.,(long)hashsize,(long)allocsize);
sleep(13); sleep(13);
@ -1018,7 +1018,7 @@ int32_t iguana_ramchain_alloc(char *fname,struct iguana_info *coin,struct iguana
long iguana_ramchain_save(struct iguana_info *coin,RAMCHAIN_FUNC,uint32_t ipbits,bits256 hash2,bits256 prevhash2,int32_t bundlei,struct iguana_bundle *bp,uint8_t zcash) long iguana_ramchain_save(struct iguana_info *coin,RAMCHAIN_FUNC,uint32_t ipbits,bits256 hash2,bits256 prevhash2,int32_t bundlei,struct iguana_bundle *bp,uint8_t zcash)
{ {
struct iguana_ramchaindata *rdata,tmp; char fname[1024]; long fpos = -1; int32_t hdrsi,checki; FILE *fp; struct iguana_ramchaindata *rdata,tmp; char fname[1024]; long fpos = -1; int32_t hdrsi,checki = 0; FILE *fp;
if ( (rdata= ramchain->H.data) == 0 ) if ( (rdata= ramchain->H.data) == 0 )
{ {
printf("ramchainsave no data ptr\n"); printf("ramchainsave no data ptr\n");
@ -1045,7 +1045,7 @@ long iguana_ramchain_save(struct iguana_info *coin,RAMCHAIN_FUNC,uint32_t ipbits
iguana_ramchain_lhashes(fname,RAMCHAIN_ARG,rdata,rdata,bp!=0?bp->n:1,ramchain->H.scriptoffset,zcash); iguana_ramchain_lhashes(fname,RAMCHAIN_ARG,rdata,rdata,bp!=0?bp->n:1,ramchain->H.scriptoffset,zcash);
tmp = *rdata; tmp = *rdata;
iguana_ramchain_compact(fname,RAMCHAIN_ARG,&tmp,rdata,bp!=0?bp->n:1,zcash); iguana_ramchain_compact(fname,RAMCHAIN_ARG,&tmp,rdata,bp!=0?bp->n:1,zcash);
if ( 0 && ramchain->expanded != 0 ) if ( (0) && ramchain->expanded != 0 )
printf("compact.%s: Koffset.%d scriptoffset.%d stacksize.%d allocsize.%d\n",fname,(int32_t)rdata->Koffset,ramchain->H.scriptoffset,ramchain->H.stacksize,(int32_t)rdata->allocsize); printf("compact.%s: Koffset.%d scriptoffset.%d stacksize.%d allocsize.%d\n",fname,(int32_t)rdata->Koffset,ramchain->H.scriptoffset,ramchain->H.stacksize,(int32_t)rdata->allocsize);
if ( fwrite(&tmp,1,sizeof(tmp),fp) != sizeof(tmp) ) if ( fwrite(&tmp,1,sizeof(tmp),fp) != sizeof(tmp) )
{ {
@ -1346,7 +1346,7 @@ int32_t iguana_Xspendmap(struct iguana_info *coin,struct iguana_ramchain *ramcha
bp->startutxo = bp->utxofinish = (uint32_t)time(NULL); bp->startutxo = bp->utxofinish = (uint32_t)time(NULL);
if ( bp->Xvalid == 0 ) if ( bp->Xvalid == 0 )
{ {
if ( 0 && (rand() % 10) == 0 ) if ( (0) && (rand() % 10) == 0 )
printf("[%d] filesize %ld Xspendptr.%p %p num.%d\n",bp->hdrsi,filesize,ramchain->Xspendptr,ramchain->Xspendinds,ramchain->numXspends); printf("[%d] filesize %ld Xspendptr.%p %p num.%d\n",bp->hdrsi,filesize,ramchain->Xspendptr,ramchain->Xspendinds,ramchain->numXspends);
bp->Xvalid = 1; bp->Xvalid = 1;
} }
@ -1362,7 +1362,7 @@ int32_t iguana_Xspendmap(struct iguana_info *coin,struct iguana_ramchain *ramcha
ramchain->Xspendinds = 0; ramchain->Xspendinds = 0;
} }
} }
else if ( 0 && iter == 1 ) else if ( (0) && iter == 1 )
printf("couldnt map.(%s)\n",fname); printf("couldnt map.(%s)\n",fname);
} }
return(ramchain->numXspends); return(ramchain->numXspends);
@ -1370,7 +1370,7 @@ int32_t iguana_Xspendmap(struct iguana_info *coin,struct iguana_ramchain *ramcha
struct iguana_ramchain *_iguana_ramchain_map(struct supernet_info *myinfo,struct iguana_info *coin,char *fname,struct iguana_bundle *bp,int32_t numblocks,struct iguana_ramchain *ramchain,struct OS_memspace *hashmem,uint32_t ipbits,bits256 hash2,bits256 prevhash2,int32_t bundlei,long fpos,int32_t allocextras,int32_t expanded,uint8_t zcash) struct iguana_ramchain *_iguana_ramchain_map(struct supernet_info *myinfo,struct iguana_info *coin,char *fname,struct iguana_bundle *bp,int32_t numblocks,struct iguana_ramchain *ramchain,struct OS_memspace *hashmem,uint32_t ipbits,bits256 hash2,bits256 prevhash2,int32_t bundlei,long fpos,int32_t allocextras,int32_t expanded,uint8_t zcash)
{ {
RAMCHAIN_DECLARE; int32_t valid,iter,i,checki,hdrsi; long filesize; void *ptr; char str[65],str2[65],dirstr[65]; struct iguana_block *block; struct iguana_zblockRO zRO; struct iguana_ramchaindata *rdata; RAMCHAIN_DECLARE; int32_t valid,iter,i,checki,hdrsi; long filesize=0; void *ptr; char str[65],str2[65],dirstr[65]; struct iguana_block *block; struct iguana_zblockRO zRO; struct iguana_ramchaindata *rdata;
/*if ( ramchain->expanded != 0 && (ramchain->sigsfileptr == 0 || ramchain->sigsfilesize == 0) ) /*if ( ramchain->expanded != 0 && (ramchain->sigsfileptr == 0 || ramchain->sigsfilesize == 0) )
{ {
sprintf(sigsfname,"sigs/%s/%s",coin->symbol,bits256_str(str,hash2)); sprintf(sigsfname,"sigs/%s/%s",coin->symbol,bits256_str(str,hash2));
@ -1423,7 +1423,7 @@ struct iguana_ramchain *_iguana_ramchain_map(struct supernet_info *myinfo,struct
ramchain->expanded = expanded; ramchain->expanded = expanded;
ramchain->numblocks = (bp == 0) ? 1 : bp->n; ramchain->numblocks = (bp == 0) ? 1 : bp->n;
//printf("ptr.%p exp.%d extra.%d %p mapped P[%d] fpos.%d + %ld -> %ld vs %ld offset.%u:%u stack.%u:%u\n",ptr,expanded,allocextras,rdata,(int32_t)rdata->Poffset,(int32_t)fpos,(long)rdata->allocsize,(long)(fpos + rdata->allocsize),ramchain->filesize,rscriptoffset,rdata->scriptspace,rstacksize,rdata->stackspace); //printf("ptr.%p exp.%d extra.%d %p mapped P[%d] fpos.%d + %ld -> %ld vs %ld offset.%u:%u stack.%u:%u\n",ptr,expanded,allocextras,rdata,(int32_t)rdata->Poffset,(int32_t)fpos,(long)rdata->allocsize,(long)(fpos + rdata->allocsize),ramchain->filesize,rscriptoffset,rdata->scriptspace,rstacksize,rdata->stackspace);
if ( 0 && bp != 0 ) if ( (0) && bp != 0 )
{ {
/*blocksRO = (struct iguana_blockRO *)rdata; /*blocksRO = (struct iguana_blockRO *)rdata;
for (i=0; i<bp->n; i++) for (i=0; i<bp->n; i++)
@ -1637,7 +1637,7 @@ int32_t iguana_ramchain_cmp(struct iguana_ramchain *A,struct iguana_ramchain *B,
int32_t iguana_ramchain_iterate(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_ramchain *dest,struct iguana_ramchain *ramchain,struct iguana_bundle *bp,int16_t bundlei) int32_t iguana_ramchain_iterate(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_ramchain *dest,struct iguana_ramchain *ramchain,struct iguana_bundle *bp,int16_t bundlei)
{ {
RAMCHAIN_DECLARE; RAMCHAIN_DESTDECLARE; RAMCHAIN_DESTZEROES; RAMCHAIN_DECLARE; RAMCHAIN_DESTDECLARE; RAMCHAIN_DESTZEROES;
int32_t j,hdrsi,prevout,scriptlen; uint32_t timestamp=0,unspentind,sequenceid,destspendind=0,desttxidind=0; uint16_t fileid; uint64_t scriptpos; int64_t crypto777_payment = 0; int32_t j,hdrsi,prevout,scriptlen; uint32_t timestamp=0,unspentind,sequenceid=0,destspendind=0,desttxidind=0; uint16_t fileid; uint64_t scriptpos; int64_t crypto777_payment = 0;
bits256 prevhash; uint64_t value; uint8_t type; struct iguana_unspent *u; bits256 prevhash; uint64_t value; uint8_t type; struct iguana_unspent *u;
struct iguana_txid *tx; struct iguana_ramchaindata *rdata; uint8_t rmd160[20]; struct iguana_txid *tx; struct iguana_ramchaindata *rdata; uint8_t rmd160[20];
//if ( dest != 0 ) //if ( dest != 0 )
@ -1667,7 +1667,7 @@ int32_t iguana_ramchain_iterate(struct supernet_info *myinfo,struct iguana_info
{ {
if ( coin->active == 0 ) if ( coin->active == 0 )
return(-1);; return(-1);;
if ( 0 && ramchain->expanded == 0 && dest != 0 ) if ( (0) && ramchain->expanded == 0 && dest != 0 )
printf("ITER [%d] TXID.%d -> dest.%p desttxid.%d dest->hashmem.%p numtxids.%d\n",rdata->height,ramchain->H.txidind,dest,dest!=0?dest->H.txidind:0,dest!=0?dest->hashmem:0,rdata->numtxids); printf("ITER [%d] TXID.%d -> dest.%p desttxid.%d dest->hashmem.%p numtxids.%d\n",rdata->height,ramchain->H.txidind,dest,dest!=0?dest->H.txidind:0,dest!=0?dest->hashmem:0,rdata->numtxids);
tx = &T[ramchain->H.txidind]; tx = &T[ramchain->H.txidind];
if ( iguana_ramchain_addtxid(coin,RAMCHAIN_ARG,tx->txid,tx->numvouts,tx->numvins,tx->locktime,tx->version,tx->timestamp,bundlei) == 0 ) if ( iguana_ramchain_addtxid(coin,RAMCHAIN_ARG,tx->txid,tx->numvouts,tx->numvins,tx->locktime,tx->version,tx->timestamp,bundlei) == 0 )
@ -1678,7 +1678,7 @@ int32_t iguana_ramchain_iterate(struct supernet_info *myinfo,struct iguana_info
if ( dest->expanded != 0 ) if ( dest->expanded != 0 )
iguana_opreturn(myinfo,1,coin,tx->timestamp,bp,0,bp->bundleheight + bundlei,(((uint64_t)bp->hdrsi << 32) | dest->H.unspentind),0,0,0,0); iguana_opreturn(myinfo,1,coin,tx->timestamp,bp,0,bp->bundleheight + bundlei,(((uint64_t)bp->hdrsi << 32) | dest->H.unspentind),0,0,0,0);
//char str[65]; //char str[65];
if ( 0 && ramchain->expanded == 0 ) if ( (0) && ramchain->expanded == 0 )
printf("ITER [%d] TXID.%d -> dest.%p desttxid.%d dest->hashmem.%p numtxids.%d\n",rdata->height,ramchain->H.txidind,dest,dest!=0?dest->H.txidind:0,dest!=0?dest->hashmem:0,rdata->numtxids); printf("ITER [%d] TXID.%d -> dest.%p desttxid.%d dest->hashmem.%p numtxids.%d\n",rdata->height,ramchain->H.txidind,dest,dest!=0?dest->H.txidind:0,dest!=0?dest->hashmem:0,rdata->numtxids);
if ( iguana_ramchain_addtxid(coin,RAMCHAIN_DESTARG,tx->txid,tx->numvouts,tx->numvins,tx->locktime,tx->version,tx->timestamp,bundlei) == 0 ) if ( iguana_ramchain_addtxid(coin,RAMCHAIN_DESTARG,tx->txid,tx->numvouts,tx->numvins,tx->locktime,tx->version,tx->timestamp,bundlei) == 0 )
return(-2); return(-2);
@ -1689,6 +1689,7 @@ int32_t iguana_ramchain_iterate(struct supernet_info *myinfo,struct iguana_info
if ( coin->active == 0 ) if ( coin->active == 0 )
return(-1); return(-1);
fileid = 0; fileid = 0;
unspentind = 0;
scriptpos = 0; scriptpos = 0;
scriptlen = 0; scriptlen = 0;
memset(rmd160,0,sizeof(rmd160)); memset(rmd160,0,sizeof(rmd160));
@ -1740,7 +1741,7 @@ int32_t iguana_ramchain_iterate(struct supernet_info *myinfo,struct iguana_info
} //else printf("no script\n");*/ } //else printf("no script\n");*/
if ( (unspentind= iguana_ramchain_addunspent20(coin,0,RAMCHAIN_ARG,value,0,scriptlen,tx->txid,j,type,bp,rmd160)) == 0 ) if ( (unspentind= iguana_ramchain_addunspent20(coin,0,RAMCHAIN_ARG,value,0,scriptlen,tx->txid,j,type,bp,rmd160)) == 0 )
return(-4); return(-4);
if ( 0 ) if ( (0) )
{ {
int32_t i; for (i=0; i<20; i++) int32_t i; for (i=0; i<20; i++)
printf("%02x",rmd160[i]); printf("%02x",rmd160[i]);
@ -1839,7 +1840,7 @@ int32_t iguana_ramchain_iterate(struct supernet_info *myinfo,struct iguana_info
long iguana_ramchain_data(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,struct iguana_txblock *origtxdata,struct iguana_msgtx *txarray,int32_t txn_count,uint8_t *data,int32_t recvlen,struct iguana_bundle *bp,struct iguana_block *block) long iguana_ramchain_data(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,struct iguana_txblock *origtxdata,struct iguana_msgtx *txarray,int32_t txn_count,uint8_t *data,int32_t recvlen,struct iguana_bundle *bp,struct iguana_block *block)
{ {
int32_t verifyflag = 0; int32_t verifyflag = 0;
RAMCHAIN_DECLARE; struct iguana_ramchain R,*mapchain,*ramchain = &addr->ramchain; struct iguana_msgtx *tx; char fname[1024]; uint8_t rmd160[20]; struct iguana_ramchaindata *rdata; int32_t i,j,fpos,pubkeysize,sigsize,subdir,firsti=1,err,flag,bundlei; uint32_t scriptspace,stackspace; struct iguana_blockRO RO; RAMCHAIN_DECLARE; struct iguana_ramchain R,*mapchain,*ramchain = &addr->ramchain; struct iguana_msgtx *tx; char fname[1024]; uint8_t rmd160[20]; struct iguana_ramchaindata *rdata; int32_t i,j,fpos,pubkeysize,sigsize,subdir,firsti=1,err,flag,bundlei=0; uint32_t scriptspace,stackspace; struct iguana_blockRO RO;
if ( block == 0 || bp == 0 || addr == 0 || (block != 0 && (bundlei= block->bundlei) < 0) ) if ( block == 0 || bp == 0 || addr == 0 || (block != 0 && (bundlei= block->bundlei) < 0) )
{ {
//printf("iguana_ramchain_data: null ptr %p %p %p\n",block,bp,addr); //printf("iguana_ramchain_data: null ptr %p %p %p\n",block,bp,addr);
@ -2028,7 +2029,7 @@ void iguana_blockdelete(struct iguana_info *coin,bits256 hash2,int32_t i)
void iguana_blockunmark(struct iguana_info *coin,struct iguana_block *block,struct iguana_bundle *bp,int32_t i,int32_t deletefile) void iguana_blockunmark(struct iguana_info *coin,struct iguana_block *block,struct iguana_bundle *bp,int32_t i,int32_t deletefile)
{ {
void *ptr; int32_t recvlen,height = -1; void *ptr; int32_t recvlen,height = -1;
if ( 0 && bp != 0 ) if ( (0) && bp != 0 )
printf("UNMARK.[%d:%d]\n",bp->hdrsi,i); printf("UNMARK.[%d:%d]\n",bp->hdrsi,i);
if ( block != 0 ) if ( block != 0 )
{ {
@ -2056,7 +2057,7 @@ void iguana_blockunmark(struct iguana_info *coin,struct iguana_block *block,stru
} }
if ( deletefile != 0 && block != 0 ) if ( deletefile != 0 && block != 0 )
iguana_blockdelete(coin,block->RO.hash2,i); iguana_blockdelete(coin,block->RO.hash2,i);
if ( 0 && coin->RTheight > 0 && height > 0 && height < coin->blocks.hwmchain.height ) if ( (0) && coin->RTheight > 0 && height > 0 && height < coin->blocks.hwmchain.height )
{ {
printf("reduce %s HWM height from %d to %d\n",coin->symbol,coin->blocks.hwmchain.height,height); printf("reduce %s HWM height from %d to %d\n",coin->symbol,coin->blocks.hwmchain.height,height);
if ( (block= iguana_blockfind("unmark",coin,iguana_blockhash(coin,height))) != 0 ) if ( (block= iguana_blockfind("unmark",coin,iguana_blockhash(coin,height))) != 0 )

10
iguana/iguana_realtime.c

@ -170,7 +170,7 @@ void iguana_RTcoinaddr(struct iguana_info *coin,struct iguana_RTtxid *RTptr,stru
} }
} }
//printf("%s %.8f [%.8f - %.8f] -> %.8f\n",coinaddr,dstr(value),dstr(coin->RTcredits),dstr(coin->RTdebits),dstr(coin->histbalance)+dstr(coin->RTcredits)-dstr(coin->RTdebits)); //printf("%s %.8f [%.8f - %.8f] -> %.8f\n",coinaddr,dstr(value),dstr(coin->RTcredits),dstr(coin->RTdebits),dstr(coin->histbalance)+dstr(coin->RTcredits)-dstr(coin->RTdebits));
if ( 0 && strcmp("BTC",coin->symbol) != 0 && strcmp("LTC",coin->symbol) != 0 && strcmp("DOGE",coin->symbol) != 0 ) if ( (0) && strcmp("BTC",coin->symbol) != 0 && strcmp("LTC",coin->symbol) != 0 && strcmp("DOGE",coin->symbol) != 0 )
printf("%lld %s %.8f h %.8f, cr %.8f deb %.8f [%.8f] numunspents.%d %p\n",(long long)polarity,coinaddr,dstr(value),dstr(RTaddr->histbalance),dstr(RTaddr->credits),dstr(RTaddr->debits),dstr(RTaddr->credits)-dstr(RTaddr->debits)+dstr(RTaddr->histbalance),RTaddr->numunspents,unspent); printf("%lld %s %.8f h %.8f, cr %.8f deb %.8f [%.8f] numunspents.%d %p\n",(long long)polarity,coinaddr,dstr(value),dstr(RTaddr->histbalance),dstr(RTaddr->credits),dstr(RTaddr->debits),dstr(RTaddr->credits)-dstr(RTaddr->debits)+dstr(RTaddr->histbalance),RTaddr->numunspents,unspent);
} }
@ -352,7 +352,7 @@ struct iguana_RTtxid *iguana_RTtxid_create(struct iguana_info *coin,struct iguan
} }
HASH_ADD_KEYPTR(hh,coin->RTdataset,RTptr->txid.bytes,sizeof(RTptr->txid),RTptr); HASH_ADD_KEYPTR(hh,coin->RTdataset,RTptr->txid.bytes,sizeof(RTptr->txid),RTptr);
bits256_str(str,txid); bits256_str(str,txid);
if ( 0 && strcmp("BTC",coin->symbol) != 0 ) if ( (0) && strcmp("BTC",coin->symbol) != 0 )
printf("%s.%d txid.(%s) vouts.%d vins.%d version.%d lock.%u t.%u %lld\n",coin->symbol,block->height,str,numvouts,numvins,version,locktime,timestamp,(long long)polarity); printf("%s.%d txid.(%s) vouts.%d vins.%d version.%d lock.%u t.%u %lld\n",coin->symbol,block->height,str,numvouts,numvins,version,locktime,timestamp,(long long)polarity);
} }
else if ( RTptr->txn_count != txn_count || RTptr->numvouts != numvouts || RTptr->numvins != numvins ) else if ( RTptr->txn_count != txn_count || RTptr->numvouts != numvouts || RTptr->numvins != numvins )
@ -630,7 +630,7 @@ void *iguana_RTrawdata(struct iguana_info *coin,bits256 hash2,uint8_t *data,int3
return(&ptr[sizeof(*recvlenp) + sizeof(checknumtx)]); return(&ptr[sizeof(*recvlenp) + sizeof(checknumtx)]);
} else printf("checklen.%d vs %d, checknumtx %d vs %d\n",checklen,(int32_t)(filesize - sizeof(checklen) - sizeof(checknumtx)),checknumtx,*numtxp); } else printf("checklen.%d vs %d, checknumtx %d vs %d\n",checklen,(int32_t)(filesize - sizeof(checklen) - sizeof(checknumtx)),checknumtx,*numtxp);
} }
else if ( 0 ) else if ( (0) )
{ {
OS_removefile(fname,0); OS_removefile(fname,0);
printf("(%s) removed to suppress errors\n",fname); printf("(%s) removed to suppress errors\n",fname);
@ -701,7 +701,7 @@ int32_t iguana_RTiterate(struct supernet_info *myinfo,struct iguana_info *coin,i
{ {
num++; num++;
iguana_blockQ("RTiterate",coin,0,-1,block->RO.hash2,1); iguana_blockQ("RTiterate",coin,0,-1,block->RO.hash2,1);
if ( 0 && coin->peers != 0 && (n= coin->peers->numranked) > 0 ) if ( (0) && coin->peers != 0 && (n= coin->peers->numranked) > 0 )
{ {
if ( (addr= coin->peers->ranked[rand() % n]) != 0 ) if ( (addr= coin->peers->ranked[rand() % n]) != 0 )
iguana_sendblockreqPT(coin,addr,0,-1,block->RO.hash2,1); iguana_sendblockreqPT(coin,addr,0,-1,block->RO.hash2,1);
@ -809,7 +809,7 @@ void iguana_RTnewblock(struct supernet_info *myinfo,struct iguana_info *coin,str
}*/ }*/
if ( block->height < coin->firstRTheight || block->height >= coin->firstRTheight+sizeof(coin->RTblocks)/sizeof(*coin->RTblocks) ) if ( block->height < coin->firstRTheight || block->height >= coin->firstRTheight+sizeof(coin->RTblocks)/sizeof(*coin->RTblocks) )
{ {
if ( 0 && coin->firstRTheight > 0 ) if ( (0) && coin->firstRTheight > 0 )
printf("iguana_RTnewblock illegal blockheight.%d\n",block->height); printf("iguana_RTnewblock illegal blockheight.%d\n",block->height);
return; return;
} }

62
iguana/iguana_recv.c

@ -85,7 +85,7 @@ int32_t iguana_sendblockreqPT(struct iguana_info *coin,struct iguana_peer *addr,
} }
if ( checkbp != bp || j != bundlei ) if ( checkbp != bp || j != bundlei )
bp = 0, bundlei = -1; bp = 0, bundlei = -1;
if ( 0 && coin->enableCACHE != 0 && iguana_speculativesearch(coin,&block,hash2) != 0 ) if ( (0) && coin->enableCACHE != 0 && iguana_speculativesearch(coin,&block,hash2) != 0 )
{ {
if ( block != 0 && block->hdrsi != 0 && block->bundlei != 0 ) if ( block != 0 && block->hdrsi != 0 && block->bundlei != 0 )
{ {
@ -127,7 +127,7 @@ int32_t iguana_sendblockreqPT(struct iguana_info *coin,struct iguana_peer *addr,
iguana_send(coin,addr,serialized,len); iguana_send(coin,addr,serialized,len);
if ( block != 0 ) if ( block != 0 )
block->issued = addr->pendtime; block->issued = addr->pendtime;
if ( 0 && coin->current == bp ) if ( (0) && coin->current == bp )
printf("REQ.(%s) [%d:%d] %s n.%d\n",bits256_str(hexstr,hash2),bundlei,bp!=0?bp->hdrsi:-1,addr->ipaddr,addr->pendblocks); printf("REQ.(%s) [%d:%d] %s n.%d\n",bits256_str(hexstr,hash2),bundlei,bp!=0?bp->hdrsi:-1,addr->ipaddr,addr->pendblocks);
} else printf("MSG_BLOCK null datalen.%d\n",len); } else printf("MSG_BLOCK null datalen.%d\n",len);
return(len); return(len);
@ -267,7 +267,7 @@ int32_t iguana_speculativefind(struct iguana_info *coin,struct iguana_bundle *bp
for (j=numcached=0; j<bp->n; j++) for (j=numcached=0; j<bp->n; j++)
if ( bp->speculativecache[j] != 0 ) if ( bp->speculativecache[j] != 0 )
numcached++; numcached++;
if ( 0 && bp == coin->current ) if ( (0) && bp == coin->current )
printf("cache %s [%d:%d] h.%d s.%d c.%d -> %d\n",bits256_str(str,block->RO.hash2),bp->hdrsi,i,bp->numhashes,bp->numsaved,bp->numcached,numcached); printf("cache %s [%d:%d] h.%d s.%d c.%d -> %d\n",bits256_str(str,block->RO.hash2),bp->hdrsi,i,bp->numhashes,bp->numsaved,bp->numcached,numcached);
return(i); return(i);
} }
@ -326,7 +326,7 @@ void iguana_oldgotblockM(struct supernet_info *myinfo,struct iguana_info *coin,s
printf("iguana_getblockM: illegal recvlen.%d\n",recvlen); printf("iguana_getblockM: illegal recvlen.%d\n",recvlen);
return; return;
} }
if ( 0 ) if ( (0) )
{ {
for (i=0; i<txdata->space[0]; i++) for (i=0; i<txdata->space[0]; i++)
if ( txdata->space[i] != 0 ) if ( txdata->space[i] != 0 )
@ -356,7 +356,7 @@ void iguana_oldgotblockM(struct supernet_info *myinfo,struct iguana_info *coin,s
{ {
printf("got block that doesnt validate? %s\n",bits256_str(str,origtxdata->zblock.RO.hash2)); printf("got block that doesnt validate? %s\n",bits256_str(str,origtxdata->zblock.RO.hash2));
return; return;
} else if ( 0 && coin->enableCACHE != 0 ) } else if ( (0) && coin->enableCACHE != 0 )
printf("c.%d v.(%s) %s n%d\n",coin->enableCACHE,bits256_str(str,origtxdata->zblock.RO.hash2),addr->ipaddr,addr->pendblocks); printf("c.%d v.(%s) %s n%d\n",coin->enableCACHE,bits256_str(str,origtxdata->zblock.RO.hash2),addr->ipaddr,addr->pendblocks);
origtxdata->zblock.txvalid = 1; origtxdata->zblock.txvalid = 1;
if ( fromcache == 0 && coin->virtualchain == 0 && addr != 0 && addr != &coin->internaladdr ) if ( fromcache == 0 && coin->virtualchain == 0 && addr != 0 && addr != &coin->internaladdr )
@ -430,7 +430,7 @@ void iguana_oldgotblockM(struct supernet_info *myinfo,struct iguana_info *coin,s
else else
{ {
iguana_bundletime(coin,bp,bundlei,block,0); iguana_bundletime(coin,bp,bundlei,block,0);
if ( 0 && bp == coin->current ) if ( (0) && bp == coin->current )
printf("recv [%d:%d] %s\n",bp->hdrsi,bundlei,bits256_str(str,block->RO.hash2)); printf("recv [%d:%d] %s\n",bp->hdrsi,bundlei,bits256_str(str,block->RO.hash2));
} }
} }
@ -462,7 +462,7 @@ void iguana_oldgotblockM(struct supernet_info *myinfo,struct iguana_info *coin,s
req = iguana_bundlereq(coin,addr,'B',data,copyflag * recvlen); req = iguana_bundlereq(coin,addr,'B',data,copyflag * recvlen);
req->copyflag = 1; req->copyflag = 1;
req->H = *H; req->H = *H;
if ( 0 && iguana_sethdr(&checkH,coin->chain->netmagic,H->command,req->serializeddata,recvlen) > 0 && memcmp(&checkH,H,sizeof(checkH)) != 0 ) if ( (0) && iguana_sethdr(&checkH,coin->chain->netmagic,H->command,req->serializeddata,recvlen) > 0 && memcmp(&checkH,H,sizeof(checkH)) != 0 )
{ {
int z; int z;
for (z=0; z<sizeof(checkH); z++) for (z=0; z<sizeof(checkH); z++)
@ -527,7 +527,7 @@ void iguana_oldgotblockM(struct supernet_info *myinfo,struct iguana_info *coin,s
req->addr = addr; req->addr = addr;
//if ( (bits256_cmp(origtxdata->zblock.RO.hash2,coin->blocks.hwmchain.RO.hash2) == 0 || req->zblock.mainchain == 0 || req->zblock.valid == 0 || req->zblock.txvalid == 0) && iguana_RTrawdata(coin,origtxdata->zblock.RO.hash2,0,&len,&numtx,1) == 0 ) //if ( (bits256_cmp(origtxdata->zblock.RO.hash2,coin->blocks.hwmchain.RO.hash2) == 0 || req->zblock.mainchain == 0 || req->zblock.valid == 0 || req->zblock.txvalid == 0) && iguana_RTrawdata(coin,origtxdata->zblock.RO.hash2,0,&len,&numtx,1) == 0 )
queue_enqueue("recvQ",&coin->recvQ,&req->DL); queue_enqueue("recvQ",&coin->recvQ,&req->DL);
if ( 0 && strcmp("BTCD",coin->symbol) == 0 ) if ( (0) && strcmp("BTCD",coin->symbol) == 0 )
printf("%s Q.(%s)\n",coin->symbol,bits256_str(str,origtxdata->zblock.RO.hash2)); printf("%s Q.(%s)\n",coin->symbol,bits256_str(str,origtxdata->zblock.RO.hash2));
} else printf("nonz fpos.%d %s\n",txdata->zblock.fpos,bits256_str(str,origtxdata->zblock.RO.hash2)); } else printf("nonz fpos.%d %s\n",txdata->zblock.fpos,bits256_str(str,origtxdata->zblock.RO.hash2));
} }
@ -609,7 +609,7 @@ int32_t iguana_bundlestats_update(struct iguana_info *coin,struct iguana_block *
else else
{ {
iguana_bundletime(coin,bp,bundlei,block,0); iguana_bundletime(coin,bp,bundlei,block,0);
if ( 0 && bp == coin->current ) if ( (0) && bp == coin->current )
printf("recv [%d:%d] %s\n",bp->hdrsi,bundlei,bits256_str(str,block->RO.hash2)); printf("recv [%d:%d] %s\n",bp->hdrsi,bundlei,bits256_str(str,block->RO.hash2));
return(0); return(0);
} }
@ -648,7 +648,7 @@ struct iguana_bundlereq *iguana_recv_bundlereq(struct iguana_info *coin,struct i
req = iguana_bundlereq(coin,addr,'B',data,copyflag * recvlen); req = iguana_bundlereq(coin,addr,'B',data,copyflag * recvlen);
req->copyflag = 1; req->copyflag = 1;
req->H = *H; req->H = *H;
if ( 0 && iguana_sethdr(&checkH,coin->chain->netmagic,H->command,req->serializeddata,recvlen) > 0 && memcmp(&checkH,H,sizeof(checkH)) != 0 ) if ( (0) && iguana_sethdr(&checkH,coin->chain->netmagic,H->command,req->serializeddata,recvlen) > 0 && memcmp(&checkH,H,sizeof(checkH)) != 0 )
{ {
int z; int z;
for (z=0; z<sizeof(checkH); z++) for (z=0; z<sizeof(checkH); z++)
@ -859,7 +859,7 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru
copyflag = (coin->enableCACHE != 0) && (strcmp(coin->symbol,"BTC") != 0); copyflag = (coin->enableCACHE != 0) && (strcmp(coin->symbol,"BTC") != 0);
req = iguana_recv_bundlereq(coin,addr,copyflag,H,data,recvlen,bp,bundlei,txdata); req = iguana_recv_bundlereq(coin,addr,copyflag,H,data,recvlen,bp,bundlei,txdata);
queue_enqueue("recvQ",&coin->recvQ,&req->DL); queue_enqueue("recvQ",&coin->recvQ,&req->DL);
if ( 0 && bp->hdrsi == 0 && strcmp("SYS",coin->symbol) == 0 ) if ( (0) && bp->hdrsi == 0 && strcmp("SYS",coin->symbol) == 0 )
printf("[%d:%d].s%d %s Q.(%s) %s\n",bp->hdrsi,bundlei,numsaved,coin->symbol,bits256_str(str,origtxdata->zblock.RO.hash2),addr->ipaddr); printf("[%d:%d].s%d %s Q.(%s) %s\n",bp->hdrsi,bundlei,numsaved,coin->symbol,bits256_str(str,origtxdata->zblock.RO.hash2),addr->ipaddr);
if ( numsaved < coin->chain->bundlesize ) if ( numsaved < coin->chain->bundlesize )
{ {
@ -991,14 +991,14 @@ void iguana_gotblockhashesM(struct iguana_info *coin,struct iguana_peer *addr,bi
req = iguana_bundlereq(coin,addr,'S',0,0); req = iguana_bundlereq(coin,addr,'S',0,0);
req->hashes = blockhashes, req->n = n; req->hashes = blockhashes, req->n = n;
char str[65]; char str[65];
if ( 0 && n > 2 && addr != 0 ) if ( (0) && n > 2 && addr != 0 )
printf("addr.%d %s [%d]\n",addr->rank,bits256_str(str,blockhashes[1]),n); printf("addr.%d %s [%d]\n",addr->rank,bits256_str(str,blockhashes[1]),n);
queue_enqueue("recvQ",&coin->recvQ,&req->DL); queue_enqueue("recvQ",&coin->recvQ,&req->DL);
if ( strcmp("BTC",coin->symbol) != 0 ) if ( strcmp("BTC",coin->symbol) != 0 )
{ {
if ( n > coin->chain->bundlesize ) if ( n > coin->chain->bundlesize )
iguana_sendblockreqPT(coin,addr,0,-1,blockhashes[1],0); iguana_sendblockreqPT(coin,addr,0,-1,blockhashes[1],0);
if ( 0 && coin->RTheight > 0 ) if ( (0) && coin->RTheight > 0 )
{ {
for (i=1; i<num; i++) for (i=1; i<num; i++)
iguana_sendblockreqPT(coin,0,0,-1,blockhashes[i],0); iguana_sendblockreqPT(coin,0,0,-1,blockhashes[i],0);
@ -1051,7 +1051,7 @@ uint32_t iguana_allhashcmp(struct supernet_info *myinfo,struct iguana_info *coin
//n = 0; //n = 0;
//if ( bp->hdrsi < coin->MAXBUNDLES || (coin->current != 0 && coin->lastpending != 0 && bp->hdrsi >= coin->current->hdrsi && bp->hdrsi <= coin->lastpending->hdrsi) ) //if ( bp->hdrsi < coin->MAXBUNDLES || (coin->current != 0 && coin->lastpending != 0 && bp->hdrsi >= coin->current->hdrsi && bp->hdrsi <= coin->lastpending->hdrsi) )
// n = iguana_bundleissuemissing(myinfo,coin,bp,1,3.); // n = iguana_bundleissuemissing(myinfo,coin,bp,1,3.);
if ( 0 && n > 2 ) if ( (0) && n > 2 )
printf("ALLHASHES FOUND! %d allhashes.%d issued %d\n",bp->bundleheight,coin->allhashes,n); printf("ALLHASHES FOUND! %d allhashes.%d issued %d\n",bp->bundleheight,coin->allhashes,n);
//if ( bp->queued == 0 ) //if ( bp->queued == 0 )
// iguana_bundleQ(myinfo,coin,bp,bp->n*5 + (rand() % 500)); // iguana_bundleQ(myinfo,coin,bp,bp->n*5 + (rand() % 500));
@ -1105,7 +1105,7 @@ int32_t iguana_bundlehashadd(struct iguana_info *coin,struct iguana_bundle *bp,i
if ( firstflag != 0 && bp->emitfinish == 0 ) if ( firstflag != 0 && bp->emitfinish == 0 )
{ {
//block->fpos = -1; //block->fpos = -1;
if ( 0 && iguana_ramchainfile(SuperNET_MYINFO(0),coin,0,&blockR,bp,bundlei,block) == 0 ) if ( (0) && iguana_ramchainfile(SuperNET_MYINFO(0),coin,0,&blockR,bp,bundlei,block) == 0 )
{ {
size = sizeof(blockR); size = sizeof(blockR);
iguana_ramchain_free(coin,&blockR,1); iguana_ramchain_free(coin,&blockR,1);
@ -1192,7 +1192,7 @@ void iguana_mainchain_clear(struct supernet_info *myinfo,struct iguana_info *coi
return; return;
} }
} }
if ( 0 && tmp != mainchain && coin->RTheight > 0 ) if ( (0) && tmp != mainchain && coin->RTheight > 0 )
printf("iguana_mainchain_clear: unexpected mismatch ht.%d vs %d %s\n",tmp->height,mainchain->height,bits256_str(str,tmp->RO.hash2)); printf("iguana_mainchain_clear: unexpected mismatch ht.%d vs %d %s\n",tmp->height,mainchain->height,bits256_str(str,tmp->RO.hash2));
} }
} }
@ -1208,7 +1208,7 @@ int32_t iguana_height_estimate(struct iguana_info *coin,struct iguana_block **ma
if ( tmp->mainchain != 0 && tmp->height >= 0 ) if ( tmp->mainchain != 0 && tmp->height >= 0 )
{ {
char str[65]; char str[65];
if ( 0 && n > 0 && coin->RTheight > 0 ) if ( (0) && n > 0 && coin->RTheight > 0 )
printf("%s M.%d dist.%d -> %d\n",bits256_str(str,block->RO.hash2),tmp->height,n,tmp->height+n); printf("%s M.%d dist.%d -> %d\n",bits256_str(str,block->RO.hash2),tmp->height,n,tmp->height+n);
*mainchainp = tmp; *mainchainp = tmp;
return(tmp->height + n); return(tmp->height + n);
@ -1416,7 +1416,7 @@ struct iguana_bundlereq *iguana_recvblockhdrs(struct supernet_info *myinfo,struc
prevhash2 = zblocks[i].RO.hash2; prevhash2 = zblocks[i].RO.hash2;
} }
char str[65]; char str[65];
if ( 0 && bp == coin->current ) if ( (0) && bp == coin->current )
printf("i.%d n.%d match.%d blockhdrs.%s hdrsi.%d\n",i,n,match,bits256_str(str,zblocks[0].RO.hash2),firstbp!=0?firstbp->hdrsi:-1); printf("i.%d n.%d match.%d blockhdrs.%s hdrsi.%d\n",i,n,match,bits256_str(str,zblocks[0].RO.hash2),firstbp!=0?firstbp->hdrsi:-1);
/*if ( firstbp != 0 && match >= coin->chain->bundlesize-1 ) /*if ( firstbp != 0 && match >= coin->chain->bundlesize-1 )
{ {
@ -1479,7 +1479,7 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct supernet_info *myinfo,str
memset(zero.bytes,0,sizeof(zero)); memset(zero.bytes,0,sizeof(zero));
bp = 0, bundlei = -2; bp = 0, bundlei = -2;
iguana_bundlefind(coin,&bp,&bundlei,blockhashes[1]); iguana_bundlefind(coin,&bp,&bundlei,blockhashes[1]);
if ( 0 && strcmp("BTCD",coin->symbol) == 0 )//0 && num >= coin->chain->bundlesize ) if ( (0) && strcmp("BTCD",coin->symbol) == 0 )//0 && num >= coin->chain->bundlesize )
printf("blockhashes[%d] %d of %d %s bp.%d[%d]\n",num,bp==0?-1:bp->hdrsi,coin->bundlescount,bits256_str(str,blockhashes[1]),bp==0?-1:bp->bundleheight,bundlei); printf("blockhashes[%d] %d of %d %s bp.%d[%d]\n",num,bp==0?-1:bp->hdrsi,coin->bundlescount,bits256_str(str,blockhashes[1]),bp==0?-1:bp->bundleheight,bundlei);
if ( num < 2 ) if ( num < 2 )
return(req); return(req);
@ -1510,7 +1510,7 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct supernet_info *myinfo,str
iguana_blockQ("recvhash1",coin,0,-1,bp->nextbundlehash2,1); iguana_blockQ("recvhash1",coin,0,-1,bp->nextbundlehash2,1);
} }
//printf("call allhashes\n"); //printf("call allhashes\n");
if ( 0 && bp->hdrsi == coin->bundlescount-1 ) if ( (0) && bp->hdrsi == coin->bundlescount-1 )
iguana_autoextend(myinfo,coin,bp); iguana_autoextend(myinfo,coin,bp);
if ( iguana_allhashcmp(myinfo,coin,bp,blockhashes,num) > 0 ) if ( iguana_allhashcmp(myinfo,coin,bp,blockhashes,num) > 0 )
return(req); return(req);
@ -1567,11 +1567,11 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct supernet_info *myinfo,str
{ {
blockhashes[0] = bp->hashes[0]; blockhashes[0] = bp->hashes[0];
vcalc_sha256(0,allhash.bytes,blockhashes[0].bytes,coin->chain->bundlesize * sizeof(*blockhashes)); vcalc_sha256(0,allhash.bytes,blockhashes[0].bytes,coin->chain->bundlesize * sizeof(*blockhashes));
if ( 0 && i == starti ) if ( (0) && i == starti )
printf("vcalc.(%s) [%d].(%s)\n",bits256_str(str,allhash),bp->hdrsi,bits256_str(str2,bp->hashes[0])); printf("vcalc.(%s) [%d].(%s)\n",bits256_str(str,allhash),bp->hdrsi,bits256_str(str2,bp->hashes[0]));
if ( bits256_cmp(allhash,bp->allhash) == 0 ) if ( bits256_cmp(allhash,bp->allhash) == 0 )
{ {
if ( 0 && bp->speculative == 0 ) if ( (0) && bp->speculative == 0 )
printf("matched allhashes.[%d]\n",bp->hdrsi); printf("matched allhashes.[%d]\n",bp->hdrsi);
if ( bp->queued != 0 ) if ( bp->queued != 0 )
bp->queued = 0; bp->queued = 0;
@ -1655,11 +1655,11 @@ struct iguana_bundlereq *iguana_recvblock(struct supernet_info *myinfo,struct ig
coin->longestchain = prevblock->height+1; coin->longestchain = prevblock->height+1;
} else iguana_blockQ("prev",coin,0,-1,origblock->RO.prev_block,1); } else iguana_blockQ("prev",coin,0,-1,origblock->RO.prev_block,1);
} }
if ( 0 && block != 0 ) if ( (0) && block != 0 )
printf("%s received.(%s) [%d:%d]\n",coin->symbol,bits256_str(str,origblock->RO.hash2),block->hdrsi,block->bundlei); printf("%s received.(%s) [%d:%d]\n",coin->symbol,bits256_str(str,origblock->RO.hash2),block->hdrsi,block->bundlei);
if ( (bp= iguana_bundleset(myinfo,coin,&block,&bundlei,(struct iguana_block *)origblock)) != 0 && bp == coin->current && block != 0 && bp->speculative != 0 && bundlei >= 0 ) if ( (bp= iguana_bundleset(myinfo,coin,&block,&bundlei,(struct iguana_block *)origblock)) != 0 && bp == coin->current && block != 0 && bp->speculative != 0 && bundlei >= 0 )
{ {
if ( 0 && strcmp("BTCD",coin->symbol) == 0 ) if ( (0) && strcmp("BTCD",coin->symbol) == 0 )
printf("%s received.(%s) %s\n",coin->symbol,bits256_str(str,origblock->RO.hash2),addr->ipaddr); printf("%s received.(%s) %s\n",coin->symbol,bits256_str(str,origblock->RO.hash2),addr->ipaddr);
if ( bp->speculative != 0 && bp->numspec <= bundlei ) if ( bp->speculative != 0 && bp->numspec <= bundlei )
{ {
@ -1730,7 +1730,7 @@ struct iguana_bundlereq *iguana_recvblock(struct supernet_info *myinfo,struct ig
} }
} // else printf("RECV MAINCHAIN.%d\n",coin->blocks.hwmchain.height); } // else printf("RECV MAINCHAIN.%d\n",coin->blocks.hwmchain.height);
} }
if ( 0 && time(NULL) > bp->hdrtime+3 && bundlei == 1 && bp != 0 && bp->numhashes < bp->n && strcmp("BTC",coin->symbol) != 0 && bp->speculative == 0 && bp == coin->current ) if ( (0) && time(NULL) > bp->hdrtime+3 && bundlei == 1 && bp != 0 && bp->numhashes < bp->n && strcmp("BTC",coin->symbol) != 0 && bp->speculative == 0 && bp == coin->current )
{ {
printf("reissue hdrs request for [%d]\n",bp->hdrsi); printf("reissue hdrs request for [%d]\n",bp->hdrsi);
bp->hdrtime = (uint32_t)time(NULL); bp->hdrtime = (uint32_t)time(NULL);
@ -1916,7 +1916,7 @@ int32_t iguana_reqblocks(struct supernet_info *myinfo,struct iguana_info *coin)
if ( 1 && (rand() % 100000) == 0 )//|| bp->bundleheight > coin->longestchain-coin->chain->bundlesize ) if ( 1 && (rand() % 100000) == 0 )//|| bp->bundleheight > coin->longestchain-coin->chain->bundlesize )
printf("%s %s MAIN.%d t %.3f lag %.3f\n",coin->symbol,bits256_str(str,hash2),coin->blocks.hwmchain.height+1,threshold,lag); printf("%s %s MAIN.%d t %.3f lag %.3f\n",coin->symbol,bits256_str(str,hash2),coin->blocks.hwmchain.height+1,threshold,lag);
} }
if ( 0 && bp != 0 && bundlei < bp->n-1 && (bits256_nonz(bp->hashes[bundlei+1]) != 0 || (bp->speculative != 0 && bits256_nonz(bp->speculative[bundlei+1]) != 0)) ) if ( (0) && bp != 0 && bundlei < bp->n-1 && (bits256_nonz(bp->hashes[bundlei+1]) != 0 || (bp->speculative != 0 && bits256_nonz(bp->speculative[bundlei+1]) != 0)) )
{ {
int32_t j; int32_t j;
//memset(bp->hashes[bundlei].bytes,0,sizeof(bp->hashes[bundlei])); //memset(bp->hashes[bundlei].bytes,0,sizeof(bp->hashes[bundlei]));
@ -2014,7 +2014,7 @@ int32_t iguana_reqhdrs(struct iguana_info *coin)
if ( now > bp->issuetime+lag && now > bp->hdrtime+3 ) if ( now > bp->issuetime+lag && now > bp->hdrtime+3 )
{ {
bp->hdrtime = now; bp->hdrtime = now;
if ( 0 && bp == coin->current ) if ( (0) && bp == coin->current )
printf("LAG.%d hdrsi.%d numhashes.%d:%d needhdrs.%d qsize.%d zcount.%d\n",(uint32_t)(now-bp->hdrtime),i,bp->numhashes,bp->n,iguana_needhdrs(coin),queue_size(&coin->hdrsQ),coin->zcount); printf("LAG.%d hdrsi.%d numhashes.%d:%d needhdrs.%d qsize.%d zcount.%d\n",(uint32_t)(now-bp->hdrtime),i,bp->numhashes,bp->n,iguana_needhdrs(coin),queue_size(&coin->hdrsQ),coin->zcount);
if ( bp->issuetime == 0 ) if ( bp->issuetime == 0 )
coin->numpendings++; coin->numpendings++;
@ -2045,7 +2045,7 @@ int32_t iguana_reqhdrs(struct iguana_info *coin)
} }
} }
} }
if ( 0 && n > 0 ) if ( (0) && n > 0 )
printf("REQ HDRS pending.%d\n",n); printf("REQ HDRS pending.%d\n",n);
coin->zcount = 0; coin->zcount = 0;
} }
@ -2062,7 +2062,7 @@ int32_t iguana_blockQ(char *argstr,struct iguana_info *coin,struct iguana_bundle
//getchar(); //getchar();
return(-1); return(-1);
} }
if ( 0 && coin->enableCACHE != 0 && iguana_speculativesearch(coin,&block,hash2) != 0 && block != 0 && block->txvalid != 0 ) if ( (0) && coin->enableCACHE != 0 && iguana_speculativesearch(coin,&block,hash2) != 0 && block != 0 && block->txvalid != 0 )
{ {
//printf("found valid [%d:%d] in blockQ\n",block!=0?block->hdrsi:-1,block!=0?block->bundlei:-1); //printf("found valid [%d:%d] in blockQ\n",block!=0?block->hdrsi:-1,block!=0?block->bundlei:-1);
return(0); return(0);
@ -2159,7 +2159,7 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr)
{ {
uint8_t serialized[sizeof(struct iguana_msghdr) + sizeof(uint32_t)*32 + sizeof(bits256)]; uint8_t serialized[sizeof(struct iguana_msghdr) + sizeof(uint32_t)*32 + sizeof(bits256)];
struct iguana_block *block; struct iguana_blockreq *req=0; char *hashstr=0; bits256 hash2; struct iguana_block *block; struct iguana_blockreq *req=0; char *hashstr=0; bits256 hash2;
int32_t bundlei,priority,i,m,z,pend,limit,height=-1,datalen,flag = 0; struct stritem *hashitem; int32_t bundlei,priority,i,m=0,z,pend,limit,height=-1,datalen,flag = 0; struct stritem *hashitem;
uint32_t now; struct iguana_bundle *bp; struct iguana_peer *ptr; uint32_t now; struct iguana_bundle *bp; struct iguana_peer *ptr;
if ( addr->msgcounts.verack == 0 ) if ( addr->msgcounts.verack == 0 )
return(0); return(0);
@ -2193,7 +2193,7 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr)
} }
if ( bp == 0 || bp->speculative == 0 || bp == coin->current || bp->hdrsi == coin->bundlescount-1 || bp->numhashes < bp->n ) if ( bp == 0 || bp->speculative == 0 || bp == coin->current || bp->hdrsi == coin->bundlescount-1 || bp->numhashes < bp->n )
{ {
if ( 0 && bp == coin->current ) if ( (0) && bp == coin->current )
printf("%s request HDR.(%s) numhashes.%d [%d]\n",addr!=0?addr->ipaddr:"local",hashstr,bp!=0?bp->numhashes:0,bp!=0?bp->hdrsi:-1); printf("%s request HDR.(%s) numhashes.%d [%d]\n",addr!=0?addr->ipaddr:"local",hashstr,bp!=0?bp->numhashes:0,bp!=0?bp->hdrsi:-1);
iguana_send(coin,addr,serialized,datalen); iguana_send(coin,addr,serialized,datalen);
addr->pendhdrs++; addr->pendhdrs++;

2
iguana/iguana_rpc.c

@ -1144,7 +1144,7 @@ void iguana_rpcloop(void *args)
{ {
static char *jsonbuf; static char *jsonbuf;
uint16_t port; struct supernet_info *myinfo = args; char filetype[128],content_type[128]; uint16_t port; struct supernet_info *myinfo = args; char filetype[128],content_type[128];
int32_t recvlen,flag,bindsock,postflag,contentlen,sock,remains,numsent,jsonflag,hdrsize,len; int32_t recvlen,flag,bindsock,postflag=0,contentlen,sock,remains,numsent,jsonflag=0,hdrsize,len;
socklen_t clilen; char helpname[512],remoteaddr[64],*buf,*retstr,*space;//,*retbuf; ,n,i,m socklen_t clilen; char helpname[512],remoteaddr[64],*buf,*retstr,*space;//,*retbuf; ,n,i,m
struct sockaddr_in cli_addr; uint32_t ipbits,i,size = IGUANA_WIDTH*IGUANA_HEIGHT*16 + 512; struct sockaddr_in cli_addr; uint32_t ipbits,i,size = IGUANA_WIDTH*IGUANA_HEIGHT*16 + 512;
if ( (port= myinfo->argport) == 0 ) if ( (port= myinfo->argport) == 0 )

4
iguana/iguana_scripts.c

@ -333,9 +333,9 @@ int32_t _iguana_calcrmd160(struct iguana_info *coin,struct vin_info *vp)
if ( (plen= vp->spendscript[2]+5) != vp->spendlen ) if ( (plen= vp->spendscript[2]+5) != vp->spendlen )
{ {
return(IGUANA_SCRIPT_STRANGE); return(IGUANA_SCRIPT_STRANGE);
while ( plen < vp->spendlen ) /*while ( plen < vp->spendlen )
if ( vp->spendscript[plen++] != 0x61 ) // nop if ( vp->spendscript[plen++] != 0x61 ) // nop
return(IGUANA_SCRIPT_STRANGE); return(IGUANA_SCRIPT_STRANGE);*/
} }
return(IGUANA_SCRIPT_76A988AC); return(IGUANA_SCRIPT_76A988AC);
} }

6
iguana/iguana_secp.c

@ -655,9 +655,9 @@ int32_t iguana_schnorr_test(void *ctx)
{ {
sigs[i] = sig64[i]; sigs[i] = sig64[i];
continue; continue;
for (j=0; j<64; j++) //for (j=0; j<64; j++)
printf("%02x",sig64[i][j]); // printf("%02x",sig64[i][j]);
printf(" sig[%d]\n",i); //printf(" sig[%d]\n",i);
} }
for (i=0; i<N; i++) for (i=0; i<N; i++)
{ {

26
iguana/iguana_sign.c

@ -86,7 +86,7 @@ int32_t iguana_vinparse(struct iguana_info *coin,int32_t rwflag,uint8_t *seriali
serialized[len++] = ((p2shlen >> 8) & 0xff); serialized[len++] = ((p2shlen >> 8) & 0xff);
} else return(-1); } else return(-1);
memcpy(&serialized[len],msg->redeemscript,p2shlen), len += p2shlen; memcpy(&serialized[len],msg->redeemscript,p2shlen), len += p2shlen;
if ( 0 ) if ( (0) )
{ {
int32_t j; int32_t j;
for (j=0; j<p2shlen; j++) for (j=0; j<p2shlen; j++)
@ -97,7 +97,7 @@ int32_t iguana_vinparse(struct iguana_info *coin,int32_t rwflag,uint8_t *seriali
} }
//printf("sequence starts.%d %08x\n",len,*(int32_t *)&serialized[len]); //printf("sequence starts.%d %08x\n",len,*(int32_t *)&serialized[len]);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(msg->sequence),&msg->sequence); len += iguana_rwnum(rwflag,&serialized[len],sizeof(msg->sequence),&msg->sequence);
if ( 0 ) if ( (0) )
{ {
int32_t i; char str[65]; int32_t i; char str[65];
for (i=0; i<len; i++) for (i=0; i<len; i++)
@ -122,7 +122,7 @@ int32_t iguana_voutparse(int32_t rwflag,uint8_t *serialized,struct iguana_msgvou
else if ( msg->pk_scriptlen > 0 ) else if ( msg->pk_scriptlen > 0 )
{ {
memcpy(&serialized[len],msg->pk_script,msg->pk_scriptlen); memcpy(&serialized[len],msg->pk_script,msg->pk_scriptlen);
if ( 0 ) if ( (0) )
{ {
int32_t i; int32_t i;
for (i=0; i<msg->pk_scriptlen; i++) for (i=0; i<msg->pk_scriptlen; i++)
@ -294,7 +294,7 @@ int32_t iguana_parsevinobj(struct supernet_info *myinfo,struct iguana_info *coin
// continue; // continue;
if ( serialized[len + m + siglen - 1] == SIGHASH_ALL ) if ( serialized[len + m + siglen - 1] == SIGHASH_ALL )
memcpy(V->signers[i++].sig,&serialized[len + m],siglen); memcpy(V->signers[i++].sig,&serialized[len + m],siglen);
if ( 0 ) if ( (0) )
{ {
int32_t j; int32_t j;
for (j=0; j<siglen; j++) for (j=0; j<siglen; j++)
@ -944,7 +944,7 @@ int32_t iguana_msgtx_Vset(struct iguana_info *coin,uint8_t *serialized,int32_t m
} }
len += scriptlen; len += scriptlen;
} }
if ( 0 ) if ( (0) )
{ {
int32_t i; for (i=0; i<len; i++) int32_t i; for (i=0; i<len; i++)
printf("%02x",script[i]); printf("%02x",script[i]);
@ -1115,9 +1115,9 @@ void iguana_ensure_privkey(struct supernet_info *myinfo,struct iguana_info *coin
waddr->privkey = privkey; waddr->privkey = privkey;
if ( bitcoin_priv2wif(waddr->wifstr,waddr->privkey,coin->chain->wiftype) > 0 ) if ( bitcoin_priv2wif(waddr->wifstr,waddr->privkey,coin->chain->wiftype) > 0 )
{ {
if ( 0 && waddr->wiftype != coin->chain->wiftype ) if ( (0) && waddr->wiftype != coin->chain->wiftype )
printf("ensurepriv warning: mismatched wiftype %02x != %02x\n",waddr->wiftype,coin->chain->wiftype); printf("ensurepriv warning: mismatched wiftype %02x != %02x\n",waddr->wiftype,coin->chain->wiftype);
if ( 0 && waddr->addrtype != coin->chain->pubtype ) if ( (0) && waddr->addrtype != coin->chain->pubtype )
printf("ensurepriv warning: mismatched addrtype %02x != %02x\n",waddr->addrtype,coin->chain->pubtype); printf("ensurepriv warning: mismatched addrtype %02x != %02x\n",waddr->addrtype,coin->chain->pubtype);
} }
} }
@ -1220,7 +1220,7 @@ cJSON *iguana_pubkeysjson(uint8_t *pubkeyptrs[],int32_t numpubkeys)
cJSON *bitcoin_txinput(struct iguana_info *coin,cJSON *txobj,bits256 txid,int32_t vout,uint32_t sequenceid,uint8_t *spendscript,int32_t spendlen,uint8_t *redeemscript,int32_t p2shlen,uint8_t *pubkeys[],int32_t numpubkeys,uint8_t *sig,int32_t siglen) cJSON *bitcoin_txinput(struct iguana_info *coin,cJSON *txobj,bits256 txid,int32_t vout,uint32_t sequenceid,uint8_t *spendscript,int32_t spendlen,uint8_t *redeemscript,int32_t p2shlen,uint8_t *pubkeys[],int32_t numpubkeys,uint8_t *sig,int32_t siglen)
{ {
cJSON *item,*vins; char p2shscriptstr[IGUANA_MAXSCRIPTSIZE*2+1]; uint8_t *script,len; cJSON *item,*vins; char p2shscriptstr[IGUANA_MAXSCRIPTSIZE*2+1]; uint8_t *script,len=0;
vins = jduplicate(jobj(txobj,"vin")); vins = jduplicate(jobj(txobj,"vin"));
jdelete(txobj,"vin"); jdelete(txobj,"vin");
item = cJSON_CreateObject(); item = cJSON_CreateObject();
@ -1284,7 +1284,7 @@ cJSON *bitcoin_txoutput(cJSON *txobj,uint8_t *paymentscript,int32_t len,uint64_t
int32_t iguana_interpreter(struct iguana_info *coin,cJSON *logarray,int64_t nLockTime,struct vin_info *V,int32_t numvins) int32_t iguana_interpreter(struct iguana_info *coin,cJSON *logarray,int64_t nLockTime,struct vin_info *V,int32_t numvins)
{ {
uint8_t script[IGUANA_MAXSCRIPTSIZE],*activescript,savescript[IGUANA_MAXSCRIPTSIZE]; char str[IGUANA_MAXSCRIPTSIZE*2+1]; int32_t vini,scriptlen,activescriptlen,savelen,errs = 0; cJSON *spendscript,*item; uint8_t script[IGUANA_MAXSCRIPTSIZE],*activescript,savescript[IGUANA_MAXSCRIPTSIZE]; char str[IGUANA_MAXSCRIPTSIZE*2+1]; int32_t vini,scriptlen,activescriptlen,savelen,errs = 0; cJSON *spendscript,*item=0;
for (vini=0; vini<numvins; vini++) for (vini=0; vini<numvins; vini++)
{ {
savelen = V[vini].spendlen; savelen = V[vini].spendlen;
@ -1319,7 +1319,7 @@ int32_t iguana_interpreter(struct iguana_info *coin,cJSON *logarray,int64_t nLoc
} }
init_hexbytes_noT(str,activescript,activescriptlen); init_hexbytes_noT(str,activescript,activescriptlen);
//printf("activescript.(%s)\n",str); //printf("activescript.(%s)\n",str);
if ( logarray != 0 ) if ( logarray != 0 && item != 0 )
jaddstr(item,"original",str); jaddstr(item,"original",str);
init_hexbytes_noT(str,script,scriptlen); init_hexbytes_noT(str,script,scriptlen);
//printf("reconstructed.(%s)\n",str); //printf("reconstructed.(%s)\n",str);
@ -1410,6 +1410,7 @@ int32_t iguana_signrawtransaction(struct supernet_info *myinfo,struct iguana_inf
{ {
uint8_t *serialized,*serialized2,*serialized3,*serialized4,*extraspace,pubkeys[64][33]; int32_t finalized,i,len,n,z,plen,maxsize,complete = 0,extralen = 65536; char *checkstr,*privkeystr,*signedtx = 0; bits256 privkeys[64],privkey,txid; cJSON *item; cJSON *txobj = 0; uint8_t *serialized,*serialized2,*serialized3,*serialized4,*extraspace,pubkeys[64][33]; int32_t finalized,i,len,n,z,plen,maxsize,complete = 0,extralen = 65536; char *checkstr,*privkeystr,*signedtx = 0; bits256 privkeys[64],privkey,txid; cJSON *item; cJSON *txobj = 0;
maxsize = 1000000; maxsize = 1000000;
memset(privkey.bytes,0,sizeof(privkey));
if ( rawtx != 0 && rawtx[0] != 0 && (len= (int32_t)strlen(rawtx)>>1) < maxsize ) if ( rawtx != 0 && rawtx[0] != 0 && (len= (int32_t)strlen(rawtx)>>1) < maxsize )
{ {
serialized = malloc(maxsize); serialized = malloc(maxsize);
@ -1421,13 +1422,13 @@ int32_t iguana_signrawtransaction(struct supernet_info *myinfo,struct iguana_inf
decode_hex(serialized,len,rawtx); decode_hex(serialized,len,rawtx);
if ( (txobj= bitcoin_hex2json(coin,height,&txid,msgtx,rawtx,extraspace,extralen,serialized4,vins,V->suppress_pubkeys)) != 0 ) if ( (txobj= bitcoin_hex2json(coin,height,&txid,msgtx,rawtx,extraspace,extralen,serialized4,vins,V->suppress_pubkeys)) != 0 )
{ {
if ( 0 && vins != 0 ) if ( (0) && vins != 0 )
printf("txobj.(%s)\n",jprint(txobj,0)); printf("txobj.(%s)\n",jprint(txobj,0));
if ( jobj(txobj,"error") != 0 ) if ( jobj(txobj,"error") != 0 )
{ {
printf("txobj.(%s)\n",jprint(txobj,0)); printf("txobj.(%s)\n",jprint(txobj,0));
} }
if ( 0 && (checkstr= bitcoin_json2hex(myinfo,coin,&txid,txobj,V)) != 0 ) // no guarantee of identical regen if ( (0) && (checkstr= bitcoin_json2hex(myinfo,coin,&txid,txobj,V)) != 0 ) // no guarantee of identical regen
{ {
if ( strcmp(rawtx,checkstr) != 0 ) if ( strcmp(rawtx,checkstr) != 0 )
{ {
@ -1467,6 +1468,7 @@ int32_t iguana_signrawtransaction(struct supernet_info *myinfo,struct iguana_inf
if ( msgtx->vins[i].p2shlen != 0 ) if ( msgtx->vins[i].p2shlen != 0 )
{ {
char coinaddr[64]; uint32_t userdatalen,sigsize,pubkeysize; uint8_t *userdata; int32_t j,k,hashtype,type,flag; struct vin_info mvin,mainvin; bits256 zero; char coinaddr[64]; uint32_t userdatalen,sigsize,pubkeysize; uint8_t *userdata; int32_t j,k,hashtype,type,flag; struct vin_info mvin,mainvin; bits256 zero;
memset(zero.bytes,0,sizeof(zero));
coinaddr[0] = 0; coinaddr[0] = 0;
sigsize = 0; sigsize = 0;
flag = (msgtx->vins[i].vinscript[0] == 0); flag = (msgtx->vins[i].vinscript[0] == 0);

26
iguana/iguana_spendvectors.c

@ -238,8 +238,8 @@ struct iguana_bundle *iguana_fastexternalspent(struct supernet_info *myinfo,stru
int32_t iguana_spendvectors(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp,struct iguana_ramchain *ramchain,int32_t starti,int32_t numblocks,int32_t convertflag,int32_t iterate) int32_t iguana_spendvectors(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp,struct iguana_ramchain *ramchain,int32_t starti,int32_t numblocks,int32_t convertflag,int32_t iterate)
{ {
static uint64_t total,emitted; static uint64_t total,emitted;
int32_t iter,spendind,n=0,txidind,errs=0,emit=0,i,j,k; double startmillis; bits256 prevhash; int32_t iter,spendind=0,n=0,txidind,errs=0,emit=0,i,j,k; double startmillis; bits256 prevhash;
uint32_t spent_unspentind,spent_pkind,now,starttime; struct iguana_ramchaindata *rdata; uint32_t spent_unspentind=0,spent_pkind,now,starttime; struct iguana_ramchaindata *rdata;
struct iguana_bundle *spentbp; struct iguana_blockRO *B; struct iguana_spendvector *ptr; struct iguana_bundle *spentbp; struct iguana_blockRO *B; struct iguana_spendvector *ptr;
struct iguana_unspent *u,*spentU; struct iguana_txid *T; char str[65]; struct iguana_unspent *u,*spentU; struct iguana_txid *T; char str[65];
struct iguana_spend *S,*s; //void *fastfind = 0; struct iguana_spend *S,*s; //void *fastfind = 0;
@ -270,7 +270,7 @@ int32_t iguana_spendvectors(struct supernet_info *myinfo,struct iguana_info *coi
ptr = mycalloc('x',sizeof(*ptr),n); ptr = mycalloc('x',sizeof(*ptr),n);
total += n; total += n;
startmillis = OS_milliseconds(); startmillis = OS_milliseconds();
if ( 0 && strcmp(coin->symbol,"BTC") == 0 ) if ( (0) && strcmp(coin->symbol,"BTC") == 0 )
printf("start UTXOGEN.%d max.%d ptr.%p millis.%.3f\n",bp->bundleheight,n,ptr,startmillis); printf("start UTXOGEN.%d max.%d ptr.%p millis.%.3f\n",bp->bundleheight,n,ptr,startmillis);
starttime = (uint32_t)time(NULL); starttime = (uint32_t)time(NULL);
iguana_ramchain_prefetch(coin,&bp->ramchain,3); iguana_ramchain_prefetch(coin,&bp->ramchain,3);
@ -383,7 +383,7 @@ int32_t iguana_spendvectors(struct supernet_info *myinfo,struct iguana_info *coi
ptr[emit].unspentind = spent_unspentind; ptr[emit].unspentind = spent_unspentind;
ptr[emit].fromheight = bp->bundleheight + i; ptr[emit].fromheight = bp->bundleheight + i;
ptr[emit].tmpflag = 1; ptr[emit].tmpflag = 1;
if ( 0 && bp == coin->current ) if ( (0) && bp == coin->current )
printf("fromht.%d spends [%d] TMPVECTOR u%d s%u\n",ptr[emit].fromheight,ptr[emit].hdrsi,ptr[emit].unspentind,spendind); printf("fromht.%d spends [%d] TMPVECTOR u%d s%u\n",ptr[emit].fromheight,ptr[emit].hdrsi,ptr[emit].unspentind,spendind);
emit++; emit++;
} }
@ -436,7 +436,7 @@ int32_t iguana_spendvectors(struct supernet_info *myinfo,struct iguana_info *coi
//printf("ALLOC tmpspends.[%d]\n",bp->hdrsi); //printf("ALLOC tmpspends.[%d]\n",bp->hdrsi);
ptr = 0; ptr = 0;
} }
if ( 0 && bp == coin->current ) if ( (0) && bp == coin->current )
printf("spendvectors.[%d]: tmpspends.%p[%d] after += emit.%d X.%p\n",bp->hdrsi,bp->tmpspends,bp->numtmpspends,emit,bp->ramchain.Xspendinds); printf("spendvectors.[%d]: tmpspends.%p[%d] after += emit.%d X.%p\n",bp->hdrsi,bp->tmpspends,bp->numtmpspends,emit,bp->ramchain.Xspendinds);
} else errs = -iguana_spendvectorsave(coin,bp,ramchain,ptr!=0?ptr:bp->tmpspends,emit,n); } else errs = -iguana_spendvectorsave(coin,bp,ramchain,ptr!=0?ptr:bp->tmpspends,emit,n);
} }
@ -486,12 +486,12 @@ int32_t iguana_balancegen(struct iguana_info *coin,int32_t incremental,struct ig
spendind = B[starti].firstvin; spendind = B[starti].firstvin;
unspentind = B[starti].firstvout; unspentind = B[starti].firstvout;
emit = startemit; emit = startemit;
if ( 0 && (coin->RTheight == 0 || bp->bundleheight+bp->n < coin->RTheight) ) if ( (0) && (coin->RTheight == 0 || bp->bundleheight+bp->n < coin->RTheight) )
fprintf(stderr,"BALANCEGEN.[%d] %p[%d] starti.%d s%d <-> endi.%d s%d startemit.%d\n",bp->hdrsi,Xspendinds,numXspends,starti,spendind,endi,B[endi].firstvin+B[endi].numvins,startemit); fprintf(stderr,"BALANCEGEN.[%d] %p[%d] starti.%d s%d <-> endi.%d s%d startemit.%d\n",bp->hdrsi,Xspendinds,numXspends,starti,spendind,endi,B[endi].firstvin+B[endi].numvins,startemit);
for (i=starti; i<=endi; i++) for (i=starti; i<=endi; i++)
{ {
now = (uint32_t)time(NULL); now = (uint32_t)time(NULL);
if ( 0 && bp == coin->current ) if ( (0) && bp == coin->current )
printf("hdrs.[%d] B[%d] 1st txidind.%d txn_count.%d firstvin.%d firstvout.%d\n",bp->hdrsi,i,B[i].firsttxidind,B[i].txn_count,B[i].firstvin,B[i].firstvout); printf("hdrs.[%d] B[%d] 1st txidind.%d txn_count.%d firstvin.%d firstvout.%d\n",bp->hdrsi,i,B[i].firsttxidind,B[i].txn_count,B[i].firstvin,B[i].firstvout);
if ( txidind != B[i].firsttxidind || spendind != B[i].firstvin || unspentind != B[i].firstvout ) if ( txidind != B[i].firsttxidind || spendind != B[i].firstvin || unspentind != B[i].firstvout )
{ {
@ -506,7 +506,7 @@ int32_t iguana_balancegen(struct iguana_info *coin,int32_t incremental,struct ig
printf("balancegen: txidind %u != %u T[txidind].firsttxidind || spendind %u != %u T[txidind].firstvin errs.%d (%d %d)\n",txidind,(uint32_t)T[txidind].txidind,spendind,(uint32_t)T[txidind].firstvin,errs,unspentind,B[i].firstvout); printf("balancegen: txidind %u != %u T[txidind].firsttxidind || spendind %u != %u T[txidind].firstvin errs.%d (%d %d)\n",txidind,(uint32_t)T[txidind].txidind,spendind,(uint32_t)T[txidind].firstvin,errs,unspentind,B[i].firstvout);
return(-1); return(-1);
} }
if ( 0 && bp == coin->current ) if ( (0) && bp == coin->current )
printf("starti.%d txidind.%d txi.%d numvins.%d spendind.%d\n",i,txidind,j,T[txidind].numvins,spendind); printf("starti.%d txidind.%d txi.%d numvins.%d spendind.%d\n",i,txidind,j,T[txidind].numvins,spendind);
/*if ( bp == coin->current )//ramchain == &coin->RTramchain ) /*if ( bp == coin->current )//ramchain == &coin->RTramchain )
{ {
@ -541,7 +541,7 @@ int32_t iguana_balancegen(struct iguana_info *coin,int32_t incremental,struct ig
spent_hdrsi = spend->hdrsi; spent_hdrsi = spend->hdrsi;
h = spend->fromheight; h = spend->fromheight;
} }
if ( 0 && bp == coin->current ) if ( (0) && bp == coin->current )
printf("external prevout.%d (emit.%d numX.%d) %p u%d p%d errs.%d spent_hdrsi.%d s%u\n",s->prevout,emit,numXspends,Xspendinds,spent_unspentind,spent_pkind,errs,spent_hdrsi,spendind); printf("external prevout.%d (emit.%d numX.%d) %p u%d p%d errs.%d spent_hdrsi.%d s%u\n",s->prevout,emit,numXspends,Xspendinds,spent_unspentind,spent_pkind,errs,spent_hdrsi,spendind);
} }
else if ( s->prevout >= 0 ) else if ( s->prevout >= 0 )
@ -567,7 +567,7 @@ int32_t iguana_balancegen(struct iguana_info *coin,int32_t incremental,struct ig
spentbp = 0; spentbp = 0;
if ( (spentbp= coin->bundles[spent_hdrsi]) != 0 && spent_unspentind > 0 && spent_pkind > 0 ) if ( (spentbp= coin->bundles[spent_hdrsi]) != 0 && spent_unspentind > 0 && spent_pkind > 0 )
{ {
if ( 0 && bp == coin->current ) if ( (0) && bp == coin->current )
printf("[%d] spendind.%u -> [%d] u%d\n",bp->hdrsi,spendind,spent_hdrsi,spent_unspentind); printf("[%d] spendind.%u -> [%d] u%d\n",bp->hdrsi,spendind,spent_hdrsi,spent_unspentind);
if ( iguana_volatileupdate(coin,incremental,&spentbp->ramchain,spent_hdrsi,spent_unspentind,spent_pkind,spent_value,spendind,h) < 0 ) //(spentbp == coin->current) ? &coin->RTramchain : if ( iguana_volatileupdate(coin,incremental,&spentbp->ramchain,spent_hdrsi,spent_unspentind,spent_pkind,spent_value,spendind,h) < 0 ) //(spentbp == coin->current) ? &coin->RTramchain :
errs++; errs++;
@ -967,7 +967,7 @@ int32_t iguana_balanceflush(struct supernet_info *myinfo,struct iguana_info *coi
} }
char str[65]; printf("BALANCES WRITTEN for %d orig.%d bundles %s\n",coin->balanceswritten,coin->origbalanceswritten,bits256_str(str,coin->balancehash)); char str[65]; printf("BALANCES WRITTEN for %d orig.%d bundles %s\n",coin->balanceswritten,coin->origbalanceswritten,bits256_str(str,coin->balancehash));
//iguana_utxoaddr_gen(myinfo,coin,(coin->balanceswritten - 1) * coin->chain->bundlesize); //iguana_utxoaddr_gen(myinfo,coin,(coin->balanceswritten - 1) * coin->chain->bundlesize);
if ( 0 && coin->balanceswritten > coin->origbalanceswritten+10 ) // strcmp(coin->symbol,"BTC") == 0 && if ( (0) && coin->balanceswritten > coin->origbalanceswritten+10 ) // strcmp(coin->symbol,"BTC") == 0 &&
{ {
coin->active = 0; coin->active = 0;
coin->started = 0; coin->started = 0;
@ -1119,7 +1119,7 @@ int32_t iguana_convert(struct iguana_info *coin,int32_t helperid,struct iguana_b
total[helperid % max] += converted; total[helperid % max] += converted;
for (i=sum=0; i<max; i++) for (i=sum=0; i<max; i++)
sum += total[i]; sum += total[i];
if ( 0 && converted != 0 && bp != coin->current ) if ( (0) && converted != 0 && bp != coin->current )
printf("[%4d] millis %7.3f converted.%-7d balance calc.%-4d of %4d | total.%llu of %llu depth.%d\n",bp->hdrsi,OS_milliseconds()-startmillis,converted,m,n,(long long)sum,(long long)total_tmpspends,(int32_t)depth); printf("[%4d] millis %7.3f converted.%-7d balance calc.%-4d of %4d | total.%llu of %llu depth.%d\n",bp->hdrsi,OS_milliseconds()-startmillis,converted,m,n,(long long)sum,(long long)total_tmpspends,(int32_t)depth);
} }
depth--; depth--;
@ -1134,7 +1134,7 @@ int32_t iguana_bundlevalidate(struct supernet_info *myinfo,struct iguana_info *c
if ( coin->chain->zcash != 0 ) if ( coin->chain->zcash != 0 )
{ {
static uint32_t counter; static uint32_t counter;
if ( 0 && counter++ < 3 ) if ( (0) && counter++ < 3 )
printf("need to process joinsplits before can validate.%s\n",coin->symbol); printf("need to process joinsplits before can validate.%s\n",coin->symbol);
bp->validated = (uint32_t)time(NULL); bp->validated = (uint32_t)time(NULL);
forceflag = 1; forceflag = 1;

4
iguana/iguana_tx.c

@ -44,7 +44,7 @@ int32_t iguana_scriptdata(struct iguana_info *coin, uint8_t *scriptspace, long f
memcpy(scriptspace,(void *)(fileptr[0] + (uint32_t)scriptpos),scriptlen); memcpy(scriptspace,(void *)(fileptr[0] + (uint32_t)scriptpos),scriptlen);
return(retval); return(retval);
} }
else if ( 0 ) else if ( (0) )
{ {
printf("munmap (%s)\n",fname); printf("munmap (%s)\n",fname);
munmap((void *)fileptr[0],fileptr[1]); munmap((void *)fileptr[0],fileptr[1]);
@ -350,7 +350,7 @@ int32_t iguana_peerblockrequest(struct supernet_info *myinfo,struct iguana_info
{ {
addr->lastsent = block->height; addr->lastsent = block->height;
printf("Sendlen.%d block.%d %s to %s\n",total,block->height,bits256_str(str,block->RO.hash2),addr->ipaddr); printf("Sendlen.%d block.%d %s to %s\n",total,block->height,bits256_str(str,block->RO.hash2),addr->ipaddr);
if ( 0 ) if ( (0) )
{ {
struct iguana_txblock txdata; int32_t checklen; static struct OS_memspace RAWMEM; struct iguana_txblock txdata; int32_t checklen; static struct OS_memspace RAWMEM;
if ( RAWMEM.ptr == 0 ) if ( RAWMEM.ptr == 0 )

22
iguana/iguana_txidfind.c

@ -18,7 +18,7 @@
int32_t iguana_alloctxbits(struct iguana_info *coin,struct iguana_ramchain *ramchain) int32_t iguana_alloctxbits(struct iguana_info *coin,struct iguana_ramchain *ramchain)
{ {
static int64_t total; struct iguana_ramchaindata *rdata; static int64_t total; struct iguana_ramchaindata *rdata;
if ( 0 && ramchain->txbits == 0 && (rdata= ramchain->H.data) != 0 ) if ( (0) && ramchain->txbits == 0 && (rdata= ramchain->H.data) != 0 )
{ {
int32_t tlen; uint8_t *TXbits; int32_t tlen; uint8_t *TXbits;
TXbits = RAMCHAIN_PTR(rdata,TXoffset); TXbits = RAMCHAIN_PTR(rdata,TXoffset);
@ -65,7 +65,7 @@ uint32_t iguana_sparseadd(uint8_t *bits,uint32_t ind,int32_t width,uint32_t tabl
printf("iguana_sparseadd tablesize zero illegal\n"); printf("iguana_sparseadd tablesize zero illegal\n");
return(0); return(0);
} }
if ( 0 && setind == 0 ) if ( (0) && setind == 0 )
{ {
char str[65]; char str[65];
for (i=n=0; i<tablesize; i++) for (i=n=0; i<tablesize; i++)
@ -88,7 +88,7 @@ uint32_t iguana_sparseadd(uint8_t *bits,uint32_t ind,int32_t width,uint32_t tabl
//if ( setind == 0 ) //if ( setind == 0 )
// ramchain->sparsesearches++; // ramchain->sparsesearches++;
//else ramchain->sparseadds++; //else ramchain->sparseadds++;
if ( 0 && (rdata= ramchain->H.data) != 0 && (ramchain->sparsesearches % 1000000) == 0 ) if ( (0) && (rdata= ramchain->H.data) != 0 && (ramchain->sparsesearches % 1000000) == 0 )
printf("[%3d] %7d.[%-2d %8d] %5.3f adds.(%-10ld %10ld) search.(hits.%-10ld %10ld) %5.2f%% max.%ld\n",ramchain->height/rdata->numblocks,ramchain->height,width,tablesize,(double)(ramchain->sparseadditers + ramchain->sparsesearchiters)/(1+ramchain->sparsesearches+ramchain->sparseadds),ramchain->sparseadds,ramchain->sparseadditers,ramchain->sparsehits,ramchain->sparsesearches,100.*(double)ramchain->sparsehits/(1+ramchain->sparsesearches),ramchain->sparsemax+1); printf("[%3d] %7d.[%-2d %8d] %5.3f adds.(%-10ld %10ld) search.(hits.%-10ld %10ld) %5.2f%% max.%ld\n",ramchain->height/rdata->numblocks,ramchain->height,width,tablesize,(double)(ramchain->sparseadditers + ramchain->sparsesearchiters)/(1+ramchain->sparsesearches+ramchain->sparseadds),ramchain->sparseadds,ramchain->sparseadditers,ramchain->sparsehits,ramchain->sparsesearches,100.*(double)ramchain->sparsehits/(1+ramchain->sparsesearches),ramchain->sparsemax+1);
if ( width == 32 ) if ( width == 32 )
{ {
@ -123,7 +123,7 @@ uint32_t iguana_sparseadd(uint8_t *bits,uint32_t ind,int32_t width,uint32_t tabl
else else
{ {
bitoffset = (ind * width); bitoffset = (ind * width);
if ( 0 && setind == 0 ) if ( (0) && setind == 0 )
printf("tablesize.%d width.%d bitoffset.%d\n",tablesize,width,(int32_t)bitoffset); printf("tablesize.%d width.%d bitoffset.%d\n",tablesize,width,(int32_t)bitoffset);
for (i=0; i<tablesize; i++,ind++,bitoffset+=width) for (i=0; i<tablesize; i++,ind++,bitoffset+=width)
{ {
@ -141,7 +141,7 @@ uint32_t iguana_sparseadd(uint8_t *bits,uint32_t ind,int32_t width,uint32_t tabl
{ {
ptr = &bits[bitoffset >> 3]; ptr = &bits[bitoffset >> 3];
modval = (bitoffset & 7); modval = (bitoffset & 7);
if ( 0 && setind == 0 ) if ( (0) && setind == 0 )
printf("tablesize.%d width.%d bitoffset.%d modval.%d i.%d\n",tablesize,width,(int32_t)bitoffset,modval,i); printf("tablesize.%d width.%d bitoffset.%d modval.%d i.%d\n",tablesize,width,(int32_t)bitoffset,modval,i);
for (x=j=0; j<width; j++,modval++) for (x=j=0; j<width; j++,modval++)
{ {
@ -152,7 +152,7 @@ uint32_t iguana_sparseadd(uint8_t *bits,uint32_t ind,int32_t width,uint32_t tabl
} }
} }
else x = bits[bitoffset >> 3]; else x = bits[bitoffset >> 3];
if ( 0 && setind == 0 ) if ( (0) && setind == 0 )
printf("x.%d\n",x); printf("x.%d\n",x);
if ( x == 0 ) if ( x == 0 )
{ {
@ -179,7 +179,7 @@ uint32_t iguana_sparseadd(uint8_t *bits,uint32_t ind,int32_t width,uint32_t tabl
} }
} }
else bits[bitoffset >> 3] = setind; else bits[bitoffset >> 3] = setind;
if ( 0 ) if ( (0) )
{ {
for (x=j=0; j<width; j++) for (x=j=0; j<width; j++)
{ {
@ -317,7 +317,7 @@ struct iguana_txid *iguana_txidfind(struct iguana_info *coin,int32_t *heightp,st
//printf("found txidind.%d\n",txidind); //printf("found txidind.%d\n",txidind);
if ( bits256_cmp(txid,T[txidind].txid) == 0 ) if ( bits256_cmp(txid,T[txidind].txid) == 0 )
{ {
if ( 0 ) if ( (0) )
{ {
int32_t j; struct iguana_block *block; int32_t j; struct iguana_block *block;
for (j=0; j<bp->n; j++) for (j=0; j<bp->n; j++)
@ -395,7 +395,7 @@ int32_t iguana_txidfastfind(struct iguana_info *coin,int32_t *heightp,bits256 tx
} }
return(firstvout); return(firstvout);
} }
else if ( 0 ) else if ( (0) )
{ {
int32_t k; int32_t k;
for (k=-16; k<0; k++) for (k=-16; k<0; k++)
@ -497,7 +497,7 @@ uint32_t iguana_fastfindinit(struct iguana_info *coin)
{ {
fprintf(stderr,"."); fprintf(stderr,".");
sorted = coin->fast[i]; sorted = coin->fast[i];
if ( 0 ) if ( (0) )
{ {
coin->fast[i] = calloc(1,coin->fastsizes[i]); coin->fast[i] = calloc(1,coin->fastsizes[i]);
memcpy(coin->fast[i],sorted,coin->fastsizes[i]); memcpy(coin->fast[i],sorted,coin->fastsizes[i]);
@ -509,7 +509,7 @@ uint32_t iguana_fastfindinit(struct iguana_info *coin)
if ( (num+1)*16 + tablesize*sizeof(*hashtable) == coin->fastsizes[i] ) if ( (num+1)*16 + tablesize*sizeof(*hashtable) == coin->fastsizes[i] )
{ {
hashtable = (int32_t *)((long)sorted + (1 + num)*16); hashtable = (int32_t *)((long)sorted + (1 + num)*16);
if ( 0 ) if ( (0) )
{ {
coin->fasttables[i] = calloc(tablesize,sizeof(*hashtable)); coin->fasttables[i] = calloc(tablesize,sizeof(*hashtable));
memcpy(coin->fasttables[i],hashtable,tablesize * sizeof(*hashtable)); memcpy(coin->fasttables[i],hashtable,tablesize * sizeof(*hashtable));

28
iguana/iguana_unspents.c

@ -361,7 +361,7 @@ struct iguana_pkhash *iguana_pkhashfind(struct iguana_info *coin,struct iguana_r
{ {
if ( (bp= coin->bundles[i]) != 0 ) if ( (bp= coin->bundles[i]) != 0 )
{ {
if ( 0 && coin->RTramchain_busy != 0 ) if ( (0) && coin->RTramchain_busy != 0 )
{ {
printf("iguana_pkhashfind: unexpected access when RTramchain_busy\n"); printf("iguana_pkhashfind: unexpected access when RTramchain_busy\n");
return(0); return(0);
@ -511,10 +511,10 @@ int32_t iguana_RTscanunspents(struct supernet_info *myinfo,struct iguana_info *c
int64_t iguana_RTpkhashbalance(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *array,uint64_t *spentp,struct iguana_outpoint *unspents,int32_t *nump,struct iguana_ramchain *ramchain,struct iguana_pkhash *p,struct iguana_outpoint lastpt,uint8_t rmd160[20],char *coinaddr,uint8_t *pubkey33,int32_t lastheight,int32_t minconf,int32_t maxconf,char *remoteaddr,int32_t includespent) int64_t iguana_RTpkhashbalance(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *array,uint64_t *spentp,struct iguana_outpoint *unspents,int32_t *nump,struct iguana_ramchain *ramchain,struct iguana_pkhash *p,struct iguana_outpoint lastpt,uint8_t rmd160[20],char *coinaddr,uint8_t *pubkey33,int32_t lastheight,int32_t minconf,int32_t maxconf,char *remoteaddr,int32_t includespent)
{ {
struct iguana_unspent *U; struct iguana_utxo *U2; int32_t firstslot,vout,spentflag,max,uheight,spentheight; uint32_t pkind=0,unspentind; uint64_t spent = 0,checkval,deposits = 0; struct iguana_txid *T; struct iguana_account *A2; struct iguana_outpoint outpt; struct iguana_ramchaindata *rdata = 0; uint64_t RTspend = 0; bits256 txid; struct iguana_unspent *U; struct iguana_utxo *U2; int32_t firstslot,vout,spentflag,max,uheight,spentheight=0; uint32_t pkind=0,unspentind; uint64_t spent = 0,checkval,deposits = 0; struct iguana_txid *T; struct iguana_account *A2; struct iguana_outpoint outpt; struct iguana_ramchaindata *rdata = 0; uint64_t RTspend = 0; bits256 txid;
max = *nump; max = *nump;
*spentp = *nump = 0; *spentp = *nump = 0;
if ( 0 && coin->RTramchain_busy != 0 ) if ( (0) && coin->RTramchain_busy != 0 )
{ {
printf("iguana_pkhashbalance: unexpected access when RTramchain_busy\n"); printf("iguana_pkhashbalance: unexpected access when RTramchain_busy\n");
return(0); return(0);
@ -599,7 +599,7 @@ int64_t iguana_RTpkhashbalance(struct supernet_info *myinfo,struct iguana_info *
} }
unspentind = U2[unspentind].prevunspentind; unspentind = U2[unspentind].prevunspentind;
} }
if ( 0 && llabs((int64_t)spent - (int64_t)checkval - (int64_t)RTspend) > SMALLVAL ) if ( (0) && llabs((int64_t)spent - (int64_t)checkval - (int64_t)RTspend) > SMALLVAL )
printf("spend %s: [%d] deposits %.8f spent %.8f check %.8f (%.8f) vs A2[%u] %.8f\n",lastheight==IGUANA_MAXHEIGHT?"checkerr":"",lastpt.hdrsi,dstr(deposits),dstr(spent),dstr(checkval)+dstr(RTspend),dstr(*spentp),pkind,dstr(A2[pkind].total)); printf("spend %s: [%d] deposits %.8f spent %.8f check %.8f (%.8f) vs A2[%u] %.8f\n",lastheight==IGUANA_MAXHEIGHT?"checkerr":"",lastpt.hdrsi,dstr(deposits),dstr(spent),dstr(checkval)+dstr(RTspend),dstr(*spentp),pkind,dstr(A2[pkind].total));
} }
(*spentp) = spent; (*spentp) = spent;
@ -613,7 +613,7 @@ int32_t iguana_RTpkhasharray(struct supernet_info *myinfo,struct iguana_info *co
int32_t i,n,m,numunspents; uint64_t spent,deposits,netbalance,total; struct iguana_outpoint lastpt; struct iguana_pkhash *p,_p; struct iguana_ramchain *ramchain; struct iguana_bundle *bp; int32_t i,n,m,numunspents; uint64_t spent,deposits,netbalance,total; struct iguana_outpoint lastpt; struct iguana_pkhash *p,_p; struct iguana_ramchain *ramchain; struct iguana_bundle *bp;
if ( coin->RTheight == 0 ) if ( coin->RTheight == 0 )
return(-1); return(-1);
if ( 0 && coin->RTramchain_busy != 0 ) if ( (0) && coin->RTramchain_busy != 0 )
{ {
printf("iguana_pkhasharray: unexpected access when RTramchain_busy\n"); printf("iguana_pkhasharray: unexpected access when RTramchain_busy\n");
return(-1); return(-1);
@ -682,7 +682,7 @@ uint64_t iguana_RTunspents(struct supernet_info *myinfo,struct iguana_info *coin
{ {
uint64_t total=0,sum=0; struct iguana_pkhash *P; uint8_t *addrtypes,*pubkeys; int32_t i,j,numunspents,maxunspents,flag = 0; char coinaddr[64]; uint64_t total=0,sum=0; struct iguana_pkhash *P; uint8_t *addrtypes,*pubkeys; int32_t i,j,numunspents,maxunspents,flag = 0; char coinaddr[64];
//portable_mutex_lock(&coin->RTmutex); //portable_mutex_lock(&coin->RTmutex);
while ( 0 && coin->RTramchain_busy != 0 ) while ( (0) && coin->RTramchain_busy != 0 )
{ {
fprintf(stderr,"iguana_pkhasharray: %s unexpected access when RTramchain_busy\n",coin->symbol); fprintf(stderr,"iguana_pkhasharray: %s unexpected access when RTramchain_busy\n",coin->symbol);
sleep(1); sleep(1);
@ -1181,7 +1181,7 @@ cJSON *iguana_RTlistunspent(struct supernet_info *myinfo,struct iguana_info *coi
int32_t iguana_RTunspentslists(struct supernet_info *myinfo,struct iguana_info *coin,uint64_t *totalp,struct iguana_outpoint *unspents,int32_t max,uint64_t required,int32_t minconf,cJSON *addresses,char *remoteaddr) int32_t iguana_RTunspentslists(struct supernet_info *myinfo,struct iguana_info *coin,uint64_t *totalp,struct iguana_outpoint *unspents,int32_t max,uint64_t required,int32_t minconf,cJSON *addresses,char *remoteaddr)
{ {
uint64_t sum = 0; int32_t i,n,firstslot,numunspents,numaddrs; uint8_t pubkey[65]; char *coinaddr,*spendscriptstr; struct iguana_outpoint outpt; cJSON *array,*item; uint64_t sum = 0; int32_t i=0,n,firstslot,numunspents,numaddrs; uint8_t pubkey[65]; char *coinaddr,*spendscriptstr; struct iguana_outpoint outpt; cJSON *array,*item;
*totalp = 0; *totalp = 0;
numunspents = 0; numunspents = 0;
if ( (numaddrs= cJSON_GetArraySize(addresses)) == 0 ) if ( (numaddrs= cJSON_GetArraySize(addresses)) == 0 )
@ -1538,7 +1538,7 @@ int32_t iguana_utxoaddr_check(struct supernet_info *myinfo,struct iguana_info *c
sum = 0; sum = 0;
bitcoin_address(coinaddr,utxoaddr->p2sh == 0 ? coin->chain->pubtype : coin->chain->p2shtype,utxoaddr->rmd160,sizeof(utxoaddr->rmd160)); bitcoin_address(coinaddr,utxoaddr->p2sh == 0 ? coin->chain->pubtype : coin->chain->p2shtype,utxoaddr->rmd160,sizeof(utxoaddr->rmd160));
numunspents += iguana_RTaddr_unspents(myinfo,coin,&sum,&unspents[numunspents],max-numunspents,coinaddr,0,lastheight,0); numunspents += iguana_RTaddr_unspents(myinfo,coin,&sum,&unspents[numunspents],max-numunspents,coinaddr,0,lastheight,0);
if ( 0 && utxoaddr->histbalance != 0 && strcmp(coin->symbol,"BTCD") == 0 ) if ( (0) && utxoaddr->histbalance != 0 && strcmp(coin->symbol,"BTCD") == 0 )
{ {
total += utxoaddr->histbalance; total += utxoaddr->histbalance;
//printf("fiat/revs sendtoaddress %s %.8f # total %.8f\n",coinaddr,dstr(utxoaddr->histbalance),dstr(total)); //printf("fiat/revs sendtoaddress %s %.8f # total %.8f\n",coinaddr,dstr(utxoaddr->histbalance),dstr(total));
@ -1554,7 +1554,7 @@ int32_t iguana_utxoaddr_check(struct supernet_info *myinfo,struct iguana_info *c
flag = 1; flag = 1;
//break; //break;
} }
if ( 0 && flag == 0 )//sum != utxoaddr->histbalance || checkbalance != sum ) if ( (0) && flag == 0 )//sum != utxoaddr->histbalance || checkbalance != sum )
{ {
bad++; bad++;
for (i=0; i<numunspents; i++) for (i=0; i<numunspents; i++)
@ -1624,7 +1624,7 @@ uint64_t iguana_RTstart(struct supernet_info *myinfo,struct iguana_info *coin,in
uint64_t iguana_utxoaddr_gen(struct supernet_info *myinfo,struct iguana_info *coin,int32_t maxheight) uint64_t iguana_utxoaddr_gen(struct supernet_info *myinfo,struct iguana_info *coin,int32_t maxheight)
{ {
char fname[1024],fname2[1024],coinaddr[64],str[65],checkaddr[64]; struct iguana_utxoaddr *utxoaddr,UA,*tmp,*last=0; uint16_t hdrsi; uint8_t *table,item[UTXOADDR_ITEMSIZE]; uint32_t *counts,*offsets,offset,n; int32_t total,errs=0,height=0,j,k,ind,tablesize=0; struct iguana_bundle *bp; struct iguana_ramchaindata *rdata=0; uint64_t checkbalance=0,balance = 0; char fname[1024],fname2[1024],coinaddr[64],str[65],checkaddr[64]; struct iguana_utxoaddr *utxoaddr,UA,*tmp,*last=0; uint16_t hdrsi; uint8_t *table,item[UTXOADDR_ITEMSIZE]; uint32_t *counts,*offsets,offset,n; int32_t total,errs=0,height=0,ind,tablesize=0; struct iguana_bundle *bp; struct iguana_ramchaindata *rdata=0; uint64_t checkbalance=0,balance = 0;
for (hdrsi=0; hdrsi<coin->bundlescount-1; hdrsi++) for (hdrsi=0; hdrsi<coin->bundlescount-1; hdrsi++)
{ {
if ( (bp= coin->bundles[hdrsi]) != 0 && bp->bundleheight < maxheight ) if ( (bp= coin->bundles[hdrsi]) != 0 && bp->bundleheight < maxheight )
@ -1633,7 +1633,7 @@ uint64_t iguana_utxoaddr_gen(struct supernet_info *myinfo,struct iguana_info *co
sprintf(fname2,"%s/%s/utxoaddrs.%d",GLOBAL_DBDIR,coin->symbol,height), OS_portable_path(fname2); sprintf(fname2,"%s/%s/utxoaddrs.%d",GLOBAL_DBDIR,coin->symbol,height), OS_portable_path(fname2);
if ( iguana_utxoaddr_map(coin,fname2) != 0 ) if ( iguana_utxoaddr_map(coin,fname2) != 0 )
{ {
if ( 0 && strcmp("BTCD",coin->symbol) == 0 ) if ( (0) && strcmp("BTCD",coin->symbol) == 0 )
errs = iguana_utxoaddr_validate(myinfo,coin,height); errs = iguana_utxoaddr_validate(myinfo,coin,height);
printf("nogen %s HIST BALANCE %s %.8f errs %d\n",fname2,bits256_str(str,coin->utxoaddrhash),dstr(coin->histbalance),errs); printf("nogen %s HIST BALANCE %s %.8f errs %d\n",fname2,bits256_str(str,coin->utxoaddrhash),dstr(coin->histbalance),errs);
if ( errs == 0 && coin->histbalance > 0 && height > 0 ) if ( errs == 0 && coin->histbalance > 0 && height > 0 )
@ -1731,14 +1731,14 @@ uint64_t iguana_utxoaddr_gen(struct supernet_info *myinfo,struct iguana_info *co
{ {
qsort(&table[offsets[ind] * UTXOADDR_ITEMSIZE],counts[ind],UTXOADDR_ITEMSIZE,_utxoaddr_cmp); qsort(&table[offsets[ind] * UTXOADDR_ITEMSIZE],counts[ind],UTXOADDR_ITEMSIZE,_utxoaddr_cmp);
continue; continue;
for (j=0; j<counts[ind]; j++) /*for (j=0; j<counts[ind]; j++)
{ {
iguana_rwutxoaddr(0,ind,&table[(offsets[ind]+j) * UTXOADDR_ITEMSIZE],&UA); iguana_rwutxoaddr(0,ind,&table[(offsets[ind]+j) * UTXOADDR_ITEMSIZE],&UA);
for (k=0; k<20; k++) for (k=0; k<20; k++)
printf("%02x",UA.rmd160[k]); printf("%02x",UA.rmd160[k]);
bitcoin_address(coinaddr,coin->chain->pubtype,UA.rmd160,sizeof(UA.rmd160)); bitcoin_address(coinaddr,coin->chain->pubtype,UA.rmd160,sizeof(UA.rmd160));
//printf(" [%4d] p%-5d %12.8f ind.%04x %d %s\n",UA.hdrsi,UA.pkind,dstr(UA.histbalance),ind,j,coinaddr); //printf(" [%4d] p%-5d %12.8f ind.%04x %d %s\n",UA.hdrsi,UA.pkind,dstr(UA.histbalance),ind,j,coinaddr);
} }*/
} }
} }
if ( iguana_utxoaddr_save(coin,fname,balance,counts,offsets,table) == 0 ) if ( iguana_utxoaddr_save(coin,fname,balance,counts,offsets,table) == 0 )
@ -1762,7 +1762,7 @@ uint64_t iguana_utxoaddr_gen(struct supernet_info *myinfo,struct iguana_info *co
{ {
printf("validating %s HIST BALANCE %s %.8f errs %d\n",fname2,bits256_str(str,coin->utxoaddrhash),dstr(coin->histbalance),errs); printf("validating %s HIST BALANCE %s %.8f errs %d\n",fname2,bits256_str(str,coin->utxoaddrhash),dstr(coin->histbalance),errs);
errs = 0; errs = 0;
if ( 0 && strcmp("BTCD",coin->symbol) == 0 ) if ( (0) && strcmp("BTCD",coin->symbol) == 0 )
errs = iguana_utxoaddr_validate(myinfo,coin,height); errs = iguana_utxoaddr_validate(myinfo,coin,height);
printf("gen %s HIST BALANCE %s %.8f errs %d\n",fname2,bits256_str(str,coin->utxoaddrhash),dstr(coin->histbalance),errs); printf("gen %s HIST BALANCE %s %.8f errs %d\n",fname2,bits256_str(str,coin->utxoaddrhash),dstr(coin->histbalance),errs);
if ( errs != 0 || height == 0 ) if ( errs != 0 || height == 0 )

2
iguana/iguana_volatiles.c

@ -290,7 +290,7 @@ int32_t iguana_volatileupdate(struct iguana_info *coin,int32_t incremental,struc
utxo = &spentchain->Uextras[spent_unspentind]; utxo = &spentchain->Uextras[spent_unspentind];
if ( utxo->spentflag == 0 ) if ( utxo->spentflag == 0 )
{ {
if ( 0 && fromheight/coin->chain->bundlesize >= coin->current->hdrsi ) if ( (0) && fromheight/coin->chain->bundlesize >= coin->current->hdrsi )
printf("iguana_volatileupdate.%d: [%d] spent.(u%u %.8f pkind.%d) fromht.%d [%d] spendind.%d\n",incremental,spent_hdrsi,spent_unspentind,dstr(spent_value),spent_pkind,fromheight,fromheight/coin->chain->bundlesize,spendind); printf("iguana_volatileupdate.%d: [%d] spent.(u%u %.8f pkind.%d) fromht.%d [%d] spendind.%d\n",incremental,spent_hdrsi,spent_unspentind,dstr(spent_value),spent_pkind,fromheight,fromheight/coin->chain->bundlesize,spendind);
utxo->prevunspentind = A2[spent_pkind].lastunspentind; utxo->prevunspentind = A2[spent_pkind].lastunspentind;
utxo->spendind = spendind; utxo->spendind = spendind;

4
iguana/iguana_wallet.c

@ -818,7 +818,7 @@ cJSON *iguana_walletiterate(struct supernet_info *myinfo,struct iguana_info *coi
} }
printf("persistent address not found in wallet, autoadd.(%s)\n",coinaddr); printf("persistent address not found in wallet, autoadd.(%s)\n",coinaddr);
} }
else if ( persistent_flag != 0 && 0 ) else if ( persistent_flag != 0 && (0) )
printf("found persistent address in wallet\n"); printf("found persistent address in wallet\n");
} }
portable_mutex_unlock(&myinfo->bu_mutex); portable_mutex_unlock(&myinfo->bu_mutex);
@ -1593,7 +1593,7 @@ STRING_ARG(bitcoinrpc,dumpwallet,filename)
{ {
if ( (walletobj= jobj(strobj,"wallet")) != 0 ) if ( (walletobj= jobj(strobj,"wallet")) != 0 )
jadd(retjson,"wallet",jduplicate(walletobj)); jadd(retjson,"wallet",jduplicate(walletobj));
if ( 0 && (walletobj= iguana_walletjson(myinfo)) != 0 ) if ( (0) && (walletobj= iguana_walletjson(myinfo)) != 0 )
jadd(retjson,"memory",walletobj); jadd(retjson,"memory",walletobj);
free_json(strobj); free_json(strobj);
} }

9
iguana/m

@ -0,0 +1,9 @@
#!/bin/bash
#./configure --enable-endomorphism --enable-module-ecdh --enable-module-schnorr --enable-module-rangeproof --enable-experimental --enable-module_recovery
rm -f ../agents/iguana *.o
git pull
cd secp256k1; ./m_unix; cd ..
cd ../crypto777; ./m_LP; cd ../iguana
clang -g -Wno-deprecated -c -O2 -DLIQUIDITY_PROVIDER=1 *.c ../basilisk/basilisk.c ../gecko/gecko.c ../datachain/datachain.c
clang -g -Wno-deprecated -c -DLIQUIDITY_PROVIDER=1 main.c iguana777.c iguana_bundles.c ../basilisk/basilisk.c
clang -g -o ../agents/iguana *.o ../agents/libcrypto777.a /usr/local/lib/libnanomsg.dylib -lcurl -lssl -lcrypto -lpthread -lz -lm

14
iguana/main.c

@ -543,7 +543,7 @@ void iguana_appletests(struct supernet_info *myinfo)
{ {
char *str; char *str;
//iguana_chaingenesis(1,1403138561,0x1e0fffff,8359109,bits256_conv("fd1751cc6963d88feca94c0d01da8883852647a37a0a67ce254d62dd8c9d5b2b")); // BTCD //iguana_chaingenesis(1,1403138561,0x1e0fffff,8359109,bits256_conv("fd1751cc6963d88feca94c0d01da8883852647a37a0a67ce254d62dd8c9d5b2b")); // BTCD
if ( 0 ) if ( (0) )
{ {
char genesisblock[1024]; char genesisblock[1024];
//iguana_chaingenesis("VPN",0,bits256_conv("00000ac7d764e7119da60d3c832b1d4458da9bc9ef9d5dd0d91a15f690a46d99"),genesisblock,"scrypt",1,1409839200,0x1e0fffff,64881664,bits256_conv("698a93a1cacd495a7a4fb3864ad8d06ed4421dedbc57f9aaad733ea53b1b5828")); // VPN //iguana_chaingenesis("VPN",0,bits256_conv("00000ac7d764e7119da60d3c832b1d4458da9bc9ef9d5dd0d91a15f690a46d99"),genesisblock,"scrypt",1,1409839200,0x1e0fffff,64881664,bits256_conv("698a93a1cacd495a7a4fb3864ad8d06ed4421dedbc57f9aaad733ea53b1b5828")); // VPN
@ -571,13 +571,13 @@ void iguana_appletests(struct supernet_info *myinfo)
bitcoin_sharedsecret(myinfo->ctx,hash2,pubkey,33); bitcoin_sharedsecret(myinfo->ctx,hash2,pubkey,33);
printf("secp256k1 elapsed %.3f for %d iterations\n",OS_milliseconds() - startmillis,i); printf("secp256k1 elapsed %.3f for %d iterations\n",OS_milliseconds() - startmillis,i);
getchar();**/ getchar();**/
if ( 0 && (str= SuperNET_JSON(myinfo,iguana_coinfind("BTCD"),cJSON_Parse("{\"protover\":70002,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":14631,\"rpc\":14632,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":512,\"endpend\":512,\"services\":129,\"maxpeers\":8,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":1,\"poll\":100}"),0,myinfo->rpcport)) != 0 ) if ( (0) && (str= SuperNET_JSON(myinfo,iguana_coinfind("BTCD"),cJSON_Parse("{\"protover\":70002,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":14631,\"rpc\":14632,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":512,\"endpend\":512,\"services\":129,\"maxpeers\":8,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":1,\"poll\":100}"),0,myinfo->rpcport)) != 0 )
{ {
free(str); free(str);
if ( 1 && (str= SuperNET_JSON(myinfo,iguana_coinfind("BTC"),cJSON_Parse("{\"portp2p\":8333,\"RELAY\":0,\"VALIDATE\":0,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":8,\"newcoin\":\"BTC\",\"active\":0,\"numhelpers\":1,\"poll\":100}"),0,myinfo->rpcport)) != 0 ) if ( 1 && (str= SuperNET_JSON(myinfo,iguana_coinfind("BTC"),cJSON_Parse("{\"portp2p\":8333,\"RELAY\":0,\"VALIDATE\":0,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":8,\"newcoin\":\"BTC\",\"active\":0,\"numhelpers\":1,\"poll\":100}"),0,myinfo->rpcport)) != 0 )
{ {
free(str); free(str);
if ( 0 && (str= SuperNET_JSON(myinfo,iguana_coinfind("BTCD"),cJSON_Parse("{\"agent\":\"SuperNET\",\"method\":\"login\",\"handle\":\"alice\",\"password\":\"alice\",\"passphrase\":\"alice\"}"),0,myinfo->rpcport)) != 0 ) if ( (0) && (str= SuperNET_JSON(myinfo,iguana_coinfind("BTCD"),cJSON_Parse("{\"agent\":\"SuperNET\",\"method\":\"login\",\"handle\":\"alice\",\"password\":\"alice\",\"passphrase\":\"alice\"}"),0,myinfo->rpcport)) != 0 )
{ {
free(str); free(str);
if ( (str= SuperNET_JSON(myinfo,iguana_coinfind("BTCD"),cJSON_Parse("{\"agent\":\"SuperNET\",\"method\":\"login\",\"handle\":\"bob\",\"password\":\"bob\",\"passphrase\":\"bob\"}"),0,myinfo->rpcport)) != 0 ) if ( (str= SuperNET_JSON(myinfo,iguana_coinfind("BTCD"),cJSON_Parse("{\"agent\":\"SuperNET\",\"method\":\"login\",\"handle\":\"bob\",\"password\":\"bob\",\"passphrase\":\"bob\"}"),0,myinfo->rpcport)) != 0 )
@ -641,7 +641,7 @@ int32_t iguana_commandline(struct supernet_info *myinfo,char *arg)
free(str); free(str);
} }
free_json(argjson); free_json(argjson);
if ( 0 ) if ( (0) )
{ {
uint32_t buf[81],c; uint32_t buf[81],c;
OS_randombytes((void *)buf,sizeof(buf)); OS_randombytes((void *)buf,sizeof(buf));
@ -1612,7 +1612,7 @@ void komodo_ICO_batch(cJSON *array,int32_t batchid)
printf("# %s KMD %.8f\n",coinaddr,dstr(kmdamount)); printf("# %s KMD %.8f\n",coinaddr,dstr(kmdamount));
if ( (iter & 1) == 0 ) if ( (iter & 1) == 0 )
{ {
if ( 0 ) if ( (0) )
{ {
printf("curl --url \"http://127.0.0.1:7778\" --data \"{\\\"agent\\\":\\\"dex\\\",\\\"method\\\":\\\"importaddress\\\",\\\"address\\\":\\\"%s\\\",\\\"symbol\\\":\\\"KMD\\\"}\" # %.8f\n",coinaddr,dstr(kmdamount)); printf("curl --url \"http://127.0.0.1:7778\" --data \"{\\\"agent\\\":\\\"dex\\\",\\\"method\\\":\\\"importaddress\\\",\\\"address\\\":\\\"%s\\\",\\\"symbol\\\":\\\"KMD\\\"}\" # %.8f\n",coinaddr,dstr(kmdamount));
printf("sleep 3\n"); printf("sleep 3\n");
@ -1678,7 +1678,7 @@ void iguana_main(void *arg)
#ifdef __APPLE__ #ifdef __APPLE__
char *batchstr,*batchstr2; cJSON *batchjson; long batchsize; char fname[512],fname2[512]; int32_t batchid = 10; char *batchstr,*batchstr2; cJSON *batchjson; long batchsize; char fname[512],fname2[512]; int32_t batchid = 10;
sprintf(fname,"REVS.raw"), sprintf(fname2,"REVS.rawtxids"); sprintf(fname,"REVS.raw"), sprintf(fname2,"REVS.rawtxids");
if ( 0 && (batchstr= OS_filestr(&batchsize,fname)) != 0 && (batchstr2= OS_filestr(&batchsize,fname2)) != 0 ) if ( (0) && (batchstr= OS_filestr(&batchsize,fname)) != 0 && (batchstr2= OS_filestr(&batchsize,fname2)) != 0 )
{ {
komodo_REVS_merge(batchstr,batchstr2); komodo_REVS_merge(batchstr,batchstr2);
} }
@ -1763,7 +1763,7 @@ void iguana_main(void *arg)
{ {
basilisks_init(myinfo); basilisks_init(myinfo);
} }
if ( 0 ) if ( (0) )
{ {
char *jsonstr = "[\"03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828\", \"02ebfc784a4ba768aad88d44d1045d240d47b26e248cafaf1c5169a42d7a61d344\", \"03750cf30d739cd7632f77c1c02812dd7a7181628b0558058d4755838117e05339\", \"0394f3529d2e8cc69ffa7a2b55f3761e7be978fa1896ef4c55dc9c275e77e5bf5e\", \"0243c1eeb3777af47187d542e5f8c84f0ac4b05cf5a7ad77faa8cb6d2d56db7823\", \"02bb298844175640a34e908ffdfa2839f77aba3d5edadefee16beb107826e00063\", \"02fa88e549b4b871498f892e527a5d57287916809f8cc3163f641d71c535e8df5a\", \"032f799e370f06476793a122fcd623db7804898fe5aef5572095cfee6353df34bf\", \"02c06fe5401faff4442ef87b7d1b56c2e5a214166615f9a2f2030c71b0cb067ae8\", \"038ac67ca49a8169bcc5de83fe020071095a2c3b2bc4d1c17386977329758956d5\"]"; char *jsonstr = "[\"03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828\", \"02ebfc784a4ba768aad88d44d1045d240d47b26e248cafaf1c5169a42d7a61d344\", \"03750cf30d739cd7632f77c1c02812dd7a7181628b0558058d4755838117e05339\", \"0394f3529d2e8cc69ffa7a2b55f3761e7be978fa1896ef4c55dc9c275e77e5bf5e\", \"0243c1eeb3777af47187d542e5f8c84f0ac4b05cf5a7ad77faa8cb6d2d56db7823\", \"02bb298844175640a34e908ffdfa2839f77aba3d5edadefee16beb107826e00063\", \"02fa88e549b4b871498f892e527a5d57287916809f8cc3163f641d71c535e8df5a\", \"032f799e370f06476793a122fcd623db7804898fe5aef5572095cfee6353df34bf\", \"02c06fe5401faff4442ef87b7d1b56c2e5a214166615f9a2f2030c71b0cb067ae8\", \"038ac67ca49a8169bcc5de83fe020071095a2c3b2bc4d1c17386977329758956d5\"]";

1
iguana/mini-gmp.c

@ -4416,6 +4416,7 @@ void mpz_from_bits256(mpz_t bn,bits256 x)
bits256 mpz_to_bits256(mpz_t bn) bits256 mpz_to_bits256(mpz_t bn)
{ {
bits256 x,rev; size_t count; int32_t i; bits256 x,rev; size_t count; int32_t i;
memset(x.bytes,0,sizeof(x));
mpz_export(rev.bytes,&count,1,sizeof(uint64_t),1,0,bn); mpz_export(rev.bytes,&count,1,sizeof(uint64_t),1,0,bn);
for (i=0; i<32; i++) for (i=0; i<32; i++)
x.bytes[i] = rev.bytes[31-i]; x.bytes[i] = rev.bytes[31-i];

2
iguana/pangea_api.c

@ -530,7 +530,7 @@ char *pangea_hexmsg(struct supernet_info *myinfo,struct gecko_chain *cat,void *d
} }
} }
} }
else if ( 0 ) else if ( (0) )
{ {
for (i=0; i<datalen; i++) for (i=0; i<datalen; i++)
printf("%02x",serialized[i]); printf("%02x",serialized[i]);

2
iguana/pangea_hand.c

@ -811,7 +811,7 @@ int32_t pangea_lastman(struct supernet_info *myinfo,struct table_info *tp)
printf("DUPLICATE LASTMAN!\n"); printf("DUPLICATE LASTMAN!\n");
return(1); return(1);
} }
if ( 0 && tp->priv.myind == activej && tp->priv.automuck == 0 ) if ( (0) && tp->priv.myind == activej && tp->priv.automuck == 0 )
{ {
pangea_sendcmd(myinfo,tp,"faceup",-1,tp->priv.holecards[0].bytes,sizeof(tp->priv.holecards[0]),tp->priv.cardis[0],tp->priv.cardis[0] != 0xff); pangea_sendcmd(myinfo,tp,"faceup",-1,tp->priv.holecards[0].bytes,sizeof(tp->priv.holecards[0]),tp->priv.cardis[0],tp->priv.cardis[0] != 0xff);
pangea_sendcmd(myinfo,tp,"faceup",-1,tp->priv.holecards[1].bytes,sizeof(tp->priv.holecards[1]),tp->priv.cardis[1],tp->priv.cardis[1] != 0xff); pangea_sendcmd(myinfo,tp,"faceup",-1,tp->priv.holecards[1].bytes,sizeof(tp->priv.holecards[1]),tp->priv.cardis[1],tp->priv.cardis[1] != 0xff);

2
iguana/pangea_json.c

@ -227,6 +227,7 @@ cJSON *pangea_tablestatus(struct supernet_info *myinfo,struct table_info *tp)
jaddi64bits(array,tp->active[i]!=0?tp->active[i]->nxt64bits:0); jaddi64bits(array,tp->active[i]!=0?tp->active[i]->nxt64bits:0);
jadd(json,"addrs",array);*/ jadd(json,"addrs",array);*/
total = 0; total = 0;
str = "error";
for (iter=0; iter<6; iter++) for (iter=0; iter<6; iter++)
{ {
array = cJSON_CreateArray(); array = cJSON_CreateArray();
@ -243,6 +244,7 @@ cJSON *pangea_tablestatus(struct supernet_info *myinfo,struct table_info *tp)
case 3: val = p->betstatus; str = "status"; break; case 3: val = p->betstatus; str = "status"; break;
case 4: val = p->bets; str = "bets"; break; case 4: val = p->bets; str = "bets"; break;
case 5: val = p->won; str = "won"; break; case 5: val = p->won; str = "won"; break;
default: str = "error"; break;
} }
} }
if ( iter == 5 ) if ( iter == 5 )

2
iguana/ramchain_api.c

@ -82,7 +82,7 @@ STRING_ARG(iguana,removecoin,activecoin)
{ {
coin->active = 0; coin->active = 0;
coin->started = 0; coin->started = 0;
if ( 0 ) if ( (0) )
{ {
for (i=0; i<IGUANA_MAXPEERS; i++) for (i=0; i<IGUANA_MAXPEERS; i++)
{ {

2
iguana/secp256k1/src/ecmult_const_impl.h

@ -60,7 +60,7 @@ static int secp256k1_wnaf_const(int *wnaf, secp256k1_scalar s, int w) {
int word = 0; int word = 0;
/* 1 2 3 */ /* 1 2 3 */
int u_last; int u_last;
int u; int u=0;
#ifdef USE_ENDOMORPHISM #ifdef USE_ENDOMORPHISM
int flip; int flip;

2
iguana/secp256k1/src/modules/rangeproof/rangeproof_impl.h

@ -406,7 +406,7 @@ SECP256K1_INLINE static void secp256k1_rangeproof_ch32xor(unsigned char *x, cons
SECP256K1_INLINE static int secp256k1_rangeproof_rewind_inner(secp256k1_scalar *blind,uint64_t *v, SECP256K1_INLINE static int secp256k1_rangeproof_rewind_inner(secp256k1_scalar *blind,uint64_t *v,
unsigned char *message,int *mlen,secp256k1_scalar *ev,secp256k1_scalar *s,int *rsizes,int rings, const unsigned char *nonce,const unsigned char *commit,const unsigned char *proof,int len) unsigned char *message,int *mlen,secp256k1_scalar *ev,secp256k1_scalar *s,int *rsizes,int rings, const unsigned char *nonce,const unsigned char *commit,const unsigned char *proof,int len)
{ {
unsigned char prep[4096]; unsigned char tmp[32]; uint64_t value; int offset,i,j,b,skip1,skip2,npub; unsigned char prep[4096]; unsigned char tmp[32]; uint64_t value=0; int offset,i,j,b,skip1,skip2,npub;
secp256k1_scalar s_orig[128]; secp256k1_scalar sec[32]; secp256k1_scalar stmp; secp256k1_scalar s_orig[128]; secp256k1_scalar sec[32]; secp256k1_scalar stmp;
npub = ((rings - 1) << 2) + rsizes[rings-1]; npub = ((rings - 1) << 2) + rsizes[rings-1];
VERIFY_CHECK(npub <= 128); VERIFY_CHECK(npub <= 128);

2
iguana/secp256k1/src/modules/recovery/main_impl.h

@ -123,7 +123,7 @@ static int secp256k1_ecdsa_sig_recover(const secp256k1_ecmult_context *ctx, cons
int secp256k1_ecdsa_sign_recoverable(const secp256k1_context* ctx, secp256k1_ecdsa_recoverable_signature *signature, const unsigned char *msg32, const unsigned char *seckey, secp256k1_nonce_function noncefp, const void* noncedata) { int secp256k1_ecdsa_sign_recoverable(const secp256k1_context* ctx, secp256k1_ecdsa_recoverable_signature *signature, const unsigned char *msg32, const unsigned char *seckey, secp256k1_nonce_function noncefp, const void* noncedata) {
secp256k1_scalar r, s; secp256k1_scalar r, s;
secp256k1_scalar sec, non, msg; secp256k1_scalar sec, non, msg;
int recid; int recid = 0;
int ret = 0; int ret = 0;
int overflow = 0; int overflow = 0;
VERIFY_CHECK(ctx != NULL); VERIFY_CHECK(ctx != NULL);

10
includes/iguana_structs.h

@ -185,7 +185,7 @@ struct msgcounts { uint32_t version,verack,getaddr,addr,inv,getdata,notfound,get
//struct iguana_fileitem { bits256 hash2; struct iguana_txdatabits txdatabits; }; //struct iguana_fileitem { bits256 hash2; struct iguana_txdatabits txdatabits; };
struct iguana_kvitem { UT_hash_handle hh; uint8_t keyvalue[]; }PACKEDSTRUCT; struct iguana_kvitem { UT_hash_handle hh; uint8_t keyvalue[]; };
struct iguana_iAddr struct iguana_iAddr
{ {
@ -223,13 +223,13 @@ struct iguana_block
{ {
iguana_blockfields; iguana_blockfields;
struct iguana_zcashRO zRO[]; struct iguana_zcashRO zRO[];
} PACKEDSTRUCT; } ;
struct iguana_zblock // mu struct iguana_zblock // mu
{ {
iguana_blockfields; // this is to minimize code needed to support both types iguana_blockfields; // this is to minimize code needed to support both types
struct iguana_zcashRO zRO; // if zRO is changed, the RO part must also be updated struct iguana_zcashRO zRO; // if zRO is changed, the RO part must also be updated
} PACKEDSTRUCT; } ;
#define IGUANA_LHASH_BLOCKS 0 #define IGUANA_LHASH_BLOCKS 0
#define IGUANA_LHASH_TXIDS 1 // #define IGUANA_LHASH_TXIDS 1 //
@ -285,8 +285,8 @@ struct iguana_utxo { uint32_t fromheight:31,lockedflag:1,prevunspentind:31,spent
#ifdef DEPRECATED_HHUTXO #ifdef DEPRECATED_HHUTXO
struct iguana_hhaccount { UT_hash_handle hh; uint64_t pval; struct iguana_account a; }PACKEDSTRUCT; struct iguana_hhaccount { UT_hash_handle hh; uint64_t pval; struct iguana_account a; }PACKEDSTRUCT;
#endif #endif
struct iguana_hhutxo { UT_hash_handle hh; uint64_t uval; struct iguana_utxo u; }PACKEDSTRUCT; struct iguana_hhutxo { UT_hash_handle hh; uint64_t uval; struct iguana_utxo u; };
struct iguana_utxoaddr { UT_hash_handle hh; uint64_t histbalance; uint32_t pkind:30,p2sh:1,searchedhist:1; uint16_t hdrsi; uint8_t rmd160[20]; }PACKEDSTRUCT; struct iguana_utxoaddr { UT_hash_handle hh; uint64_t histbalance; uint32_t pkind:30,p2sh:1,searchedhist:1; uint16_t hdrsi; uint8_t rmd160[20]; };
// GLOBAL one zero to non-zero write (unless reorg) // GLOBAL one zero to non-zero write (unless reorg)
struct iguana_spendvector { uint64_t value; uint32_t pkind,unspentind; int32_t fromheight; uint16_t hdrsi:15,tmpflag:1; }PACKEDSTRUCT; // unspentind struct iguana_spendvector { uint64_t value; uint32_t pkind,unspentind; int32_t fromheight; uint16_t hdrsi:15,tmpflag:1; }PACKEDSTRUCT; // unspentind

Loading…
Cancel
Save