Browse Source

test

release/v0.1
jl777 8 years ago
parent
commit
eb629421d7
  1. 259
      crypto777/SaM.c
  2. 5
      gecko/gecko_blocks.c
  3. 21
      iguana/iguana777.c
  4. 3
      iguana/iguana_realtime.c
  5. 96
      iguana/iguana_recv.c
  6. 10
      iguana/iguana_unspents.c

259
crypto777/SaM.c

@ -958,5 +958,264 @@ BOOL castSupervisorVotes(unsigned int token, unsigned long time, Vote* votes, un
}
#endif
char bits2trits[256][5] = {
{0, 0, 0, 0, 0},
{1, 0, 0, 0, 0},
{-1, 1, 0, 0, 0},
{0, 1, 0, 0, 0},
{1, 1, 0, 0, 0},
{-1, -1, 1, 0, 0},
{0, -1, 1, 0, 0},
{1, -1, 1, 0, 0},
{-1, 0, 1, 0, 0},
{0, 0, 1, 0, 0},
{1, 0, 1, 0, 0},
{-1, 1, 1, 0, 0},
{0, 1, 1, 0, 0},
{1, 1, 1, 0, 0},
{-1, -1, -1, 1, 0},
{0, -1, -1, 1, 0},
{1, -1, -1, 1, 0},
{-1, 0, -1, 1, 0},
{0, 0, -1, 1, 0},
{1, 0, -1, 1, 0},
{-1, 1, -1, 1, 0},
{0, 1, -1, 1, 0},
{1, 1, -1, 1, 0},
{-1, -1, 0, 1, 0},
{0, -1, 0, 1, 0},
{1, -1, 0, 1, 0},
{-1, 0, 0, 1, 0},
{0, 0, 0, 1, 0},
{1, 0, 0, 1, 0},
{-1, 1, 0, 1, 0},
{0, 1, 0, 1, 0},
{1, 1, 0, 1, 0},
{-1, -1, 1, 1, 0},
{0, -1, 1, 1, 0},
{1, -1, 1, 1, 0},
{-1, 0, 1, 1, 0},
{0, 0, 1, 1, 0},
{1, 0, 1, 1, 0},
{-1, 1, 1, 1, 0},
{0, 1, 1, 1, 0},
{1, 1, 1, 1, 0},
{-1, -1, -1, -1, 1},
{0, -1, -1, -1, 1},
{1, -1, -1, -1, 1},
{-1, 0, -1, -1, 1},
{0, 0, -1, -1, 1},
{1, 0, -1, -1, 1},
{-1, 1, -1, -1, 1},
{0, 1, -1, -1, 1},
{1, 1, -1, -1, 1},
{-1, -1, 0, -1, 1},
{0, -1, 0, -1, 1},
{1, -1, 0, -1, 1},
{-1, 0, 0, -1, 1},
{0, 0, 0, -1, 1},
{1, 0, 0, -1, 1},
{-1, 1, 0, -1, 1},
{0, 1, 0, -1, 1},
{1, 1, 0, -1, 1},
{-1, -1, 1, -1, 1},
{0, -1, 1, -1, 1},
{1, -1, 1, -1, 1},
{-1, 0, 1, -1, 1},
{0, 0, 1, -1, 1},
{1, 0, 1, -1, 1},
{-1, 1, 1, -1, 1},
{0, 1, 1, -1, 1},
{1, 1, 1, -1, 1},
{-1, -1, -1, 0, 1},
{0, -1, -1, 0, 1},
{1, -1, -1, 0, 1},
{-1, 0, -1, 0, 1},
{0, 0, -1, 0, 1},
{1, 0, -1, 0, 1},
{-1, 1, -1, 0, 1},
{0, 1, -1, 0, 1},
{1, 1, -1, 0, 1},
{-1, -1, 0, 0, 1},
{0, -1, 0, 0, 1},
{1, -1, 0, 0, 1},
{-1, 0, 0, 0, 1},
{0, 0, 0, 0, 1},
{1, 0, 0, 0, 1},
{-1, 1, 0, 0, 1},
{0, 1, 0, 0, 1},
{1, 1, 0, 0, 1},
{-1, -1, 1, 0, 1},
{0, -1, 1, 0, 1},
{1, -1, 1, 0, 1},
{-1, 0, 1, 0, 1},
{0, 0, 1, 0, 1},
{1, 0, 1, 0, 1},
{-1, 1, 1, 0, 1},
{0, 1, 1, 0, 1},
{1, 1, 1, 0, 1},
{-1, -1, -1, 1, 1},
{0, -1, -1, 1, 1},
{1, -1, -1, 1, 1},
{-1, 0, -1, 1, 1},
{0, 0, -1, 1, 1},
{1, 0, -1, 1, 1},
{-1, 1, -1, 1, 1},
{0, 1, -1, 1, 1},
{1, 1, -1, 1, 1},
{-1, -1, 0, 1, 1},
{0, -1, 0, 1, 1},
{1, -1, 0, 1, 1},
{-1, 0, 0, 1, 1},
{0, 0, 0, 1, 1},
{1, 0, 0, 1, 1},
{-1, 1, 0, 1, 1},
{0, 1, 0, 1, 1},
{1, 1, 0, 1, 1},
{-1, -1, 1, 1, 1},
{0, -1, 1, 1, 1},
{1, -1, 1, 1, 1},
{-1, 0, 1, 1, 1},
{0, 0, 1, 1, 1},
{1, 0, 1, 1, 1},
{-1, 1, 1, 1, 1},
{0, 1, 1, 1, 1},
{1, 1, 1, 1, 1},
{2, 2, 2, 2, 2},
{2, 2, 2, 2, 2},
{2, 2, 2, 2, 2},
{2, 2, 2, 2, 2},
{2, 2, 2, 2, 2},
{2, 2, 2, 2, 2},
{2, 2, 2, 2, 2},
{2, 2, 2, 2, 2},
{2, 2, 2, 2, 2},
{2, 2, 2, 2, 2},
{2, 2, 2, 2, 2},
{2, 2, 2, 2, 2},
{2, 2, 2, 2, 2},
{-1, -1, -1, -1, -1},
{0, -1, -1, -1, -1},
{1, -1, -1, -1, -1},
{-1, 0, -1, -1, -1},
{0, 0, -1, -1, -1},
{1, 0, -1, -1, -1},
{-1, 1, -1, -1, -1},
{0, 1, -1, -1, -1},
{1, 1, -1, -1, -1},
{-1, -1, 0, -1, -1},
{0, -1, 0, -1, -1},
{1, -1, 0, -1, -1},
{-1, 0, 0, -1, -1},
{0, 0, 0, -1, -1},
{1, 0, 0, -1, -1},
{-1, 1, 0, -1, -1},
{0, 1, 0, -1, -1},
{1, 1, 0, -1, -1},
{-1, -1, 1, -1, -1},
{0, -1, 1, -1, -1},
{1, -1, 1, -1, -1},
{-1, 0, 1, -1, -1},
{0, 0, 1, -1, -1},
{1, 0, 1, -1, -1},
{-1, 1, 1, -1, -1},
{0, 1, 1, -1, -1},
{1, 1, 1, -1, -1},
{-1, -1, -1, 0, -1},
{0, -1, -1, 0, -1},
{1, -1, -1, 0, -1},
{-1, 0, -1, 0, -1},
{0, 0, -1, 0, -1},
{1, 0, -1, 0, -1},
{-1, 1, -1, 0, -1},
{0, 1, -1, 0, -1},
{1, 1, -1, 0, -1},
{-1, -1, 0, 0, -1},
{0, -1, 0, 0, -1},
{1, -1, 0, 0, -1},
{-1, 0, 0, 0, -1},
{0, 0, 0, 0, -1},
{1, 0, 0, 0, -1},
{-1, 1, 0, 0, -1},
{0, 1, 0, 0, -1},
{1, 1, 0, 0, -1},
{-1, -1, 1, 0, -1},
{0, -1, 1, 0, -1},
{1, -1, 1, 0, -1},
{-1, 0, 1, 0, -1},
{0, 0, 1, 0, -1},
{1, 0, 1, 0, -1},
{-1, 1, 1, 0, -1},
{0, 1, 1, 0, -1},
{1, 1, 1, 0, -1},
{-1, -1, -1, 1, -1},
{0, -1, -1, 1, -1},
{1, -1, -1, 1, -1},
{-1, 0, -1, 1, -1},
{0, 0, -1, 1, -1},
{1, 0, -1, 1, -1},
{-1, 1, -1, 1, -1},
{0, 1, -1, 1, -1},
{1, 1, -1, 1, -1},
{-1, -1, 0, 1, -1},
{0, -1, 0, 1, -1},
{1, -1, 0, 1, -1},
{-1, 0, 0, 1, -1},
{0, 0, 0, 1, -1},
{1, 0, 0, 1, -1},
{-1, 1, 0, 1, -1},
{0, 1, 0, 1, -1},
{1, 1, 0, 1, -1},
{-1, -1, 1, 1, -1},
{0, -1, 1, 1, -1},
{1, -1, 1, 1, -1},
{-1, 0, 1, 1, -1},
{0, 0, 1, 1, -1},
{1, 0, 1, 1, -1},
{-1, 1, 1, 1, -1},
{0, 1, 1, 1, -1},
{1, 1, 1, 1, -1},
{-1, -1, -1, -1, 0},
{0, -1, -1, -1, 0},
{1, -1, -1, -1, 0},
{-1, 0, -1, -1, 0},
{0, 0, -1, -1, 0},
{1, 0, -1, -1, 0},
{-1, 1, -1, -1, 0},
{0, 1, -1, -1, 0},
{1, 1, -1, -1, 0},
{-1, -1, 0, -1, 0},
{0, -1, 0, -1, 0},
{1, -1, 0, -1, 0},
{-1, 0, 0, -1, 0},
{0, 0, 0, -1, 0},
{1, 0, 0, -1, 0},
{-1, 1, 0, -1, 0},
{0, 1, 0, -1, 0},
{1, 1, 0, -1, 0},
{-1, -1, 1, -1, 0},
{0, -1, 1, -1, 0},
{1, -1, 1, -1, 0},
{-1, 0, 1, -1, 0},
{0, 0, 1, -1, 0},
{1, 0, 1, -1, 0},
{-1, 1, 1, -1, 0},
{0, 1, 1, -1, 0},
{1, 1, 1, -1, 0},
{-1, -1, -1, 0, 0},
{0, -1, -1, 0, 0},
{1, -1, -1, 0, 0},
{-1, 0, -1, 0, 0},
{0, 0, -1, 0, 0},
{1, 0, -1, 0, 0},
{-1, 1, -1, 0, 0},
{0, 1, -1, 0, 0},
{1, 1, -1, 0, 0},
{-1, -1, 0, 0, 0},
{0, -1, 0, 0, 0},
{1, -1, 0, 0, 0},
{-1, 0, 0, 0, 0}
};
#endif
#endif

