Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
3f030c56b0
  1. 28
      basilisk/basilisk.c
  2. 14
      gecko/gecko_blocks.c

28
basilisk/basilisk.c

@ -591,17 +591,35 @@ int32_t basilisk_relays_ping(struct supernet_info *myinfo,uint8_t *data,int32_t
int32_t basilisk_blocksend(struct supernet_info *myinfo,struct iguana_info *btcd,struct iguana_info *virt,struct iguana_peer *addr,int32_t height)
{
int32_t blocklen; bits256 hash2; char str[65],strbuf[8192],*blockstr,*allocptr = 0;
int32_t blocklen; bits256 hash2; uint8_t *data = 0; char str[65],strbuf[8192],*blockstr,*allocptr = 0; struct iguana_block *block;
hash2 = iguana_blockhash(virt,height);
if ( (blocklen= iguana_peerblockrequest(virt,virt->blockspace,IGUANA_MAXPACKETSIZE,0,hash2,0)) > 0 )
if ( (block= iguana_blockfind("bsend",virt,hash2)) != 0 )
{
blockstr = basilisk_addhexstr(&allocptr,0,strbuf,sizeof(strbuf),&virt->blockspace[sizeof(struct iguana_msghdr)],blocklen);
if ( block->height != height )
{
printf("basilisk_blocksend: height.%d mismatch %d\n",block->height,height);
return(-1);
}
else if ( block->queued != 0 && block->req != 0 )
{
memcpy(&blocklen,block->req,sizeof(blocklen));
data = (uint8_t *)(void *)((long)block->req + sizeof(blocklen));
}
}
if ( data == 0 )
{
if ( (blocklen= iguana_peerblockrequest(virt,virt->blockspace,IGUANA_MAXPACKETSIZE,0,hash2,0)) > 0 )
data = &virt->blockspace[sizeof(struct iguana_msghdr)];
}
if ( data != 0 )
{
blockstr = basilisk_addhexstr(&allocptr,0,strbuf,sizeof(strbuf),data,blocklen);
printf("RELAYID.%d send block.%d %s -> (%s) %s\n",myinfo->RELAYID,height,blockstr,addr->ipaddr,bits256_str(str,hash2));
basilisk_blocksubmit(myinfo,btcd,virt,addr,blockstr,virt->blocks.hwmchain.RO.hash2,height);
basilisk_blocksubmit(myinfo,btcd,virt,addr,blockstr,hash2,height);
if ( allocptr != 0 )
free(allocptr);
return(0);
} else printf("blocklen.%d for hwm.%d height.%d %s\n",blocklen,virt->blocks.hwmchain.height,height,bits256_str(str,virt->blocks.hwmchain.RO.hash2));
} else printf("blocklen.%d for hwm.%d height.%d %s\n",blocklen,virt->blocks.hwmchain.height,height,bits256_str(str,hash2));
return(-1);
}

14
gecko/gecko_blocks.c

@ -59,7 +59,7 @@ struct iguana_bundle *gecko_bundleset(struct iguana_info *virt,struct iguana_blo
{
bp->blocks[bundlei] = block;
bp->hashes[bundlei] = block->RO.hash2;
//char str[65]; printf("[%d:%d] <- %s %p\n",hdrsi,bundlei,bits256_str(str,block->RO.hash2),block);
char str[65]; printf("[%d:%d] <- %s %p\n",hdrsi,bundlei,bits256_str(str,block->RO.hash2),block);
iguana_hash2set(virt,"ensure",bp,bundlei,block->RO.hash2);
}
return(bp);
@ -144,9 +144,19 @@ int32_t gecko_hwmset(struct supernet_info *myinfo,struct iguana_info *virt,struc
block->hdrsi = hdrsi;
block->height =
block->bundlei = (block->height % virt->chain->bundlesize);
if ( block->queued == 0 )
{
block->req = calloc(1,datalen + sizeof(datalen));
memcpy(block->req,&datalen,sizeof(datalen));
memcpy((void *)((long)block->req + sizeof(datalen)),data,datalen);
block->queued = 1;
}
if ( (bp= virt->bundles[hdrsi]) != 0 )
{
bp->numsaved++;
bp->numsaved = 0;
for (i=0; i<virt->chain->bundlesize; i++)
if ( bp->blocks[i] != 0 && bp->blocks[i]->txvalid != 0 )
bp->numsaved++;
virt->current = bp;
iguana_RTspendvectors(virt,bp);
iguana_RTramchainalloc("RTbundle",virt,bp);

Loading…
Cancel
Save