Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
66e60a4b89
  1. 2
      basilisk/basilisk.c
  2. 2
      gecko/gecko.c
  3. 2
      gecko/gecko.h
  4. 41
      gecko/gecko_blocks.c

2
basilisk/basilisk.c

@ -810,7 +810,7 @@ void basilisk_geckoresult(struct supernet_info *myinfo,struct basilisk_item *ptr
else if ( strcmp(type,"MEM") == 0 )
str = gecko_mempoolarrived(myinfo,virt,ptr->remoteaddr,data,datalen,hash2);
else if ( strcmp(type,"BLK") == 0 )
str = gecko_blockarrived(myinfo,virt,ptr->remoteaddr,data,datalen,hash2);
str = gecko_blockarrived(myinfo,virt,ptr->remoteaddr,data,datalen,hash2,0);
else if ( strcmp(type,"GTX") == 0 )
str = gecko_txarrived(myinfo,virt,ptr->remoteaddr,data,datalen,hash2);
}

2
gecko/gecko.c

@ -331,7 +331,7 @@ struct iguana_info *basilisk_geckochain(struct supernet_info *myinfo,char *symbo
iguana_gentxarray(virt,&virt->TXMEM,&txdata,&len,serialized,datalen);
txdata.zblock.height = 0;
txdata.zblock.RO.allocsize = iguana_ROallocsize(virt);
gecko_hwmset(myinfo,virt,&txdata,virt->TXMEM.ptr,serialized,datalen,txdata.numtxids);
gecko_hwmset(myinfo,virt,&txdata,virt->TXMEM.ptr,serialized,datalen,txdata.numtxids,0);
}
virt->started = virt;
virt->active = (uint32_t)time(NULL);

2
gecko/gecko.h

