diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index eb0fede65..22bfaf87b 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -398,7 +398,7 @@ struct iguana_txid *iguana_bundletx(struct iguana_info *coin,struct iguana_bundl static const bits256 zero; int32_t hdrsi,iter; struct iguana_txid *T; int64_t Toffset; char fname[1024]; FILE *fp; struct iguana_ramchaindata rdata,*rptr; portable_mutex_lock(&coin->special_mutex); - if ( (rptr= bp->ramchain.H.data) != 0 || (bp == coin->current && (rptr= coin->RTramchain.H.data) != 0) ) + if ( (rptr= bp->ramchain.H.data) != 0 )//|| (bp == coin->current && (rptr= coin->RTramchain.H.data) != 0) ) { T = RAMCHAIN_PTR(rptr,Toffset); *tx = T[txidind]; diff --git a/iguana/iguana_msg.c b/iguana/iguana_msg.c index 0f4441fb8..5582cf13f 100755 --- a/iguana/iguana_msg.c +++ b/iguana/iguana_msg.c @@ -421,7 +421,8 @@ void iguana_gotaddr(struct iguana_info *coin,struct iguana_peer *addr,struct igu printf("0x%02x%s",A->ip[i],i<15?",":""); printf("}, 14631},\n"); } - iguana_possible_peer(coin,ipport); + if ( strcmp(coin->symbol,"BTC") != 0 || (rand() % 10) == 0 ) + iguana_possible_peer(coin,ipport); //printf("gotaddr.(%s:%d) from (%s)\n",ipaddr,port,addr->ipaddr); } diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index f9eb79e7e..cc328bf9c 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -874,7 +874,7 @@ uint32_t iguana_possible_peer(struct iguana_info *coin,char *ipaddr) printf("%s possible peer.(%s) %x already there\n",coin->symbol,ipaddr,(uint32_t)coin->peers->active[i].ipbits); return(0); } - //printf("Q possible.(%s)\n",ipaddr); + //printf("%s Q possible.(%s)\n",coin->symbol,ipaddr); queue_enqueue("possibleQ",&coin->possibleQ,queueitem(ipaddr),1); return((uint32_t)time(NULL)); } diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index 5cd83c761..7ee0be051 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -17,8 +17,9 @@ void iguana_RTramchainfree(struct iguana_info *coin,struct iguana_bundle *bp) { + return; +#ifdef ENABLE_RAMCHAIN int32_t hdrsi; -return; //portable_mutex_lock(&coin->RTmutex); if ( coin->utxotable != 0 ) { @@ -43,12 +44,14 @@ return; printf("done RTramchain\n"); } //portable_mutex_unlock(&coin->RTmutex); +#endif } void *iguana_ramchainfile(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_ramchain *dest,struct iguana_ramchain *R,struct iguana_bundle *bp,int32_t bundlei,struct iguana_block *block) { + return(0); +#ifdef ENABLE_RAMCHAIN char fname[1024]; long filesize; int32_t err; void *ptr=0; -return(0); if ( block == bp->blocks[bundlei] && (ptr= iguana_bundlefile(coin,fname,&filesize,bp,bundlei)) != 0 ) { if ( iguana_mapchaininit(fname,coin,R,bp,bundlei,block,ptr,filesize) >= 0 ) @@ -67,12 +70,14 @@ return(0); iguana_ramchain_free(coin,R,1); } //else printf("ramchainfile ptr.%p block.%p\n",ptr,block); return(0); +#endif } void iguana_RTramchainalloc(char *fname,struct iguana_info *coin,struct iguana_bundle *bp) { + return; +#ifdef ENABLE_RAMCHAIN uint32_t i,changed = 0; struct iguana_ramchaindata *rdata; struct iguana_ramchain *dest = &coin->RTramchain; struct iguana_blockRO *B; struct iguana_bundle *tmpbp; -return; //portable_mutex_lock(&coin->RTmutex); if ( (rdata= dest->H.data) != 0 ) { @@ -116,11 +121,13 @@ return; } } //portable_mutex_unlock(&coin->RTmutex); +#endif } void iguana_rdataset(struct iguana_ramchain *dest,struct iguana_ramchaindata *rdest,struct iguana_ramchain *src) { -return; + return; +#ifdef ENABLE_RAMCHAIN *dest = *src; dest->H.data = rdest; *rdest = *src->H.data; @@ -130,11 +137,13 @@ return; rdest->numunspents = src->H.unspentind; rdest->numspends = src->H.spendind; //printf("RT set numtxids.%u numspends.%u\n",rdest->numtxids,rdest->numspends); +#endif } void iguana_rdatarestore(struct iguana_ramchain *dest,struct iguana_ramchaindata *rdest,struct iguana_ramchain *src) { -return; + return; +#ifdef ENABLE_RAMCHAIN *src = *dest; *src->H.data = *rdest; src->pkind = rdest->numpkinds; @@ -143,12 +152,14 @@ return; src->H.unspentind = rdest->numunspents; src->H.spendind = rdest->numspends; printf("RT restore numtxids.%u numspends.%u\n",rdest->numtxids,rdest->numspends); +#endif } void iguana_RThdrs(struct iguana_info *coin,struct iguana_bundle *bp,int32_t numaddrs) { + return; +#ifdef ENABLE_RAMCHAIN int32_t datalen,i; uint8_t serialized[512]; char str[65]; struct iguana_peer *addr; -return; if ( coin->peers == 0 ) return; datalen = iguana_gethdrs(coin,serialized,coin->chain->gethdrsmsg,bits256_str(str,bp->hashes[0])); @@ -163,12 +174,14 @@ return; //addr->pendhdrs++; } } +#endif } void iguana_RTspendvectors(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp) { + return; +#ifdef ENABLE_RAMCHAIN int32_t iterate,lasti,num,hdrsi,orignumemit; struct iguana_ramchain R; struct iguana_ramchaindata RDATA; -return; if ( bp->hdrsi <= 0 ) return; printf("RTspendvectors [%d]\n",bp->hdrsi); @@ -212,14 +225,17 @@ return; //printf("iguana_balancegen [%d] (%d to %d)\n",bp->hdrsi,coin->RTstarti,(coin->RTheight-1)%bp->n); coin->RTstarti = coin->RTheight; } +#endif } int32_t iguana_realtime_update(struct supernet_info *myinfo,struct iguana_info *coin) { + return(0); +#ifdef ENABLE_RAMCHAIN double startmillis0; static double totalmillis0; static int32_t num0; struct iguana_bundle *bp; struct iguana_ramchaindata *rdata; int32_t offset,bundlei,i,n,flag=0; bits256 hash2,*ptr; struct iguana_peer *addr; struct iguana_block *block=0; struct iguana_blockRO *B; struct iguana_ramchain *dest=0,blockR; - //if ( coin->peers == 0 && coin->virtualchain == 0 ) + if ( coin->peers == 0 && coin->virtualchain == 0 ) return(0); offset = 0;//(strcmp("BTC",coin->symbol) != 0); if ( coin->RTheight >= (coin->current->hdrsi+1)*coin->chain->bundlesize ) @@ -245,7 +261,7 @@ int32_t iguana_realtime_update(struct supernet_info *myinfo,struct iguana_info * } if ( coin->spendvectorsaved <= 1 ) { -//printf("%s spendvectorsaved not yet\n",coin->symbol); + //printf("%s spendvectorsaved not yet\n",coin->symbol); usleep(100000); return(0); } @@ -278,10 +294,10 @@ int32_t iguana_realtime_update(struct supernet_info *myinfo,struct iguana_info * coin->lastRTheight = coin->RTheight = 0; iguana_utxoaddrs_purge(coin); /*while ( coin->spendvectorsaved <= 1 ) - { - fprintf(stderr,"wait for spendvectorsaved\n"); - sleep(3); - }*/ + { + fprintf(stderr,"wait for spendvectorsaved\n"); + sleep(3); + }*/ return(0); } if ( coin->RTdatabad == 0 && bp->hdrsi >= (coin->longestchain/coin->chain->bundlesize)-1 && bp->hdrsi >= coin->balanceswritten-2 && ((coin->RTheight < coin->blocks.hwmchain.height-offset && time(NULL) > bp->lastRT) || time(NULL) > bp->lastRT+1) ) //coin->RTheight >= bp->bundleheight && coin->RTheight < bp->bundleheight+bp->n && @@ -443,4 +459,5 @@ int32_t iguana_realtime_update(struct supernet_info *myinfo,struct iguana_info * //portable_mutex_unlock(&coin->RTmutex); } return(flag); +#endif } diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index adc6edf8c..ffd3e2726 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -1423,7 +1423,7 @@ int32_t iguana_reqhdrs(struct iguana_info *coin) queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(hashstr),1); if ( bp == coin->current ) { - printf("issue HWM HDRS %d\n",coin->blocks.hwmchain.height); + printf("%s issue HWM HDRS %d\n",coin->symbol,coin->blocks.hwmchain.height); init_hexbytes_noT(hashstr,coin->blocks.hwmchain.RO.hash2.bytes,sizeof(bits256)); queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(hashstr),1); } @@ -1662,9 +1662,12 @@ int32_t iguana_processrecv(struct supernet_info *myinfo,struct iguana_info *coin { fprintf(stderr,"%s call balanceflush\n",coin->symbol); //portable_mutex_lock(&coin->RTmutex); + coin->disableUTXO = 1; + iguana_utxoupdate(coin,-1,0,0,0,0,-1,0); // free hashtables if ( iguana_balanceflush(myinfo,coin,coin->balanceflush) > 0 ) printf("balanceswritten.%d flushed coin->balanceflush %d vs %d coin->longestchain/coin->chain->bundlesize\n",coin->balanceswritten,coin->balanceflush,coin->longestchain/coin->chain->bundlesize); //portable_mutex_unlock(&coin->RTmutex); + coin->disableUTXO = 0; fprintf(stderr,"%s back balanceflush\n",coin->symbol); coin->balanceflush = 0; //iguana_utxoaddr_gen(myinfo,coin,(coin->balanceswritten - 1) * coin->chain->bundlesize); diff --git a/iguana/iguana_spendvectors.c b/iguana/iguana_spendvectors.c index 1ad1e7430..e220be245 100755 --- a/iguana/iguana_spendvectors.c +++ b/iguana/iguana_spendvectors.c @@ -449,9 +449,9 @@ int32_t iguana_balancegen(struct iguana_info *coin,int32_t incremental,struct ig struct iguana_spendvector *spend; struct iguana_unspent *spentU,*u,*U; struct iguana_spendvector *Xspendinds; struct iguana_txid *T; struct iguana_blockRO *B; struct iguana_bundle *spentbp; struct iguana_utxoaddr *utxoaddr; struct iguana_pkhash *P; int32_t spent_hdrsi,spendind,n,numXspends,errs=0,emit=0; struct iguana_spend *S,*s; - if ( (starti % coin->chain->bundlesize) != 0 || (endheight % coin->chain->bundlesize) != coin->chain->bundlesize-1 ) + /*if ( (starti % coin->chain->bundlesize) != 0 || (endheight % coin->chain->bundlesize) != coin->chain->bundlesize-1 ) ramchain = &coin->RTramchain; - else ramchain = &bp->ramchain; + else*/ ramchain = &bp->ramchain; starti %= coin->chain->bundlesize; if ( (rdata= ramchain->H.data) == 0 || (n= rdata->numspends) < 1 ) return(-1); @@ -500,7 +500,7 @@ int32_t iguana_balancegen(struct iguana_info *coin,int32_t incremental,struct ig } if ( 0 && bp == coin->current ) printf("starti.%d txidind.%d txi.%d numvins.%d spendind.%d\n",i,txidind,j,T[txidind].numvins,spendind); - if ( ramchain == &coin->RTramchain ) + if ( bp == coin->current )//ramchain == &coin->RTramchain ) { for (k=0; k= 0 && height < coin->chain->bundlesize*coin->bundlescount && (bp= coin->bundles[height / coin->chain->bundlesize]) != 0 ) { - ramchain = (bp == coin->current) ? &coin->RTramchain : &bp->ramchain; - if ( ((rdata= ramchain->H.data) != 0 || ((bp == coin->current && (rdata= coin->RTramchain.H.data) != 0))) && i < tx->numvins ) + ramchain = &bp->ramchain;//(bp == coin->current) ? &coin->RTramchain : &bp->ramchain; + if ( ((rdata= ramchain->H.data) != 0 || ((bp == coin->current && (rdata= ramchain->H.data) != 0))) && i < tx->numvins ) //if ( (rdata= ramchain->H.data) != 0 && i < rdata->numspends ) { S = RAMCHAIN_PTR(rdata,Soffset); @@ -125,8 +125,8 @@ int32_t iguana_voutset(struct iguana_info *coin,uint8_t *scriptspace,char *asmst memset(vout,0,sizeof(*vout)); if ( height >= 0 && height < coin->chain->bundlesize*coin->bundlescount && (bp= coin->bundles[height / coin->chain->bundlesize]) != 0 ) { - ramchain = (bp == coin->current) ? &coin->RTramchain : &bp->ramchain; - if ( ((rdata= ramchain->H.data) != 0 || ((bp == coin->current && (rdata= coin->RTramchain.H.data) != 0))) && i < tx->numvouts ) + ramchain = &bp->ramchain;//(bp == coin->current) ? &coin->RTramchain : &bp->ramchain; + if ( ((rdata= ramchain->H.data) != 0 || ((bp == coin->current && (rdata= ramchain->H.data) != 0))) && i < tx->numvouts ) { U = RAMCHAIN_PTR(rdata,Uoffset); P = RAMCHAIN_PTR(rdata,Poffset); @@ -239,8 +239,12 @@ int32_t iguana_peerblockrequest(struct iguana_info *coin,uint8_t *blockspace,int struct iguana_txid *tx,T; bits256 checktxid; int32_t i,len,total,bundlei=-2; struct iguana_block *block; struct iguana_msgblock msgB; bits256 *tree,checkhash2,merkle_root; struct iguana_bundle *bp=0; long tmp; char str[65]; struct iguana_ramchaindata *rdata; if ( (bp= iguana_bundlefind(coin,&bp,&bundlei,hash2)) != 0 && bundlei >= 0 && bundlei < bp->n ) { - if ( (rdata= bp->ramchain.H.data) == 0 && bp == coin->current ) - rdata = coin->RTramchain.H.data; + if ( (rdata= bp->ramchain.H.data) == 0 )//&& bp == coin->current ) + { + printf("no ramchain data [%d]\n",bp->hdrsi); + //rdata = coin->RTramchain.H.data; + return(-1); + } if ( (block= bp->blocks[bundlei]) != 0 && rdata != 0 ) { iguana_blockunconv(coin->chain->zcash,coin->chain->auxpow,&msgB,block,0); diff --git a/iguana/iguana_txidfind.c b/iguana/iguana_txidfind.c index b7d3397d4..7cc3b2c20 100755 --- a/iguana/iguana_txidfind.c +++ b/iguana/iguana_txidfind.c @@ -280,7 +280,7 @@ struct iguana_txid *iguana_txidfind(struct iguana_info *coin,int32_t *heightp,st { if ( (bp= coin->bundles[i]) != 0 && (bp == coin->current || bp->emitfinish > 1) ) { - ramchain = (bp == coin->current) ? &coin->RTramchain : &bp->ramchain; + ramchain = &bp->ramchain;//(bp == coin->current) ? &coin->RTramchain : &bp->ramchain; if ( (rdata= ramchain->H.data) != 0 ) { if ( (TXbits= ramchain->txbits) == 0 ) diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 46214d94e..8c6598313 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -26,10 +26,11 @@ int32_t iguana_unspentind2txid(struct supernet_info *myinfo,struct iguana_info * struct iguana_ramchaindata *rdata=0; struct iguana_bundle *bp=0; struct iguana_unspent *U,*u; struct iguana_txid *T,*t; *voutp = *spentheightp = -1; memset(txidp,0,sizeof(*txidp)); - if ( hdrsi == coin->bundlescount-1 ) - rdata = coin->RTramchain.H.data; - else if ( (bp= coin->bundles[hdrsi]) != 0 ) - rdata = bp->ramchain.H.data; + //if ( hdrsi == coin->bundlescount-1 ) + // rdata = coin->RTramchain.H.data; + //else if ( (bp= coin->bundles[hdrsi]) != 0 ) + bp = coin->bundles[hdrsi]; + rdata = bp->ramchain.H.data; while ( rdata != 0 && unspentind > 0 && unspentind < rdata->numunspents ) { U = RAMCHAIN_PTR(rdata,Uoffset); @@ -116,7 +117,7 @@ int32_t iguana_unspentindfind(struct supernet_info *myinfo,struct iguana_info *c { RTspend = 0; flag++; - if ( iguana_spentflag(myinfo,coin,&RTspend,&spentheight,bp == coin->current ? &coin->RTramchain : &bp->ramchain,bp->hdrsi,unspentind,0,1,coin->longestchain,U[unspentind].value) == 0 ) // + if ( iguana_spentflag(myinfo,coin,&RTspend,&spentheight,&bp->ramchain,bp->hdrsi,unspentind,0,1,coin->longestchain,U[unspentind].value) == 0 ) //bp == coin->current ? &coin->RTramchain : { if ( valuep != 0 ) *valuep = U[unspentind].value; @@ -809,7 +810,7 @@ int32_t iguana_uvaltxid(struct supernet_info *myinfo,bits256 *txidp,struct iguan struct iguana_bundle *bp; struct iguana_unspent *U,*u; struct iguana_txid *T; struct iguana_ramchain *ramchain; struct iguana_ramchaindata *rdata; if ( (bp= coin->bundles[hdrsi]) == 0 ) return(-1); - ramchain = (bp == coin->current) ? &coin->RTramchain : &bp->ramchain; + ramchain = &bp->ramchain;//(bp == coin->current) ? &coin->RTramchain : &bp->ramchain; if ( (rdata= ramchain->H.data) != 0 ) { U = RAMCHAIN_PTR(rdata,Uoffset); @@ -834,7 +835,7 @@ int64_t iguana_unspentavail(struct supernet_info *myinfo,struct iguana_info *coi return(-1); hdrsi = (int16_t)(hdrsi_unspentind >> 32); unspentind = (uint32_t)hdrsi_unspentind; - ramchain = (bp == coin->current) ? &coin->RTramchain : &bp->ramchain; + ramchain = &bp->ramchain;//(bp == coin->current) ? &coin->RTramchain : &bp->ramchain; if ( (rdata= ramchain->H.data) == 0 ) return(0); if ( (spentflag= iguana_spentflag(myinfo,coin,&RTspend,&spentheight,ramchain,hdrsi,unspentind,0,minconf,maxconf,0)) > 0 ) diff --git a/iguana/iguana_volatiles.c b/iguana/iguana_volatiles.c index 5fe778ff6..0a7a1c1bd 100755 --- a/iguana/iguana_volatiles.c +++ b/iguana/iguana_volatiles.c @@ -55,6 +55,11 @@ int32_t iguana_utxoupdate(struct iguana_info *coin,int16_t spent_hdrsi,uint32_t } return(0); } + if ( coin->disableUTXO != 0 ) + { + printf("skip utxoupdate when disabled\n"); + return(0); + } uval = ((uint64_t)spent_hdrsi << 32) | spent_unspentind; pval = ((uint64_t)spent_hdrsi << 32) | spent_pkind; if ( (hhutxo= iguana_hhutxofind(coin,uval)) != 0 && hhutxo->u.spentflag != 0 ) @@ -93,9 +98,14 @@ struct iguana_utxo iguana_utxofind(struct iguana_info *coin,int16_t spent_hdrsi, uint64_t val,uval; struct iguana_hhutxo *hhutxo; struct iguana_utxo utxo; struct iguana_ramchain *ramchain; struct iguana_bundle *bp; struct iguana_ramchaindata *rdata; int32_t flag; *RTspendflagp = 0; memset(&utxo,0,sizeof(utxo)); + if ( coin->disableUTXO != 0 ) + { + printf("skip utxofind when disabled\n"); + return(utxo); + } if ( (bp= coin->bundles[spent_hdrsi]) == 0 ) return(utxo); - ramchain = (bp == coin->current) ? &coin->RTramchain : &bp->ramchain; + ramchain = &bp->ramchain;//(bp == coin->current) ? &coin->RTramchain : &bp->ramchain; if ( (rdata= ramchain->H.data) == 0 ) return(utxo); flag = (coin->RTheight > 0); @@ -157,6 +167,11 @@ int32_t iguana_spentflag(struct supernet_info *myinfo,struct iguana_info *coin,i uint32_t numunspents; int32_t RTspentflag; struct iguana_utxo utxo; uint64_t confs,RTspend = 0; struct iguana_ramchaindata *rdata; *spentheightp = -1; + if ( coin->disableUTXO != 0 ) + { + printf("skip spentflag when disabled\n"); + return(0); + } if ( (rdata= ramchain->H.data) == 0 ) return(0); numunspents = rdata->numunspents; @@ -185,6 +200,11 @@ int32_t iguana_spentflag(struct supernet_info *myinfo,struct iguana_info *coin,i int32_t iguana_volatileupdate(struct iguana_info *coin,int32_t incremental,struct iguana_ramchain *spentchain,int16_t spent_hdrsi,uint32_t spent_unspentind,uint32_t spent_pkind,uint64_t spent_value,uint32_t spendind,uint32_t fromheight) { struct iguana_account *A2; struct iguana_unspent *spentU; struct iguana_pkhash *spentP; struct iguana_ramchaindata *rdata; struct iguana_utxo *utxo; + if ( coin->disableUTXO != 0 ) + { + printf("skip volatileupdate when disabled\n"); + return(0); + } if ( (rdata= spentchain->H.data) != 0 ) { portable_mutex_lock(&coin->RTmutex); diff --git a/includes/iguana_structs.h b/includes/iguana_structs.h index 7b907e0c9..5798eb7c6 100755 --- a/includes/iguana_structs.h +++ b/includes/iguana_structs.h @@ -406,11 +406,12 @@ struct iguana_info portable_mutex_t peers_mutex,blocks_mutex,special_mutex,RTmutex; char changeaddr[64]; struct iguana_bundle *bundles[IGUANA_MAXBUNDLES],*current,*lastpending; - struct iguana_ramchain RTramchain; struct OS_memspace RTmem,RThashmem; bits256 RThash1; + //struct iguana_ramchain RTramchain; struct OS_memspace RTmem,RThashmem; + bits256 RThash1; int32_t numremain,numpendings,zcount,recvcount,bcount,pcount,lastbundle,numsaved,pendbalances,numverified,blockdepth; uint32_t recvtime,hdrstime,backstoptime,lastbundletime,numreqsent,numbundlesQ,lastbundleitime,lastdisp,RTgenesis,firstRTgenesis,RTstarti,idletime,stucktime,stuckmonitor,maxstuck,lastreqtime,RThdrstime,nextchecked,lastcheckpoint; double bandwidth,maxbandwidth,backstopmillis; bits256 backstophash2; int64_t spaceused; - int32_t initialheight,mapflags,minconfirms,numrecv,bindsock,isRT,backstop,blocksrecv,merging,polltimeout,numreqtxids,allhashes,balanceflush,basilisk_busy; bits256 reqtxids[64]; + int32_t disableUTXO,initialheight,mapflags,minconfirms,numrecv,bindsock,isRT,backstop,blocksrecv,merging,polltimeout,numreqtxids,allhashes,balanceflush,basilisk_busy; bits256 reqtxids[64]; void *launched,*started,*rpcloop; uint64_t bloomsearches,bloomhits,bloomfalse,collisions,txfee_perkb,txfee; uint8_t *blockspace; int32_t blockspacesize; struct OS_memspace blockMEM;