5
gecko/gecko_blocks.c

@ -160,8 +160,9 @@ int32_t gecko_hwmset(struct supernet_info *myinfo,struct iguana_info *virt,struc
virt->current = bp;
iguana_RTspendvectors(myinfo,virt,bp);
iguana_RTramchainalloc("RTbundle",virt,bp);
iguana_update_balances(virt);
iguana_realtime_update(myinfo,virt);
printf("update virtchain balances\n");
//iguana_update_balances(virt);
//iguana_realtime_update(myinfo,virt);
if ( (block->height % virt->chain->bundlesize) == 13 && hdrsi > 0 && (prevbp= virt->bundles[hdrsi - 1]) != 0 && prevbp->emitfinish == 0 && prevbp->numsaved >= prevbp->n )
{
iguana_bundlefinalize(myinfo,virt,prevbp,&virt->MEM,virt->MEMB);

21
iguana/iguana777.c

@ -603,16 +603,19 @@ void iguana_helper(void *arg)
//portable_mutex_lock(&myinfo->allcoins_mutex);
HASH_ITER(hh,myinfo->allcoins,coin,tmp)
{
if ( coin->spendvectorsaved == 1 && coin->firstRTheight == 0 )
iguana_utxogen(myinfo,coin,helperid,0);
else if ( coin->spendvectorsaved > 1 && (coin->spendvalidated & (1 << helperid)) == 0 )
if ( coin->firstRTheight == 0 )
{
//printf("%s spendvectorsaved.%u helperid.%d validate\n",coin->symbol,coin->spendvectorsaved,helperid);
for (j=helperid; j<coin->bundlescount-1; j+=IGUANA_NUMHELPERS)
if ( (bp= coin->bundles[j]) != 0 )
iguana_bundlevalidate(coin,bp,0);
coin->spendvalidated |= (1 << helperid);
//printf("DONE %s spendvectorsaved.%u helperid.%d validate\n",coin->symbol,coin->spendvectorsaved,helperid);
if ( coin->spendvectorsaved == 1 )
iguana_utxogen(myinfo,coin,helperid,0);
else if ( coin->spendvectorsaved > 1 && (coin->spendvalidated & (1 << helperid)) == 0 )
{
//printf("%s spendvectorsaved.%u helperid.%d validate\n",coin->symbol,coin->spendvectorsaved,helperid);
for (j=helperid; j<coin->bundlescount-1; j+=IGUANA_NUMHELPERS)
if ( (bp= coin->bundles[j]) != 0 )
iguana_bundlevalidate(coin,bp,0);
coin->spendvalidated |= (1 << helperid);
//printf("DONE %s spendvectorsaved.%u helperid.%d validate\n",coin->symbol,coin->spendvectorsaved,helperid);
}
}
}
//portable_mutex_unlock(&myinfo->allcoins_mutex);

3
iguana/iguana_realtime.c

@ -694,8 +694,7 @@ void iguana_RTnewblock(struct iguana_info *coin,struct iguana_block *block)
else
{
printf("missing RTaddblock at i.%d RTheight.%d vs %p %d\n",i,coin->RTheight,addblock,addblock!=0?addblock->height:-1);
iguana_RTreset(coin);
return;
break;
}
}
coin->RTheight += i;

96
iguana/iguana_recv.c

@ -608,7 +608,7 @@ void iguana_gotblockhashesM(struct iguana_info *coin,struct iguana_peer *addr,bi
}
}
}
// if ( flag == 0 )
if ( flag == 0 )
iguana_sendblockreqPT(coin,addr,0,-1,blockhashes[i],0);
}
}
@ -748,10 +748,84 @@ int32_t iguana_bundlehashadd(struct iguana_info *coin,struct iguana_bundle *bp,i
return(retval);
}
void iguana_bundle_set(struct iguana_info *coin,struct iguana_block *block,int32_t height)
{
int32_t hdrsi,bundlei; struct iguana_bundle *bp;
if ( block->height < 0 || block->height == height )
{
hdrsi = (height / coin->chain->bundlesize);
bundlei = (height % coin->chain->bundlesize);
if ( hdrsi < coin->bundlescount && (bp= coin->bundles[hdrsi]) != 0 )
{
bp->blocks[bundlei] = block;
bp->hashes[bundlei] = block->RO.hash2;
if ( bp->speculative != 0 )
bp->speculative[bundlei] = block->RO.hash2;
printf("SET new HWM.%d in [%d:%d]\n",height,hdrsi,bundlei);
} else printf("iguana_bundle_set: no bundle at [%d]\n",hdrsi);
} else printf("iguana_bundle_set: mismatch ht.%d vs %d\n",block->height,height);
}
void iguana_hwmchain_set(struct iguana_info *coin,struct iguana_block *block,int32_t height)
{
if ( block->height == height )
iguana_blockcopy(coin->chain->zcash,coin->chain->auxpow,coin,(struct iguana_block *)&coin->blocks.hwmchain,block);
else printf("iguana_hwmchain_set: mismatched ht.%d vs %d\n",block->height,height);
}
void iguana_mainchain_clear(struct iguana_info *coin,struct iguana_block *mainchain,struct iguana_block *oldhwm,int32_t n)
{
int32_t i,height; struct iguana_block *tmp = oldhwm;
if ( mainchain != oldhwm )
{
height = oldhwm->height;
for (i=0; i<n; i++,height--)
{
if ( tmp->mainchain == 0 )
printf("iguana_mainchain_clear: unexpected non-mainchain at ht.%d\n",tmp->height);
else if ( tmp->height != height )
printf("iguana_mainchain_clear: unexpected ht.%d vs %d\n",tmp->height,height);
else
{
tmp->mainchain = 0;
printf("CLEAR mainchain.%d\n",height);
}
if ( (tmp= iguana_blockfind("clear",coin,tmp->RO.prev_block)) == 0 )
{
printf("iguana_mainchain_clear: got null tmp i.%d of %d\n",i,n);
return;
}
}
if ( tmp != mainchain )
printf("iguana_mainchain_clear: unexpected mismatch ht.%d vs %d\n",tmp->height,mainchain->height);
}
}
int32_t iguana_height_estimate(struct iguana_info *coin,struct iguana_block **mainchainp,struct iguana_block *block)
{
int32_t i,n; struct iguana_block *tmp = block;
*mainchainp = 0;
for (i=n=0; i<coin->chain->bundlesize; i++)
{
if ( tmp != 0 && (tmp= iguana_blockfind("estimate",coin,tmp->RO.hash2)) != 0 )
{
if ( tmp->mainchain != 0 )
{
char str[65]; printf("%s found mainchain.%d dist.%d\n",bits256_str(str,block->RO.hash2),tmp->height,n);
*mainchainp = tmp;
return(tmp->height + n);
}
n++;
tmp = iguana_blockfind("prevestimate",coin,tmp->RO.prev_block);
} else return(0);
}
return(0);
}
// main context, ie single threaded
struct iguana_bundle *iguana_bundleset(struct iguana_info *coin,struct iguana_block **blockp,int32_t *bundleip,struct iguana_block *origblock)
{
struct iguana_block *block,*prevblock; bits256 zero,hash2,prevhash2; struct iguana_bundle *prevbp,*bp = 0; int32_t prevbundlei,bundlei = -2; // struct iguana_ramchain blockR;
struct iguana_block *block,*prevblock,*tmp,*mainchain,*hwmblock; bits256 zero,hash2,prevhash2; struct iguana_bundle *prevbp,*bp = 0; int32_t i,newheight,prevbundlei,bundlei = -2; // struct iguana_ramchain blockR;
*bundleip = -2; *blockp = 0;
if ( origblock == 0 )
return(0);
@ -766,6 +840,22 @@ struct iguana_bundle *iguana_bundleset(struct iguana_info *coin,struct iguana_bl
//fprintf(stderr,"bundleset block.%p vs origblock.%p prev.%d bits.%x fpos.%ld\n",block,origblock,bits256_nonz(prevhash2),block->fpipbits,block->fpos);
}
*blockp = block;
if ( coin->firstRTheight > 0 && coin->blocks.hwmchain.height > 0 && (hwmblock= iguana_blockfind("hwm",coin,coin->blocks.hwmchain.RO.hash2)) != 0 )
{
if ( (newheight= iguana_height_estimate(coin,&mainchain,block)) >= coin->blocks.hwmchain.height )
{
iguana_mainchain_clear(coin,mainchain,hwmblock,coin->blocks.hwmchain.height-mainchain->height+1);
tmp = block;
for (i=0; i<newheight-mainchain->height; i++)
{
iguana_bundle_set(coin,tmp,newheight-i);
if ( (tmp= iguana_blockfind("hwmprev",coin,tmp->RO.prev_block)) == 0 )
break;
}
if ( mainchain != hwmblock )
iguana_hwmchain_set(coin,mainchain,mainchain->height); // trigger reprocess
}
}
//if ( 0 && bits256_nonz(prevhash2) > 0 )
// iguana_patch(coin,block);
bp = 0, bundlei = -2;
@ -1479,11 +1569,11 @@ int32_t iguana_reqhdrs(struct iguana_info *coin)
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(hashstr),1);
if ( bp == coin->current && coin->blocks.hwmchain.height > 100 )
{
//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);
bits256 hash2 = iguana_blockhash(coin,coin->blocks.hwmchain.height-10);
init_hexbytes_noT(hashstr,hash2.bytes,sizeof(bits256));
//printf("%s issue HWM HDRS %d-10 %s\n",coin->symbol,coin->blocks.hwmchain.height,hashstr);
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(hashstr),1);
}
//printf("hdrsi.%d reqHDR.(%s) numhashes.%d\n",bp->hdrsi,hashstr,bp->numhashes);

