|
|
@ -1495,7 +1495,7 @@ struct iguana_ramchain *_iguana_ramchain_map(struct supernet_info *myinfo,struct |
|
|
|
return(0); |
|
|
|
} |
|
|
|
|
|
|
|
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) |
|
|
|
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 *retptr; |
|
|
|
#ifdef __PNACL__ |
|
|
@ -1503,7 +1503,7 @@ struct iguana_ramchain *iguana_ramchain_map(struct supernet_info *myinfo,struct |
|
|
|
//portable_mutex_lock(&mutex);
|
|
|
|
#endif |
|
|
|
ramchain->height = bp->bundleheight; |
|
|
|
retptr = _iguana_ramchain_map(myinfo,coin,fname,bp,numblocks,ramchain,hashmem,ipbits,hash2,prevhash2,bundlei,fpos,allocextras,expanded,coin->chain->zcash); |
|
|
|
retptr = _iguana_ramchain_map(myinfo,coin,fname,bp,numblocks,ramchain,hashmem,ipbits,hash2,prevhash2,bundlei,fpos,allocextras,expanded,zcash); |
|
|
|
#ifdef __PNACL__ |
|
|
|
//portable_mutex_unlock(&mutex);
|
|
|
|
#endif |
|
|
@ -1819,8 +1819,8 @@ 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) |
|
|
|
{ |
|
|
|
int32_t zcash=coin->chain->zcash,verifyflag = 1; |
|
|
|
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,hdrsi,subdir,firsti=1,err,flag,bundlei; uint32_t scriptspace,stackspace; struct iguana_blockRO RO; struct iguana_zblockRO zRO; |
|
|
|
int32_t zcash=0,verifyflag = 1; |
|
|
|
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,hdrsi,subdir,firsti=1,err,flag,bundlei; uint32_t scriptspace,stackspace; struct iguana_blockRO RO; |
|
|
|
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);
|
|
|
@ -1840,7 +1840,6 @@ long iguana_ramchain_data(struct supernet_info *myinfo,struct iguana_info *coin, |
|
|
|
block->issued = block->RO.recvlen = 0, block->fpos = -1; |
|
|
|
return(-1); |
|
|
|
} |
|
|
|
printf("ramchain data.(%s)\n",fname); |
|
|
|
if ( block != 0 ) |
|
|
|
{ |
|
|
|
RO = block->RO; |
|
|
@ -1854,7 +1853,6 @@ long iguana_ramchain_data(struct supernet_info *myinfo,struct iguana_info *coin, |
|
|
|
} |
|
|
|
fpos = -1; |
|
|
|
iguana_ramchain_link(ramchain,origtxdata->zblock.RO.hash2,bp->hdrsi,bp->bundleheight+bundlei,bundlei,1,firsti,0); |
|
|
|
printf("2 ramchain data.(%s)\n",fname); |
|
|
|
if ( (rdata= ramchain->H.data) != 0 ) |
|
|
|
{ |
|
|
|
_iguana_ramchain_setptrs(RAMCHAIN_PTRS,rdata); |
|
|
@ -1862,7 +1860,6 @@ long iguana_ramchain_data(struct supernet_info *myinfo,struct iguana_info *coin, |
|
|
|
char dirname[1024]; sprintf(dirname,"%s/%s/%d",GLOBAL_TMPDIR,coin->symbol,subdir), OS_ensure_directory(dirname); |
|
|
|
sprintf(dirname,"%s/%s/%d/%d",GLOBAL_TMPDIR,coin->symbol,subdir,bp->bundleheight), OS_ensure_directory(dirname); |
|
|
|
//printf("Kspace.%p bp.[%d:%d] <- scriptspace.%d expanded.%d\n",Kspace,bp->hdrsi,bundlei,scriptspace,ramchain->expanded);
|
|
|
|
printf("3 ramchain data.(%s)\n",fname); |
|
|
|
if ( T == 0 || U == 0 || S == 0 || B == 0 ) |
|
|
|
{ |
|
|
|
if ( block != 0 ) |
|
|
@ -1892,7 +1889,6 @@ long iguana_ramchain_data(struct supernet_info *myinfo,struct iguana_info *coin, |
|
|
|
} |
|
|
|
ramchain->H.spendind += tx->tx_in; |
|
|
|
} |
|
|
|
printf("4 ramchain data.(%s)\n",fname); |
|
|
|
//printf("scriptoffset.%d after %d txids\n",ramchain->H.scriptoffset,txn_count);
|
|
|
|
ramchain->H.txidind = ramchain->H.spendind = rdata->firsti; |
|
|
|
for (i=0; i<txn_count; i++,ramchain->H.txidind++) |
|
|
@ -1906,9 +1902,7 @@ long iguana_ramchain_data(struct supernet_info *myinfo,struct iguana_info *coin, |
|
|
|
rdata->prevhash2 = origtxdata->zblock.RO.prev_block; |
|
|
|
rdata->scriptspace = scriptspace = ramchain->H.scriptoffset; |
|
|
|
rdata->stackspace = stackspace = ramchain->H.stacksize; |
|
|
|
printf("5 ramchain data.(%s)\n",fname); |
|
|
|
iguana_ramchain_setsize(fname,ramchain,rdata,1,zcash); |
|
|
|
printf("6 ramchain data.(%s)\n",fname); |
|
|
|
flag = 0; |
|
|
|
if ( ramchain->H.txidind != rdata->numtxids || ramchain->H.unspentind != rdata->numunspents || ramchain->H.spendind != rdata->numspends ) |
|
|
|
{ |
|
|
@ -1922,17 +1916,13 @@ long iguana_ramchain_data(struct supernet_info *myinfo,struct iguana_info *coin, |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
printf("6b ramchain data.(%s)\n",fname); |
|
|
|
if ( (err= iguana_ramchain_verify(coin,ramchain)) == 0 ) |
|
|
|
{ |
|
|
|
printf("6c ramchain data.(%s) zcash.%d\n",fname,zcash); |
|
|
|
*B = RO; |
|
|
|
rdata->scriptspace = ramchain->H.scriptoffset = scriptspace; |
|
|
|
rdata->stackspace = ramchain->H.stacksize = stackspace; |
|
|
|
printf("7 ramchain data.(%s)\n",fname); |
|
|
|
if ( (fpos= (int32_t)iguana_ramchain_save(coin,RAMCHAIN_ARG,(uint32_t)addr->ipbits,RO.hash2,RO.prev_block,bundlei,0,zcash)) >= 0 ) |
|
|
|
{ |
|
|
|
printf("8 ramchain data.(%s)\n",fname); |
|
|
|
origtxdata->datalen = (int32_t)rdata->allocsize; |
|
|
|
//char str[65]; printf("saved.%s [%d:%d] fpos.%d datalen.%d\n",bits256_str(str,block->RO.hash2),bp->hdrsi,bundlei,fpos,origtxdata->datalen);
|
|
|
|
ramchain->H.ROflag = 0; |
|
|
@ -1943,8 +1933,8 @@ long iguana_ramchain_data(struct supernet_info *myinfo,struct iguana_info *coin, |
|
|
|
fflush(addr->vinsfp); |
|
|
|
memset(&R,0,sizeof(R)); |
|
|
|
//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)
|
|
|
|
printf("myinfo.%p coin.%p (%s) fpos.%d\n",myinfo,coin,fname,(uint32_t)fpos); |
|
|
|
if ( verifyflag != 0 && (mapchain= iguana_ramchain_map(myinfo,coin,fname,0,1,&R,&addr->HASHMEM,(uint32_t)1234,RO.hash2,RO.prev_block,bundlei,fpos,0,0)) == 0 ) |
|
|
|
printf("myinfo.%p coin.%p addr.%p (%s) fpos.%d\n",myinfo,coin,addr,fname,(uint32_t)fpos); |
|
|
|
if ( verifyflag != 0 && (mapchain= iguana_ramchain_map(myinfo,coin,fname,0,1,&R,&addr->HASHMEM,(uint32_t)1234,RO.hash2,RO.prev_block,bundlei,fpos,0,0,zcash)) == 0 ) |
|
|
|
{ |
|
|
|
printf("delete unverified [%d:%d]\n",bp->hdrsi,bundlei); |
|
|
|
iguana_ramchain_free(coin,&R,1); |
|
|
@ -2197,7 +2187,7 @@ void iguana_bundlemapfree(struct iguana_info *coin,struct OS_memspace *mem,struc |
|
|
|
|
|
|
|
int32_t iguana_ramchain_expandedsave(struct supernet_info *myinfo,struct iguana_info *coin,RAMCHAIN_FUNC,struct iguana_ramchain *newchain,struct OS_memspace *hashmem,int32_t cmpflag,struct iguana_bundle *bp) |
|
|
|
{ |
|
|
|
static const bits256 zero; |
|
|
|
static const bits256 zero; uint8_t zcash = 0; |
|
|
|
bits256 firsthash2; int32_t err,bundlei,hdrsi,numblocks,firsti,height,retval= -1; struct iguana_ramchain checkR,*mapchain; char fname[1024]; struct iguana_block *block; uint32_t scriptspace,scriptoffset,stacksize; uint8_t *destoffset,*srcoffset; struct iguana_ramchaindata *rdata; |
|
|
|
if ( (rdata= ramchain->H.data) == 0 ) |
|
|
|
return(-1); |
|
|
@ -2219,7 +2209,7 @@ int32_t iguana_ramchain_expandedsave(struct supernet_info *myinfo,struct iguana_ |
|
|
|
rdata->prevhash2 = block->RO.prev_block; |
|
|
|
rdata->scriptspace = scriptoffset; |
|
|
|
ramchain->H.stacksize = rdata->stackspace = stacksize; |
|
|
|
iguana_ramchain_setsize(fname,ramchain,rdata,bp->n,coin->chain->zcash); |
|
|
|
iguana_ramchain_setsize(fname,ramchain,rdata,bp->n,zcash); |
|
|
|
//printf("Apresave T.%d U.%d S.%d P.%d X.%d -> size.%ld firsti.%d scriptoffset.%d stacksize.%d\n",rdata->numtxids,rdata->numunspents,rdata->numspends,rdata->numpkinds,rdata->numexternaltxids,(long)rdata->allocsize,firsti,ramchain->H.scriptoffset,ramchain->H.stacksize);
|
|
|
|
*newchain = *ramchain; |
|
|
|
//memcpy(ramchain->roU2,ramchain->U2,sizeof(*ramchain->U2) * rdata->numunspents);
|
|
|
@ -2243,7 +2233,7 @@ int32_t iguana_ramchain_expandedsave(struct supernet_info *myinfo,struct iguana_ |
|
|
|
ramchain->H.scriptoffset = scriptoffset; |
|
|
|
rdata->scriptspace = scriptoffset; |
|
|
|
ramchain->H.stacksize = rdata->stackspace = stacksize; |
|
|
|
if ( iguana_ramchain_save(coin,RAMCHAIN_ARG,0,firsthash2,zero,0,bp,coin->chain->zcash) < 0 ) |
|
|
|
if ( iguana_ramchain_save(coin,RAMCHAIN_ARG,0,firsthash2,zero,0,bp,zcash) < 0 ) |
|
|
|
{ |
|
|
|
printf("ERROR saving ramchain hdrsi.%d, deleting and will regenerate\n",hdrsi); |
|
|
|
iguana_mempurge(hashmem); |
|
|
@ -2258,7 +2248,7 @@ int32_t iguana_ramchain_expandedsave(struct supernet_info *myinfo,struct iguana_ |
|
|
|
bundlei = 0; |
|
|
|
if ( cmpflag == 0 ) |
|
|
|
iguana_memreset(hashmem); |
|
|
|
if ( (mapchain= iguana_ramchain_map(myinfo,coin,fname,bp,numblocks,&checkR,cmpflag==0?hashmem:0,0,firsthash2,zero,bundlei,0,0,1)) != 0 ) |
|
|
|
if ( (mapchain= iguana_ramchain_map(myinfo,coin,fname,bp,numblocks,&checkR,cmpflag==0?hashmem:0,0,firsthash2,zero,bundlei,0,0,1,zcash)) != 0 ) |
|
|
|
{ |
|
|
|
iguana_ramchain_link(mapchain,firsthash2,hdrsi,height,0,numblocks,firsti,1); |
|
|
|
iguana_ramchain_extras(myinfo,coin,mapchain,hashmem,0); |
|
|
@ -2290,13 +2280,13 @@ int32_t iguana_ramchain_expandedsave(struct supernet_info *myinfo,struct iguana_ |
|
|
|
|
|
|
|
struct iguana_ramchain *iguana_bundleload(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_ramchain *ramchain,struct iguana_bundle *bp,int32_t extraflag) |
|
|
|
{ |
|
|
|
static const bits256 zero; |
|
|
|
static const bits256 zero; uint8_t zcash = 0; |
|
|
|
struct iguana_blockRO *B; struct iguana_txid *T; int32_t i,firsti = 1; char fname[512]; |
|
|
|
struct iguana_block *block,*prev,*prev2; struct iguana_ramchain *mapchain; struct iguana_ramchaindata *rdata; uint32_t firsttxidind; |
|
|
|
if ( bp->emitfinish > 1 ) |
|
|
|
return(ramchain); |
|
|
|
memset(ramchain,0,sizeof(*ramchain)); |
|
|
|
if ( (mapchain= iguana_ramchain_map(myinfo,coin,fname,bp,bp->n,ramchain,0,0,bp->hashes[0],zero,0,0,extraflag,1)) != 0 ) |
|
|
|
if ( (mapchain= iguana_ramchain_map(myinfo,coin,fname,bp,bp->n,ramchain,0,0,bp->hashes[0],zero,0,0,extraflag,1,zcash)) != 0 ) |
|
|
|
{ |
|
|
|
iguana_ramchain_link(mapchain,bp->hashes[0],bp->hdrsi,bp->bundleheight,0,bp->n,firsti,1); |
|
|
|
//char str[65]; printf("%s bp.%d: T.%d U.%d S.%d P%d X.%d MAPPED %s %p\n",coin->symbol,bp->hdrsi,mapchain->H.data->numtxids,mapchain->H.data->numunspents,mapchain->H.data->numspends,mapchain->H.data->numpkinds,mapchain->H.data->numexternaltxids,mbstr(str,mapchain->H.data->allocsize),mapchain->H.data);
|
|
|
@ -2323,7 +2313,7 @@ struct iguana_ramchain *iguana_bundleload(struct supernet_info *myinfo,struct ig |
|
|
|
block->hdrsi = bp->hdrsi; |
|
|
|
block->bundlei = i; |
|
|
|
block->fpipbits = (uint32_t)calc_ipbits("127.0.0.1"); |
|
|
|
iguana_blockzcopyRO(coin->chain->zcash,&block->RO,0,B,i); |
|
|
|
iguana_blockzcopyRO(zcash,&block->RO,0,B,i); |
|
|
|
//printf("%x ",(int32_t)B[i].hash2.ulongs[3]);
|
|
|
|
bp->blocks[i] = block; |
|
|
|
bp->hashes[i] = block->RO.hash2; |
|
|
@ -2369,7 +2359,7 @@ struct iguana_ramchain *iguana_bundleload(struct supernet_info *myinfo,struct ig |
|
|
|
|
|
|
|
int64_t iguana_ramchainopen(struct supernet_info *myinfo,char *fname,struct iguana_info *coin,struct iguana_ramchain *ramchain,struct OS_memspace *mem,struct OS_memspace *hashmem,int32_t bundleheight,bits256 hash2) |
|
|
|
{ |
|
|
|
RAMCHAIN_DECLARE; RAMCHAIN_ZEROES; int32_t i,numblocks = coin->chain->bundlesize; uint32_t numtxids,numunspents,numspends,numpkinds,numexternaltxids,scriptspace; struct iguana_bundle *bp; struct iguana_ramchaindata *rdata=0; int64_t hashsize,allocsize; |
|
|
|
RAMCHAIN_DECLARE; RAMCHAIN_ZEROES; uint8_t zcash = 0; int32_t i,numblocks = coin->chain->bundlesize; uint32_t numtxids,numunspents,numspends,numpkinds,numexternaltxids,scriptspace; struct iguana_bundle *bp; struct iguana_ramchaindata *rdata=0; int64_t hashsize,allocsize; |
|
|
|
//B = 0, Ux = 0, Sx = 0, P = 0, A = 0, X = 0, Kspace = TXbits = PKbits = 0, U = 0, S = 0, T = 0;
|
|
|
|
mem->alignflag = sizeof(uint32_t); |
|
|
|
hashmem->alignflag = sizeof(uint32_t); |
|
|
@ -2397,7 +2387,7 @@ int64_t iguana_ramchainopen(struct supernet_info *myinfo,char *fname,struct igua |
|
|
|
//#endif
|
|
|
|
if ( mem->ptr == 0 ) |
|
|
|
{ |
|
|
|
while ( (allocsize= _iguana_rdata_action(fname,0,0,0,0,1,numtxids,numunspents,numspends,numpkinds,numexternaltxids,scriptspace,0,0,0,0,0,RAMCHAIN_ARG,numblocks,coin->chain->zcash)) > 2*1024LL*1024L*1024L ) |
|
|
|
while ( (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)) > 2*1024LL*1024L*1024L ) |
|
|
|
{ |
|
|
|
numtxids *= .9; |
|
|
|
numunspents *= .9; |
|
|
@ -2414,7 +2404,7 @@ int64_t iguana_ramchainopen(struct supernet_info *myinfo,char *fname,struct igua |
|
|
|
iguana_meminit(hashmem,coin->symbol,0,hashsize + 65536*3,0); |
|
|
|
printf("%s hash meminit %lld\n",coin->symbol,(long long)hashmem->totalsize); |
|
|
|
} |
|
|
|
if ( iguana_ramchain_init(fname,ramchain,mem,hashmem,1,numtxids,numunspents,numspends,numpkinds,numexternaltxids,scriptspace,1,numblocks,coin->chain->zcash) > 0 ) |
|
|
|
if ( iguana_ramchain_init(fname,ramchain,mem,hashmem,1,numtxids,numunspents,numspends,numpkinds,numexternaltxids,scriptspace,1,numblocks,zcash) > 0 ) |
|
|
|
{ |
|
|
|
iguana_ramchain_link(ramchain,hash2,bundleheight/coin->chain->bundlesize,bundleheight,0,0,1,0); |
|
|
|
ramchain->expanded = 1; |
|
|
@ -2430,7 +2420,7 @@ int64_t iguana_ramchainopen(struct supernet_info *myinfo,char *fname,struct igua |
|
|
|
|
|
|
|
int32_t iguana_mapchaininit(char *fname,struct iguana_info *coin,struct iguana_ramchain *mapchain,struct iguana_bundle *bp,int32_t bundlei,struct iguana_block *block,void *ptr,long filesize) |
|
|
|
{ |
|
|
|
int32_t firsti = 1; RAMCHAIN_DECLARE; |
|
|
|
int32_t firsti = 1; RAMCHAIN_DECLARE; uint8_t zcash = 0; |
|
|
|
memset(mapchain,0,sizeof(*mapchain)); |
|
|
|
mapchain->fileptr = ptr; |
|
|
|
mapchain->filesize = filesize; |
|
|
@ -2442,9 +2432,9 @@ int32_t iguana_mapchaininit(char *fname,struct iguana_info *coin,struct iguana_r |
|
|
|
return(-1); |
|
|
|
} |
|
|
|
_iguana_ramchain_setptrs(MAPCHAIN_PTRS,mapchain->H.data); |
|
|
|
if ( block->fpos+mapchain->H.data->allocsize > filesize || iguana_ramchain_size(fname,MAPCHAIN_ARG,1,mapchain->H.data->scriptspace,coin->chain->zcash) != mapchain->H.data->allocsize ) |
|
|
|
if ( block->fpos+mapchain->H.data->allocsize > filesize || iguana_ramchain_size(fname,MAPCHAIN_ARG,1,mapchain->H.data->scriptspace,zcash) != mapchain->H.data->allocsize ) |
|
|
|
{ |
|
|
|
printf("iguana_mapchaininit.%d ipbits.%x size mismatch %ld vs %ld vs filesize.%ld fpos.%ld bundlei.%d expanded.%d soff.%d\n",bp->bundleheight,block->fpipbits,(long)iguana_ramchain_size(fname,MAPCHAIN_ARG,1,mapchain->H.data->scriptspace,coin->chain->zcash),(long)mapchain->H.data->allocsize,(long)filesize,(long)block->fpos,bundlei,mapchain->expanded,mapchain->H.data->scriptspace); |
|
|
|
printf("iguana_mapchaininit.%d ipbits.%x size mismatch %ld vs %ld vs filesize.%ld fpos.%ld bundlei.%d expanded.%d soff.%d\n",bp->bundleheight,block->fpipbits,(long)iguana_ramchain_size(fname,MAPCHAIN_ARG,1,mapchain->H.data->scriptspace,zcash),(long)mapchain->H.data->allocsize,(long)filesize,(long)block->fpos,bundlei,mapchain->expanded,mapchain->H.data->scriptspace); |
|
|
|
//getchar();
|
|
|
|
return(-1); |
|
|
|
} |
|
|
@ -2462,7 +2452,7 @@ int32_t iguana_mapchaininit(char *fname,struct iguana_info *coin,struct iguana_r |
|
|
|
// helper threads: NUM_HELPERS
|
|
|
|
int32_t iguana_bundlesaveHT(struct supernet_info *myinfo,struct iguana_info *coin,struct OS_memspace *mem,struct OS_memspace *memB,struct iguana_bundle *bp,uint32_t starttime) // helper thread
|
|
|
|
{ |
|
|
|
static int depth; |
|
|
|
static int depth; uint8_t zcash = 0; |
|
|
|
RAMCHAIN_DESTDECLARE; RAMCHAIN_DECLARE; RAMCHAIN_ZEROES; |
|
|
|
void **ptrs; long *filesizes; uint32_t *ipbits; char fname[1024]; |
|
|
|
struct iguana_ramchain *R,*mapchain,*dest,newchain; uint32_t fpipbits; bits256 prevhash2; |
|
|
@ -2545,7 +2535,7 @@ int32_t iguana_bundlesaveHT(struct supernet_info *myinfo,struct iguana_info *coi |
|
|
|
numexternaltxids = numspends; |
|
|
|
//printf("E.%d depth.%d start bundle ramchain %d at %u started.%u lag.%d\n",coin->numemitted,depth,bp->bundleheight,now,starttime,now-starttime);
|
|
|
|
depth++; |
|
|
|
if ( iguana_ramchain_alloc(fname,coin,dest,mem,&HASHMEM,numtxids,numunspents,numspends,numpkinds,numexternaltxids,scriptspace+sigspace,bp->bundleheight+starti,bp_n,coin->chain->zcash) < 0 ) |
|
|
|
if ( iguana_ramchain_alloc(fname,coin,dest,mem,&HASHMEM,numtxids,numunspents,numspends,numpkinds,numexternaltxids,scriptspace+sigspace,bp->bundleheight+starti,bp_n,zcash) < 0 ) |
|
|
|
{ |
|
|
|
printf("error iguana_ramchain_alloc for bundleheight.%d\n",bp->bundleheight); |
|
|
|
iguana_bundlemapfree(coin,mem,&HASHMEM,ipbits,ptrs,filesizes,num,R,starti,endi); |
|
|
@ -2574,7 +2564,7 @@ int32_t iguana_bundlesaveHT(struct supernet_info *myinfo,struct iguana_info *coi |
|
|
|
iguana_blockunmark(coin,block,bp,i,1); |
|
|
|
return(-1); |
|
|
|
} |
|
|
|
iguana_blockzcopyRO(coin->chain->zcash,destB,i,&block->RO,0); |
|
|
|
iguana_blockzcopyRO(zcash,destB,i,&block->RO,0); |
|
|
|
//destB[i] = block->RO;
|
|
|
|
} else printf("bundlesave error getting block (%d:%d) %p vs %p\n",bp->hdrsi,i,block,bp->blocks[i]); |
|
|
|
} |
|
|
@ -2589,7 +2579,7 @@ int32_t iguana_bundlesaveHT(struct supernet_info *myinfo,struct iguana_info *coi |
|
|
|
{ |
|
|
|
iguana_blocksetcounters(coin,block,dest); |
|
|
|
//coin->blocks.RO[bp->bundleheight+bundlei] = block->RO;
|
|
|
|
iguana_blockzcopyRO(coin->chain->zcash,destB,bundlei,&block->RO,0); |
|
|
|
iguana_blockzcopyRO(zcash,destB,bundlei,&block->RO,0); |
|
|
|
//destB[bundlei] = block->RO;
|
|
|
|
//fprintf(stderr,"(%d %d).%d ",R[bundlei].H.data->numtxids,dest->H.txidind,bundlei);
|
|
|
|
if ( (err= iguana_ramchain_iterate(myinfo,coin,dest,&R[bundlei],bp,bundlei)) != 0 ) |
|
|
@ -2670,7 +2660,7 @@ void iguana_mergefree(struct iguana_info *coin,struct OS_memspace *mem,struct ig |
|
|
|
|
|
|
|
int32_t iguana_bundlemergeHT(struct supernet_info *myinfo,char *fname,struct iguana_info *coin,struct OS_memspace *mem,struct OS_memspace *memB,struct iguana_bundle *bp,struct iguana_bundle *nextbp,uint32_t starttime) |
|
|
|
{ |
|
|
|
static int32_t depth; static const bits256 zero; |
|
|
|
static int32_t depth; static const bits256 zero; uint8_t zcash = 0; |
|
|
|
RAMCHAIN_DESTDECLARE; struct OS_memspace HASHMEM,HASHMEMA,HASHMEMB; |
|
|
|
uint32_t now = (uint32_t)time(NULL); char str[65],fnameA[1024],fnameB[1024]; |
|
|
|
struct iguana_ramchain _Achain,_Bchain,*A,*B,R,newchain,*dest = &R; int32_t err,retval = -1,firsti = 1; |
|
|
@ -2681,11 +2671,11 @@ int32_t iguana_bundlemergeHT(struct supernet_info *myinfo,char *fname,struct igu |
|
|
|
iguana_meminit(&HASHMEMB,"hashmemB",0,iguana_hashmemsize(nextbp->ramchain.H.txidind,nextbp->ramchain.H.unspentind,nextbp->ramchain.H.spendind,nextbp->ramchain.pkind,nextbp->ramchain.externalind,nextbp->ramchain.H.data->scriptspace) + IGUANA_MAXSCRIPTSIZE,0); |
|
|
|
memset(&_Achain,0,sizeof(_Achain)); A = &_Achain; |
|
|
|
memset(&_Bchain,0,sizeof(_Bchain)); B = &_Bchain; |
|
|
|
if ( (A= iguana_ramchain_map(myinfo,coin,fnameA,bp,bp->ramchain.numblocks,A,&HASHMEMA,0,bp->hashes[0],zero,0,0,1,1)) != 0 ) |
|
|
|
if ( (A= iguana_ramchain_map(myinfo,coin,fnameA,bp,bp->ramchain.numblocks,A,&HASHMEMA,0,bp->hashes[0],zero,0,0,1,1,zcash)) != 0 ) |
|
|
|
{ |
|
|
|
iguana_ramchain_link(A,bp->hashes[0],bp->hdrsi,bp->bundleheight,0,bp->ramchain.numblocks,firsti,1); |
|
|
|
} |
|
|
|
if ( (B= iguana_ramchain_map(myinfo,coin,fnameB,bp,nextbp->ramchain.numblocks,B,&HASHMEMB,0,nextbp->hashes[0],zero,0,0,1,1)) != 0 ) |
|
|
|
if ( (B= iguana_ramchain_map(myinfo,coin,fnameB,bp,nextbp->ramchain.numblocks,B,&HASHMEMB,0,nextbp->hashes[0],zero,0,0,1,1,zcash)) != 0 ) |
|
|
|
{ |
|
|
|
iguana_ramchain_link(B,bp->hashes[0],nextbp->hdrsi,nextbp->bundleheight,0,nextbp->ramchain.numblocks,firsti,1); |
|
|
|
} |
|
|
@ -2697,7 +2687,7 @@ int32_t iguana_bundlemergeHT(struct supernet_info *myinfo,char *fname,struct igu |
|
|
|
} |
|
|
|
if ( A->H.data != 0 && B->H.data != 0 && B->height == A->height+A->numblocks ) |
|
|
|
{ |
|
|
|
if ( iguana_ramchain_alloc(fname,coin,dest,mem,&HASHMEM,(A->H.data->numtxids+B->H.data->numtxids),(A->H.data->numunspents+B->H.data->numunspents),(A->H.data->numspends+B->H.data->numspends),(A->H.data->numpkinds+B->H.data->numpkinds),(A->H.data->numexternaltxids+B->H.data->numexternaltxids),A->H.data->scriptspace,A->height,A->numblocks + B->numblocks,coin->chain->zcash) < 0 ) |
|
|
|
if ( iguana_ramchain_alloc(fname,coin,dest,mem,&HASHMEM,(A->H.data->numtxids+B->H.data->numtxids),(A->H.data->numunspents+B->H.data->numunspents),(A->H.data->numspends+B->H.data->numspends),(A->H.data->numpkinds+B->H.data->numpkinds),(A->H.data->numexternaltxids+B->H.data->numexternaltxids),A->H.data->scriptspace,A->height,A->numblocks + B->numblocks,zcash) < 0 ) |
|
|
|
{ |
|
|
|
printf("depth.%d ht.%d fsize.%s ERROR alloc lag.%d elapsed.%d\n",depth,dest->height,mbstr(str,dest->H.data->allocsize),now-starttime,(int32_t)(time(NULL)-now)); |
|
|
|
iguana_mergefree(coin,mem,A,B,&HASHMEM,&HASHMEMA,&HASHMEMB); |
|
|
|