@ -74,7 +74,7 @@ char *basilisk_respond_geckoget(struct supernet_info *myinfo,char *CMD,void *add
void gecko_miner(struct supernet_info *myinfo,struct iguana_info *btcd,struct iguana_info *virt,int32_t maxmillis,uint8_t *minerpubkey33);
void gecko_seqresult(struct supernet_info *myinfo,char *retstr);
int32_t gecko_sequpdate(struct supernet_info *myinfo,char *symbol,uint32_t reftimestamp);
char *gecko_blockarrived(struct supernet_info *myinfo,struct iguana_info *virt,char *remoteaddr,uint8_t *data,int32_t datalen,bits256 hash2);
char *gecko_blockarrived(struct supernet_info *myinfo,struct iguana_info *virt,char *remoteaddr,uint8_t *data,int32_t datalen,bits256 hash2,int32_t verifyonly);
char *gecko_txarrived(struct supernet_info *myinfo,struct iguana_info *virt,char *remoteaddr,uint8_t *data,int32_t datalen,bits256 hash2);
char *gecko_mempoolarrived(struct supernet_info *myinfo,struct iguana_info *virt,char *remoteaddr,uint8_t *data,int32_t datalen,bits256 hash2);
char *gecko_headersarrived(struct supernet_info *myinfo,struct iguana_info *virt,char *remoteaddr,uint8_t *data,int32_t datalen,bits256 hash2);

41
gecko/gecko_blocks.c

@ -112,7 +112,7 @@ struct iguana_bundle *gecko_ensurebundle(struct iguana_info *virt,struct iguana_
return(bp);
}
int32_t gecko_hwmset(struct supernet_info *myinfo,struct iguana_info *virt,struct iguana_txblock *txdata,struct iguana_msgtx *txarray,uint8_t *data,int32_t datalen,int32_t depth)
int32_t gecko_hwmset(struct supernet_info *myinfo,struct iguana_info *virt,struct iguana_txblock *txdata,struct iguana_msgtx *txarray,uint8_t *data,int32_t datalen,int32_t depth,int32_t verifyonly)
{
struct iguana_peer *addr; int32_t i,hdrsi; struct iguana_bundle *bp,*prevbp; struct iguana_block *block;
if ( (block= iguana_blockhashset("gecko_hwmset",virt,txdata->zblock.height,txdata->zblock.RO.hash2,1)) != 0 )
@ -127,29 +127,32 @@ int32_t gecko_hwmset(struct supernet_info *myinfo,struct iguana_info *virt,struc
block->fpipbits = (uint32_t)addr->ipbits;
block->RO.recvlen = datalen;
block->txvalid = 1;
iguana_blockzcopy(virt->chain->zcash,(void *)&virt->blocks.hwmchain,block);
hdrsi = block->height / virt->chain->bundlesize;
if ( (bp= virt->bundles[hdrsi]) != 0 )
if ( verifyonly == 0 )
{
bp->numsaved++;
if ( (block->height % virt->chain->bundlesize) == 13 && hdrsi > 0 && (prevbp= virt->bundles[hdrsi - 1]) != 0 && prevbp->emitfinish == 0 && prevbp->numsaved >= prevbp->n )
iguana_blockzcopy(virt->chain->zcash,(void *)&virt->blocks.hwmchain,block);
hdrsi = block->height / virt->chain->bundlesize;
if ( (bp= virt->bundles[hdrsi]) != 0 )
{
iguana_bundlefinalize(myinfo,virt,prevbp,&virt->MEM,virt->MEMB);
prevbp->emitfinish = (uint32_t)(time(NULL) - 3600);
iguana_bundlepurgefiles(virt,prevbp);
iguana_savehdrs(virt);
iguana_bundlevalidate(virt,prevbp,1);
for (i=0; i<block->RO.txn_count; i++)
gecko_txidpurge(virt,txarray[i].txid);
bp->numsaved++;
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);
prevbp->emitfinish = (uint32_t)(time(NULL) - 3600);
iguana_bundlepurgefiles(virt,prevbp);
iguana_savehdrs(virt);
iguana_bundlevalidate(virt,prevbp,1);
for (i=0; i<block->RO.txn_count; i++)
gecko_txidpurge(virt,txarray[i].txid);
}
}
//printf("created block.%d [%d:%d] %d\n",block->height,bp!=0?bp->hdrsi:-1,block->height%virt->chain->bundlesize,bp->numsaved);
}
//printf("created block.%d [%d:%d] %d\n",block->height,bp!=0?bp->hdrsi:-1,block->height%virt->chain->bundlesize,bp->numsaved);
return(block->height);
}
return(-1);
}
char *gecko_blockarrived(struct supernet_info *myinfo,struct iguana_info *virt,char *remoteaddr,uint8_t *data,int32_t datalen,bits256 hash2)
char *gecko_blockarrived(struct supernet_info *myinfo,struct iguana_info *virt,char *remoteaddr,uint8_t *data,int32_t datalen,bits256 hash2,int32_t verifyonly)
{
struct iguana_txblock txdata; int32_t height,valid,adjacent,gap,n,i,j,len = -1; struct iguana_block *block,*prev; struct iguana_txid tx; char str[65]; bits256 txid; struct iguana_msgtx *txs;
memset(&txdata,0,sizeof(txdata));
@ -236,7 +239,7 @@ char *gecko_blockarrived(struct supernet_info *myinfo,struct iguana_info *virt,c
}
txdata.zblock.height = block->height;
txdata.zblock.mainchain = block->mainchain = 1;
if ( gecko_hwmset(myinfo,virt,&txdata,virt->TXMEM.ptr,data,datalen,i+1) >= 0 )
if ( gecko_hwmset(myinfo,virt,&txdata,virt->TXMEM.ptr,data,datalen,i+1,verifyonly) >= 0 )
{
if ( block->height > virt->longestchain )
virt->longestchain = block->height;
@ -272,7 +275,7 @@ char *basilisk_respond_geckoblock(struct supernet_info *myinfo,char *CMD,void *a
{
iguana_rwblock(symbol,virt->chain->zcash,virt->chain->auxpow,virt->chain->hashalgo,0,&checkhash2,data,&msg,datalen);
if ( bits256_cmp(hash2,checkhash2) == 0 )
return(gecko_blockarrived(myinfo,virt,addr,data,datalen,hash2));
return(gecko_blockarrived(myinfo,virt,addr,data,datalen,hash2,0));
else return(clonestr("{\"error\":\"block error with checkhash2\"}"));
} else return(clonestr("{\"error\":\"block nonce didnt verify\"}"));
}
@ -284,7 +287,7 @@ int32_t basilisk_blocksubmit(struct supernet_info *myinfo,struct iguana_info *bt
int32_t i,datalen,num,numerrs,numresults=-1; uint8_t *data,space[16384],*allocptr; cJSON *valsobj=0,*retjson,*retarray,*item; char *str,*str2,*othercoin; bits256 othertip;
if ( (data= get_dataptr(sizeof(struct iguana_msghdr) + BASILISK_HDROFFSET,&allocptr,&datalen,space,sizeof(space),blockstr)) != 0 )
{
if ( (str= gecko_blockarrived(myinfo,virt,"127.0.0.1",data,datalen,hash2)) != 0 )
if ( (str= gecko_blockarrived(myinfo,virt,"127.0.0.1",data,datalen,hash2,1)) != 0 )
{
if ( (retjson= cJSON_Parse(str)) != 0 )
{
@ -329,6 +332,8 @@ int32_t basilisk_blocksubmit(struct supernet_info *myinfo,struct iguana_info *bt
free_json(retjson);
}
free(str);
if ( (numresults >= myinfo->numrelays >> 1) && (str= gecko_blockarrived(myinfo,virt,"127.0.0.1",data,datalen,hash2,0)) != 0 )
free(str);
}
}
if ( allocptr != 0 )

Loading…
Cancel
Save