10
iguana/iguana_unspents.c

@ -1173,7 +1173,7 @@ int32_t iguana_utxoaddr_validate(struct supernet_info *myinfo,struct iguana_info
int64_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 errs=0,height=0,j,k,ind,tablesize=0; struct iguana_bundle *bp; struct iguana_ramchaindata *rdata=0; int64_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 errs=0,height=0,j,k,ind,tablesize=0; struct iguana_bundle *bp; struct iguana_block *block; struct iguana_ramchaindata *rdata=0; int64_t checkbalance=0,balance = 0;
for (hdrsi=0; hdrsi<coin->bundlescount-1; hdrsi++)
{
if ( (bp= coin->bundles[hdrsi]) != 0 && bp->bundleheight < maxheight )
@ -1190,8 +1190,8 @@ int64_t iguana_utxoaddr_gen(struct supernet_info *myinfo,struct iguana_info *coi
coin->firstRTheight = coin->RTheight = height;
iguana_RTreset(coin);
iguana_RTpurge(coin,coin->firstRTheight);
//if ( (block= iguana_blockfind("utxogen",coin,coin->blocks.hwmchain.RO.hash2)) != 0 )
// iguana_RTnewblock(coin,block);
if ( (block= iguana_blockfind("utxogen",coin,coin->blocks.hwmchain.RO.hash2)) != 0 )
iguana_RTnewblock(coin,block);
return(coin->histbalance);
}
}
@ -1319,8 +1319,8 @@ continue;
coin->firstRTheight = coin->RTheight = height;
iguana_RTreset(coin);
iguana_RTpurge(coin,coin->firstRTheight);
//if ( (block= iguana_blockfind("utxogen",coin,coin->blocks.hwmchain.RO.hash2)) != 0 )
// iguana_RTnewblock(coin,block);
if ( (block= iguana_blockfind("utxogen",coin,coin->blocks.hwmchain.RO.hash2)) != 0 )
iguana_RTnewblock(coin,block);
return(coin->histbalance);
}
}

Loading…
Cancel
Save