Browse Source

test

olddPoW
jl777 8 years ago
parent
commit
73d058418e
  1. 2
      gecko/gecko_headers.c
  2. 4
      iguana/iguana_blocks.c
  3. 56
      iguana/iguana_bundles.c
  4. 2
      iguana/iguana_chains.c
  5. 24
      iguana/iguana_init.c
  6. 20
      iguana/iguana_ramchain.c
  7. 46
      iguana/iguana_recv.c
  8. 8
      iguana/iguana_spendvectors.c
  9. 2
      includes/iguana_structs.h

2
gecko/gecko_headers.c

@ -96,7 +96,7 @@ void gecko_requesthdrs(struct supernet_info *myinfo,struct iguana_info *virt,int
memset(zero.bytes,0,sizeof(zero));
jaddstr(vals,"symbol",virt->symbol);
jaddstr(vals,"type","HDR");
if ( (retstr= basilisk_standardservice("GET",myinfo,0,bp->hashes[0],vals,0,0)) != 0 )
if ( (retstr= basilisk_standardservice("GET",myinfo,0,bp->bundlehash2,vals,0,0)) != 0 )
free(retstr);
free_json(vals);
} else printf("dont have bundle needed\n");

4
iguana/iguana_blocks.c

@ -633,9 +633,9 @@ struct iguana_block *_iguana_chainlink(struct supernet_info *myinfo,struct iguan
{
if ( hdrsi < coin->bundlescount )
{
if ( (bp= coin->bundles[hdrsi]) != 0 && bits256_cmp(block->RO.hash2,bp->hashes[0]) != 0 )
if ( (bp= coin->bundles[hdrsi]) != 0 && bits256_cmp(block->RO.hash2,bp->bundlehash2) != 0 )
{
printf(">>>>>>>>>>>>>> interloper bundle.[%d] ht.%d %s != %s\n",hdrsi,block->height,bits256_str(str,bp->hashes[0]),bits256_str(str2,block->RO.hash2));
printf(">>>>>>>>>>>>>> interloper bundle.[%d] ht.%d %s != %s\n",hdrsi,block->height,bits256_str(str,bp->bundlehash2),bits256_str(str2,block->RO.hash2));
coin->bundles[hdrsi] = 0;
}
}

56
iguana/iguana_bundles.c

@ -75,10 +75,15 @@ struct iguana_bundle *iguana_bundlefind(struct iguana_info *coin,struct iguana_b
if ( bp == 0 )
{
for (i=coin->bundlescount-1; i>=0; i--)
//for (i=0; i<coin->bundlescount; i++)
{
if ( (bp= coin->bundles[i]) != 0 )
{
if ( bits256_cmp(bp->bundlehash2,hash2) == 0 )
{
*bpp = bp;
*bundleip = 0;
return(bp);
}
if ( iguana_bloomfind(coin,&bp->bloom,0,bit) == 0 )
{
*bpp = bp;
@ -87,7 +92,15 @@ struct iguana_bundle *iguana_bundlefind(struct iguana_info *coin,struct iguana_b
//printf("bloom miss\n");
coin->bloomfalse++;
} else return(bp);
} //else printf("no bloom\n");
}
else
{
if ( (*bundleip= iguana_bundlescan(coin,bp,hash2)) >= 0 )
{
*bpp = bp;
return(bp);
}
}
}
}
*bundleip = -2;
@ -146,7 +159,7 @@ int32_t iguana_hash2set(struct iguana_info *coin,char *debugstr,struct iguana_bu
{
char str2[65],str3[65];
bits256_str(str2,*orighash2p), bits256_str(str3,newhash2);
printf("WARNING iguana_hash2set overwrite %s [%s] %s with %s [%d:%d]\n",coin->symbol,debugstr,str2,str3,bp->hdrsi,bundlei);
printf("WARNING iguana_hash2set dont overwrite %s [%s] %s with %s [%d:%d]\n",coin->symbol,debugstr,str2,str3,bp->hdrsi,bundlei);
}
//*orighash2p = newhash2;
return(-1);
@ -228,7 +241,7 @@ int32_t iguana_bundlehash2add(struct iguana_info *coin,struct iguana_block **blo
{
if ( bundlei > 1 )
bundlei -= 2;
if ( bp->bundleheight+bundlei > coin->blocks.hwmchain.height && (block= iguana_blockfind("reset",coin,bp->hashes[0])) != 0 )
if ( bp->bundleheight+bundlei > coin->blocks.hwmchain.height && (block= iguana_blockfind("reset",coin,bp->bundlehash2)) != 0 )
{
iguana_blockzcopy(coin->chain->zcash,(void *)&coin->blocks.hwmchain,block);
printf("RESET HWM to %d ht.%d\n",bp->bundleheight+bundlei,block->height);
@ -294,16 +307,16 @@ int32_t iguana_bundlehash2add(struct iguana_info *coin,struct iguana_block **blo
{
if ( bundlei == 0 && (otherbundlei == -2 || otherbundlei == bundlesize-1) )
{
if ( otherbp != 0 && iguana_hash2set(coin,"blockadd0_prev",bp,-1,otherbp->hashes[0]) != 0 )
if ( otherbp != 0 && iguana_hash2set(coin,"blockadd0_prev",bp,-1,otherbp->bundlehash2) != 0 )
err |= 4;
if ( otherbp != 0 && iguana_hash2set(coin,"blockadd0_next",otherbp,bundlesize,bp->hashes[0]) != 0 )
if ( otherbp != 0 && iguana_hash2set(coin,"blockadd0_next",otherbp,bundlesize,bp->bundlehash2) != 0 )
err |= 8;
}
else if ( bundlei == bundlesize-1 && (otherbundlei == -2 || otherbundlei == 0) )
{
if ( otherbp != 0 && iguana_hash2set(coin,"blockaddL_prev",otherbp,-1,bp->hashes[0]) != 0 )
if ( otherbp != 0 && iguana_hash2set(coin,"blockaddL_prev",otherbp,-1,bp->bundlehash2) != 0 )
err |= 16;
if ( otherbp != 0 && iguana_hash2set(coin,"blockaddL_next",bp,bundlesize,otherbp->hashes[0]) != 0 )
if ( otherbp != 0 && iguana_hash2set(coin,"blockaddL_next",bp,bundlesize,otherbp->bundlehash2) != 0 )
err |= 32;
}
//else printf("blockadd warning: %d[%d] bloomfound %d[%d]\n",bp->hdrsi,bundlei,otherbp!=0?otherbp->hdrsi:-1,otherbundlei);
@ -334,6 +347,12 @@ int32_t iguana_bundlehash2add(struct iguana_info *coin,struct iguana_block **blo
printf("bundlehash2add err.%d\n",err);
//return(0);
}
if ( bits256_cmp(bp->bundlehash2,bp->bundlehash2) != 0 )
{
char str[65];
printf("hdrs.%d %p bundlehash2? %s\n",bp->hdrsi,bp,bits256_str(str,bp->hashes[0]));
bp->hashes[0] = bp->bundlehash2;
}
return(-err);
}
@ -357,6 +376,7 @@ struct iguana_bundle *iguana_bundlecreate(struct iguana_info *coin,int32_t *bund
}
bp = mycalloc('b',1,sizeof(*bp));
bp->n = coin->chain->bundlesize;
bp->bundlehash2 = bundlehash2;
bp->hdrsi = bundleheight / coin->chain->bundlesize;
bp->bundleheight = bundleheight;
bp->allhash = allhash;
@ -365,6 +385,7 @@ struct iguana_bundle *iguana_bundlecreate(struct iguana_info *coin,int32_t *bund
{
bp->coin = coin;
bp->avetime = coin->avetime * 2.;
char str[65]; printf(">>>>>>>>>> set hdrsi.%d <<<<<<< %p %s\n",bp->hdrsi,bp,bits256_str(str,bundlehash2));
coin->bundles[bp->hdrsi] = bp;
if ( bp->hdrsi > 0 )
{
@ -382,7 +403,7 @@ struct iguana_bundle *iguana_bundlecreate(struct iguana_info *coin,int32_t *bund
sprintf(dirname,"%s/%s/%d/%d",GLOBAL_TMPDIR,coin->symbol,subdir,bp->bundleheight), OS_ensure_directory(dirname);
//sprintf(dirname,"DB/%s/%d",coin->symbol,bp->bundleheight), OS_ensure_directory(dirname);
//printf("%s ht.%d alloc.[%d] new hdrs.%s\n",coin->symbol,bp->bundleheight,coin->bundlescount,bits256_str(str,bp->hashes[0]));
iguana_bundlehash2add(coin,0,bp,0,bundlehash2);
//iguana_bundlehash2add(coin,0,bp,0,bundlehash2);
if ( issueflag != 0 )
{
iguana_blockQ("bundlecreate",coin,bp,0,bundlehash2,1);
@ -390,6 +411,7 @@ struct iguana_bundle *iguana_bundlecreate(struct iguana_info *coin,int32_t *bund
}
if ( bp->hdrsi >= coin->bundlescount )
coin->bundlescount = (bp->hdrsi + 1);
printf("bp.%p hashes[0] %s\n",bp,bits256_str(str,bp->hashes[0]));
}
else
{
@ -406,7 +428,7 @@ struct iguana_bundle *iguana_bundlecreate(struct iguana_info *coin,int32_t *bund
int32_t iguana_bundlefname(struct iguana_info *coin,struct iguana_bundle *bp,char *fname)
{
int32_t hdrsi; static bits256 zero;
iguana_peerfname(coin,&hdrsi,"DB",fname,0,bp->hashes[0],zero,bp->n,1);
iguana_peerfname(coin,&hdrsi,"DB",fname,0,bp->bundlehash2,zero,bp->n,1);
if ( hdrsi == bp->hdrsi )
return(0);
else
@ -432,7 +454,7 @@ struct iguana_txid *iguana_bundletx(struct iguana_info *coin,struct iguana_bundl
printf("bundletx without ramchain\n");
for (iter=0; iter<2; iter++)
{
iguana_peerfname(coin,&hdrsi,iter==0?"DB/ro":"DB",fname,0,bp->hashes[0],zero,bp->n,1);
iguana_peerfname(coin,&hdrsi,iter==0?"DB/ro":"DB",fname,0,bp->bundlehash2,zero,bp->n,1);
if ( (fp= fopen(fname,"rb")) != 0 )
{
fseek(fp,(long)&rdata.Toffset - (long)&rdata,SEEK_SET);
@ -564,7 +586,7 @@ struct iguana_block *iguana_bundleblock(struct iguana_info *coin,bits256 *hash2p
{
if ( bp->hdrsi < coin->bundlescount && (nextbp= coin->bundles[bp->hdrsi+1]) != 0 )
{
*hash2p = nextbp->hashes[0];
*hash2p = nextbp->bundlehash2;
return(nextbp->blocks[0]);
}
} else return(0);
@ -881,7 +903,7 @@ int32_t iguana_bundlehdr(struct supernet_info *myinfo,struct iguana_info *coin,s
if ( time(NULL) > bp->hdrtime+dist && (bp == coin->current || bp->hdrsi >= coin->bundlescount-2 || (strcmp("BTC",coin->symbol) != 0 && bp->numhashes < bp->n && (bp->speculative == 0 || bp->hdrsi >= coin->longestchain/bp->n))) )
{
bp->hdrtime = (uint32_t)time(NULL);
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0])));
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->bundlehash2)));
}
if ( time(NULL) > bp->hdrtime+dist && strcmp("BTC",coin->symbol) != 0 && (bp == coin->current || bp->hdrsi == coin->bundlescount-1) && bits256_nonz(bp->nextbundlehash2) == 0 )
{
@ -892,13 +914,13 @@ int32_t iguana_bundlehdr(struct supernet_info *myinfo,struct iguana_info *coin,s
if ( GETBIT(bp->haveblock,i) == 0 )
bp->issued[i] = 0;
bp->hdrtime = (uint32_t)time(NULL);
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0])));
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->bundlehash2)));
}
iguana_bundleissuemissing(myinfo,coin,bp,3,3.);
/*if ( bp == coin->current )
{
mult = 1.;
printf("iguana_bundlehdr.[%d] %d %s\n",bp->hdrsi,bp->numspec,bits256_str(str,bp->hashes[0]));
printf("iguana_bundlehdr.[%d] %d %s\n",bp->hdrsi,bp->numspec,bits256_str(str,bp->bundlehash2));
}*/
}
return(counter);
@ -1064,7 +1086,7 @@ int32_t iguana_bundlefinalize(struct supernet_info *myinfo,struct iguana_info *c
coin->numemitted++;
for (i=0; i<bp->n; i++)
iguana_hash2set(coin,"bundlefinalize",bp,i,bp->hashes[i]);
/*if ( bp->hdrsi == 0 && iguana_peerblockrequest(coin,coin->blockspace,coin->blockspacesize,0,bp->hashes[0],1) > 0 )
/*if ( bp->hdrsi == 0 && iguana_peerblockrequest(coin,coin->blockspace,coin->blockspacesize,0,bp->bundlehash2,1) > 0 )
printf("GENESIS block validated\n");
else printf("GENESIS didnt validate bp.%p\n",bp);*/
//if ( strcmp("BTC",coin->symbol) != 0 )
@ -1203,7 +1225,7 @@ void iguana_unstickhdr(struct iguana_info *coin,struct iguana_bundle *bp,int32_t
if ( (m= coin->peers->numranked) > 0 && bp->numhashes < bp->n && bp->hdrsi < coin->longestchain/coin->chain->bundlesize && time(NULL) > bp->unsticktime+lag )
{
for (i=0; i<10; i++)
if ( (addr= coin->peers->ranked[rand() % m]) != 0 && addr->usock >= 0 && addr->dead == 0 && (datalen= iguana_gethdrs(coin,serialized,coin->chain->gethdrsmsg,bits256_str(str,bp->hashes[0]))) > 0 )
if ( (addr= coin->peers->ranked[rand() % m]) != 0 && addr->usock >= 0 && addr->dead == 0 && (datalen= iguana_gethdrs(coin,serialized,coin->chain->gethdrsmsg,bits256_str(str,bp->bundlehash2))) > 0 )
{
//printf("UNSTICK HDR.[%d]\n",bp->hdrsi);
iguana_send(coin,addr,serialized,datalen);

2
iguana/iguana_chains.c

@ -504,7 +504,7 @@ void iguana_chaininit(struct supernet_info *myinfo,struct iguana_chain *chain,in
chain->bundlesize = _IGUANA_BLOCKHASHES;
}
if ( chain->zcash != 0 )
chain->bundlesize = 500;
chain->bundlesize = 160;
if ( strcmp(chain->symbol,"BTC") == 0 )
chain->bundlesize = 100;
decode_hex((uint8_t *)chain->genesis_hashdata,32,(char *)chain->genesis_hash);

24
iguana/iguana_init.c

@ -178,17 +178,17 @@ int32_t iguana_savehdrs(struct iguana_info *coin)
sha256all = bp->allhash;
bits256_str(shastr,bp->allhash);
}
fprintf(fp,"%d %s %s %s\n",bp->bundleheight,bits256_str(str,bp->hashes[0]),shastr,bits256_str(str2,bp->hashes[1]));
fprintf(fp,"%d %s %s %s\n",bp->bundleheight,bits256_str(str,bp->bundlehash2),shastr,bits256_str(str2,bp->hashes[1]));
if ( fp2 != 0 )
fprintf(fp2,"{ \"%d\", \"%s\", \"%s\", \"%s\"},\n",bp->bundleheight,bits256_str(str,bp->hashes[0]),shastr,bits256_str(str2,bp->hashes[1]));
fprintf(fp2,"{ \"%d\", \"%s\", \"%s\", \"%s\"},\n",bp->bundleheight,bits256_str(str,bp->bundlehash2),shastr,bits256_str(str2,bp->hashes[1]));
}
else
{
if ( bp != 0 && bits256_nonz(bp->hashes[0]) != 0 )
if ( bp != 0 && bits256_nonz(bp->bundlehash2) != 0 )
{
fprintf(fp,"%d %s\n",bp->bundleheight,bits256_str(str,bp->hashes[0]));
fprintf(fp,"%d %s\n",bp->bundleheight,bits256_str(str,bp->bundlehash2));
if ( fp2 != 0 )
fprintf(fp2,"{ \"%d\", \"%s\", \"%s\", \"%s\"},\n",bp->bundleheight,bits256_str(str,bp->hashes[0]),"","");
fprintf(fp2,"{ \"%d\", \"%s\", \"%s\", \"%s\"},\n",bp->bundleheight,bits256_str(str,bp->bundlehash2),"","");
}
break;
}
@ -327,7 +327,7 @@ void iguana_parseline(struct supernet_info *myinfo,struct iguana_info *coin,int3
{
lastheight = height = -1;
if ( coin->bundlescount > 0 && (bp= coin->bundles[coin->bundlescount - 1]) != 0 )
lastheight = bp->bundleheight, lastbundle = bp->hashes[0];
lastheight = bp->bundleheight, lastbundle = bp->bundlehash2;
for (k=height=0; k<j-1; k++)
{
if ( (c= line[k]) == ' ' )
@ -345,6 +345,8 @@ void iguana_parseline(struct supernet_info *myinfo,struct iguana_info *coin,int3
{
if ( (bp= iguana_bundlecreate(coin,&bundlei,height,hash2,zero,0)) != 0 )
{
if ( bits256_cmp(hash2,bp->bundlehash2) != 0 )
printf("error setting hashes[0] for ht.%d\n",height);
//printf("created bundle.%d\n",bp->hdrsi);
memset(hash1.bytes,0,sizeof(hash1));
iguana_bundleinitmap(myinfo,coin,bp,height,hash2,hash1);
@ -515,7 +517,7 @@ void iguana_coinpurge(struct iguana_info *coin)
struct iguana_info *iguana_coinstart(struct supernet_info *myinfo,struct iguana_info *coin,int32_t initialheight,int32_t mapflags)
{
FILE *fp; char fname[512],*symbol; int32_t j,iter; long fpos; bits256 lastbundle;
FILE *fp; char fname[512],*symbol; int32_t j,iter; long fpos; bits256 lastbundle,genesishash2;
/*if ( coin->peers == 0 )
{
printf("cant start privatechain directly\n");
@ -564,13 +566,15 @@ struct iguana_info *iguana_coinstart(struct supernet_info *myinfo,struct iguana_
}
}
//coin->firstblock = coin->blocks.parsedblocks + 1;
iguana_genesis(myinfo,coin,coin->chain);
genesishash2 = iguana_genesis(myinfo,coin,coin->chain);
int32_t bundlei = -2;
static const bits256 zero;
iguana_bundlecreate(coin,&bundlei,0,*(bits256 *)coin->chain->genesis_hashdata,zero,1);
//iguana_bundlecreate(coin,&bundlei,0,*(bits256 *)coin->chain->genesis_hashdata,zero,1);
coin->bundles[0] = iguana_bundlecreate(coin,&bundlei,0,genesishash2,zero,1);
if ( coin->virtualchain == 0 )
{
_iguana_chainlink(myinfo,coin,iguana_blockfind("genesis",coin,*(bits256 *)coin->chain->genesis_hashdata));
//_iguana_chainlink(myinfo,coin,iguana_blockfind("genesis",coin,*(bits256 *)coin->chain->genesis_hashdata));
_iguana_chainlink(myinfo,coin,iguana_blockfind("genesis",coin,genesishash2));
if ( coin->blocks.hwmchain.height != 0 || memcmp(coin->blocks.hwmchain.RO.hash2.bytes,coin->chain->genesis_hashdata,sizeof(coin->chain->genesis_hashdata)) != 0 )
{
char str[65]; printf("%s genesis values mismatch hwmheight.%d %.15f %.15f %s\n",coin->name,coin->blocks.hwmchain.height,coin->blocks.hwmchain.PoW,coin->blocks.hwmchain.PoW,bits256_str(str,coin->blocks.hwmchain.RO.hash2));

20
iguana/iguana_ramchain.c

@ -115,7 +115,9 @@ int32_t iguana_peerfname(struct iguana_info *coin,int32_t *hdrsip,char *dirname,
return(-2);
} else bundlei++;
}
hash2 = bp->hashes[0], *hdrsip = bp->hdrsi;
if ( bits256_cmp(bp->hashes[0],bp->bundlehash2) != 0 )
bp->hashes[0] = bp->bundlehash2;
hash2 = bp->bundlehash2, *hdrsip = bp->hdrsi;
subdir = bp->bundleheight / IGUANA_SUBDIRDIVISOR;
if ( numblocks == 1 )
{
@ -1289,7 +1291,7 @@ int32_t iguana_bundleremove(struct iguana_info *coin,int32_t hdrsi,int32_t tmpfi
for (i=0; i<bp->n; i++)
iguana_blockunmark(coin,bp->blocks[i],bp,i,1);
}
sprintf(fname,"%s/%s/spends/%s.%d",GLOBAL_DBDIR,coin->symbol,bits256_str(str,bp->hashes[0]),bp->bundleheight), OS_removefile(fname,0);
sprintf(fname,"%s/%s/spends/%s.%d",GLOBAL_DBDIR,coin->symbol,bits256_str(str,bp->bundlehash2),bp->bundleheight), OS_removefile(fname,0);
sprintf(fname,"%s/%s/accounts/debits.%d",GLOBAL_DBDIR,coin->symbol,bp->bundleheight), OS_removefile(fname,0);
sprintf(fname,"%s/%s/accounts/lastspends.%d",GLOBAL_DBDIR,coin->symbol,bp->bundleheight), OS_removefile(fname,0);
sprintf(fname,"%s/%s/validated/%d",GLOBAL_DBDIR,coin->symbol,bp->bundleheight), OS_removefile(fname,0);
@ -1323,7 +1325,7 @@ int32_t iguana_Xspendmap(struct iguana_info *coin,struct iguana_ramchain *ramcha
int32_t iter; bits256 sha256; char str[65],fname[1024]; void *ptr; long filesize;
for (iter=0; iter<2; iter++)
{
sprintf(fname,"%s/%s%s/spends/%s.%d",GLOBAL_DBDIR,iter==0?"ro/":"",coin->symbol,bits256_str(str,bp->hashes[0]),bp->bundleheight);
sprintf(fname,"%s/%s%s/spends/%s.%d",GLOBAL_DBDIR,iter==0?"ro/":"",coin->symbol,bits256_str(str,bp->bundlehash2),bp->bundleheight);
if ( (ptr= OS_mapfile(fname,&filesize,0)) != 0 )
{
ramchain->Xspendinds = (void *)((long)ptr + sizeof(sha256));
@ -2283,9 +2285,9 @@ struct iguana_ramchain *iguana_bundleload(struct supernet_info *myinfo,struct ig
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->bundlehash2,zero,0,0,extraflag,1)) != 0 )
{
iguana_ramchain_link(mapchain,bp->hashes[0],bp->hdrsi,bp->bundleheight,0,bp->n,firsti,1);
iguana_ramchain_link(mapchain,bp->bundlehash2,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);
//ramcoder_test(mapchain->H.data,mapchain->H.data->allocsize);
firsttxidind = 1;
@ -2668,13 +2670,13 @@ 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->bundlehash2,zero,0,0,1,1)) != 0 )
{
iguana_ramchain_link(A,bp->hashes[0],bp->hdrsi,bp->bundleheight,0,bp->ramchain.numblocks,firsti,1);
iguana_ramchain_link(A,bp->bundlehash2,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->bundlehash2,zero,0,0,1,1)) != 0 )
{
iguana_ramchain_link(B,bp->hashes[0],nextbp->hdrsi,nextbp->bundleheight,0,nextbp->ramchain.numblocks,firsti,1);
iguana_ramchain_link(B,bp->bundlehash2,nextbp->hdrsi,nextbp->bundleheight,0,nextbp->ramchain.numblocks,firsti,1);
}
if ( A == 0 || B == 0 || A->H.data == 0 || B->H.data == 0 || (A->H.data->allocsize + B->H.data->allocsize) > IGUANA_MAXRAMCHAINSIZE )
{

46
iguana/iguana_recv.c

@ -1058,7 +1058,7 @@ void iguana_bundlespeculate(struct iguana_info *coin,struct iguana_bundle *bp,in
return;
if ( time(NULL) > bp->hdrtime+3 && strcmp("BTC",coin->symbol) != 0 && bp->numhashes < bp->n && bundlei == 0 && bp->speculative == 0 && bp->bundleheight < coin->longestchain-coin->chain->bundlesize )
{
char str[65]; bits256_str(str,bp->hashes[0]);
char str[65]; bits256_str(str,bp->bundlehash2);
//fprintf(stderr,"Afound block -> %d %d hdr.%s\n",bp->bundleheight,coin->longestchain-coin->chain->bundlesize,str);
bp->hdrtime = (uint32_t)time(NULL);
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(str));
@ -1358,9 +1358,9 @@ struct iguana_bundlereq *iguana_recvblockhdrs(struct supernet_info *myinfo,struc
memset(prevhash2.bytes,0,sizeof(prevhash2));
for (i=match=0; i<n&&i<coin->chain->bundlesize; i++)
{
bp = 0, bundlei = -2;
if ( bits256_cmp(zblocks[i].RO.prev_block,coin->blocks.hwmchain.RO.hash2) == 0 )
{
bp = 0, bundlei = -2;
if ( (bp= iguana_bundleset(myinfo,coin,&block,&bundlei,(struct iguana_block *)&zblocks[i])) != 0 )
{
if ( firstbp == 0 )
@ -1369,9 +1369,18 @@ struct iguana_bundlereq *iguana_recvblockhdrs(struct supernet_info *myinfo,struc
coin->longestchain = block->height+1;
_iguana_chainlink(myinfo,coin,block);
}
//char str[65]; printf("HWM in hdr's prev[%d] bp.%p bundlei.%d block.%p %s\n",i,bp,bundlei,block,bp!=0?bits256_str(str,bp->hashes[bundlei]):"()");
//printf("HWM in hdr's prev[%d] bp.%p bundlei.%d block.%p %s\n",i,bp,bundlei,block,bp!=0?bits256_str(str,bp->hashes[bundlei]):"()");
}
bp = 0, bundlei = -2;
if ( i > 0 && bits256_cmp(zblocks[i].RO.prev_block,prevhash2) == 0 )
{
bp = 0; bundlei = -2;
if ( (bp= iguana_bundleset(myinfo,coin,&block,&bundlei,(struct iguana_block *)&zblocks[i])) != 0 )
{
//printf("found bp.%p i.%d of %d\n",bp,i,n);
} //else printf("didnt find in i.%d of %d\n",i,n);
}
iguana_blockQ("recvhdr",coin,bp,bundlei,zblocks[i].RO.hash2,0);
/*bp = 0, bundlei = -2;
if ( (bp= iguana_bundleset(myinfo,coin,&block,&bundlei,(struct iguana_block *)&zblocks[i])) == 0 )
{
bp = 0, bundlei = -2;
@ -1386,6 +1395,7 @@ struct iguana_bundlereq *iguana_recvblockhdrs(struct supernet_info *myinfo,struc
}
}
}
printf("i.%d of %d [%d]: %s\n",i,n,bundlei,bits256_str(str,zblocks[i].RO.prev_block));*/
if ( bp != 0 )
{
if ( firstbp == 0 )
@ -1393,7 +1403,7 @@ struct iguana_bundlereq *iguana_recvblockhdrs(struct supernet_info *myinfo,struc
else if ( bp == firstbp )
match++;
bp->dirty++;
if ( bp->issued[bundlei] == 0 )//&& coin->RTheight > 0 )
if ( bundlei >= 0 && bp->issued[bundlei] == 0 )//&& coin->RTheight > 0 )
{
bp->issued[bundlei] = 1;
iguana_blockQ("recvhdr",coin,bp,bundlei,zblocks[i].RO.hash2,0);
@ -1414,7 +1424,7 @@ struct iguana_bundlereq *iguana_recvblockhdrs(struct supernet_info *myinfo,struc
}*/
if ( firstbp != 0 && (addr= req->addr) != 0 && n >= coin->chain->bundlesize )
{
addr->RThashes[0] = firstbp->hashes[0];
addr->RThashes[0] = firstbp->bundlehash2;
for (i=1; i<coin->chain->bundlesize; i++)
{
iguana_serialize_block(myinfo,coin->chain,&addr->RThashes[i],serialized,(struct iguana_block *)&zblocks[i]);
@ -1452,7 +1462,7 @@ void iguana_autoextend(struct supernet_info *myinfo,struct iguana_info *coin,str
bp->hdrtime = (uint32_t)time(NULL);
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(hashstr));
}
//char str[65],str2[65]; printf("EXTEND last bundle %s/%s ht.%d\n",bits256_str(str,newbp->hashes[0]),bits256_str(str2,bp->nextbundlehash2),newbp->bundleheight);
//char str[65],str2[65]; printf("EXTEND last bundle %s/%s ht.%d\n",bits256_str(str,newbp->bundlehash2),bits256_str(str2,bp->nextbundlehash2),newbp->bundleheight);
if ( newbp->queued == 0 )
iguana_bundleQ(myinfo,coin,newbp,1000);
}
@ -1486,7 +1496,7 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct supernet_info *myinfo,str
{
bp->dirty++;
bp->hdrtime = (uint32_t)time(NULL);
blockhashes[0] = bp->hashes[0];
blockhashes[0] = bp->bundlehash2;
//iguana_blockQ("recvhash0",coin,bp,0,blockhashes[0],1);
if ( num >= coin->chain->bundlesize )
{
@ -1534,7 +1544,7 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct supernet_info *myinfo,str
bp->blocks[i] = iguana_blockhashset("recvhashes3",coin,bp->bundleheight+i,blockhashes[i],1);
//printf("speculate new issue [%d:%d]\n",bp->hdrsi,i);
}
bp->speculative[0] = bp->hashes[0];
bp->speculative[0] = bp->bundlehash2;
bp->numspec = (num <= bp->n+1) ? num : bp->n+1;
if ( bp == coin->current && (addr= req->addr) != 0 )
{
@ -1551,10 +1561,10 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct supernet_info *myinfo,str
{
if ( (bp= coin->bundles[i]) != 0 )//&& bp->emitfinish > 1 )
{
blockhashes[0] = bp->hashes[0];
blockhashes[0] = bp->bundlehash2;
vcalc_sha256(0,allhash.bytes,blockhashes[0].bytes,coin->chain->bundlesize * sizeof(*blockhashes));
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->bundlehash2));
if ( bits256_cmp(allhash,bp->allhash) == 0 )
{
if ( 0 && bp->speculative == 0 )
@ -1718,7 +1728,7 @@ struct iguana_bundlereq *iguana_recvblock(struct supernet_info *myinfo,struct ig
{
printf("reissue hdrs request for [%d]\n",bp->hdrsi);
bp->hdrtime = (uint32_t)time(NULL);
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0])));
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->bundlehash2)));
}
if ( (block= iguana_blockhashset("recvblock",coin,-1,origblock->RO.hash2,1)) != 0 )
{
@ -1998,12 +2008,14 @@ int32_t iguana_reqhdrs(struct iguana_info *coin)
if ( now > bp->issuetime+lag && now > bp->hdrtime+3 )
{
bp->hdrtime = now;
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);
if ( bp->issuetime == 0 )
coin->numpendings++;
init_hexbytes_noT(hashstr,bp->hashes[0].bytes,sizeof(bits256));
init_hexbytes_noT(hashstr,bp->bundlehash2.bytes,sizeof(bits256));
if ( bits256_nonz(bp->bundlehash2) == 0 )
printf("null hdrsi.%d hash0?\n",bp->hdrsi);
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(hashstr));
if ( 0 && bp == coin->current )
printf("LAG.%d hdrsi.%d numhashes.%d:%d needhdrs.%d qsize.%d zcount.%d %s\n",(uint32_t)(now-bp->hdrtime),i,bp->numhashes,bp->n,iguana_needhdrs(coin),queue_size(&coin->hdrsQ),coin->zcount,hashstr);
if ( bp == coin->current )
{
init_hexbytes_noT(hashstr,bp->hashes[0].bytes,sizeof(bits256));
@ -2020,7 +2032,7 @@ int32_t iguana_reqhdrs(struct iguana_info *coin)
//printf("hdrsi.%d reqHDR.(%s) numhashes.%d\n",bp->hdrsi,hashstr,bp->numhashes);
if ( 1 )
{
iguana_blockQ("reqhdrs0",coin,bp,0,bp->hashes[0],1);
iguana_blockQ("reqhdrs0",coin,bp,0,bp->bundlehash2,1);
if ( bits256_nonz(bp->hashes[1]) > 0 )
iguana_blockQ("reqhdrs1",coin,bp,1,bp->hashes[1],1);
}
@ -2182,7 +2194,7 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr)
iguana_send(coin,addr,serialized,datalen);
addr->pendhdrs++;
flag++;
} //else printf("skip hdrreq.%s m.%d z.%d bp.%p longest.%d queued.%d\n",hashstr,m,z,bp,bp->coin->longestchain,bp->queued);
} else printf("skip hdrreq.%s m.%d z.%d bp.%p longest.%d queued.%d\n",hashstr,m,z,bp,bp->coin->longestchain,bp->queued);
}
//free_queueitem(hashstr);
//return(flag);

8
iguana/iguana_spendvectors.c

@ -66,7 +66,7 @@ int32_t iguana_spendvectorsave(struct iguana_info *coin,struct iguana_bundle *bp
printf("iguana_spendvectorconv error [%d] at %d of %d/%d\n",bp->hdrsi,i,emit,n);
return(-1);
}
sprintf(fname,"%s/%s/spends/%s.%d",GLOBAL_DBDIR,coin->symbol,bits256_str(str,bp->hashes[0]),bp->bundleheight);
sprintf(fname,"%s/%s/spends/%s.%d",GLOBAL_DBDIR,coin->symbol,bits256_str(str,bp->bundlehash2),bp->bundleheight);
vcalc_sha256(0,sha256.bytes,(void *)ptr,(int32_t)(sizeof(*ptr) * emit));
if ( (fp= fopen(fname,"wb")) != 0 )
{
@ -699,11 +699,11 @@ int32_t iguana_volatilesinit(struct supernet_info *myinfo,struct iguana_info *co
//fprintf(stderr,"balancehash add [%d]\n",bp->hdrsi);
vupdate_sha256(balancehash.bytes,&vstate,(void *)Aptr,sizeof(*Aptr) * numpkinds);
vupdate_sha256(balancehash.bytes,&vstate,(void *)Uptr,sizeof(*Uptr) * numunspents);
vupdate_sha256(allbundles.bytes,&bstate,(void *)bp->hashes,sizeof(bp->hashes[0]) * bp->n);
vupdate_sha256(allbundles.bytes,&bstate,(void *)bp->hashes,sizeof(bp->bundlehash2) * bp->n);
}
crc = calc_crc32(crc,(void *)Aptr,(int32_t)(sizeof(*Aptr) * numpkinds));
crc = calc_crc32(crc,(void *)Uptr,(int32_t)(sizeof(*Uptr) * numunspents));
crc = calc_crc32(crc,(void *)bp->hashes,(int32_t)(sizeof(bp->hashes[0]) * bp->n));
crc = calc_crc32(crc,(void *)bp->hashes,(int32_t)(sizeof(bp->bundlehash2) * bp->n));
} //else printf("missing hdrs.[%d] data.%p num.(%u %d) %p %p\n",i,bp->ramchain.H.data,numpkinds,numunspents,Aptr,Uptr);
}
} else crc = filecrc;
@ -878,7 +878,7 @@ int32_t iguana_balanceflush(struct supernet_info *myinfo,struct iguana_info *coi
{
vupdate_sha256(balancehash.bytes,&vstate,(void *)Aptr,sizeof(*Aptr)*numpkinds);
vupdate_sha256(balancehash.bytes,&vstate,(void *)Uptr,sizeof(*Uptr)*numunspents);
vupdate_sha256(allbundles.bytes,&bstate,(void *)bp->hashes,sizeof(bp->hashes[0])*bp->n);
vupdate_sha256(allbundles.bytes,&bstate,(void *)bp->hashes,sizeof(bp->bundlehash2)*bp->n);
}
else if ( iter == 1 )
{

2
includes/iguana_structs.h

@ -381,7 +381,7 @@ struct iguana_bundle
struct iguana_block *blocks[IGUANA_MAXBUNDLESIZE];
uint8_t *speculativecache[IGUANA_MAXBUNDLESIZE],haveblock[IGUANA_MAXBUNDLESIZE/3+1];
uint32_t issued[IGUANA_MAXBUNDLESIZE],firsttxidinds[IGUANA_MAXBUNDLESIZE];
bits256 prevbundlehash2,hashes[IGUANA_MAXBUNDLESIZE+1],nextbundlehash2,allhash,*speculative,validatehash;
bits256 prevbundlehash2,bundlehash2,hashes[IGUANA_MAXBUNDLESIZE+1],nextbundlehash2,allhash,*speculative,validatehash;
struct iguana_ramchain ramchain; uint8_t red,green,blue;
struct iguana_spendvector *tmpspends; int32_t numtmpspends;
uint64_t *weights,supply; int32_t numweights;

Loading…
Cancel
Save