Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
61b6f8c75d
  1. 24
      basilisk/basilisk_bitcoin.c
  2. 2
      iguana/iguana777.h
  3. 2
      iguana/iguana_accept.c
  4. 5
      iguana/iguana_blocks.c
  5. 1
      iguana/iguana_bundles.c
  6. 2
      iguana/iguana_tx.c

24
basilisk/basilisk_bitcoin.c

@ -92,13 +92,29 @@ char *bitcoin_blockhashstr(char *coinstr,char *serverport,char *userpass,int32_t
return(blockhashstr);
}
bits256 basilisk_blockhash(struct iguana_info *coin,int32_t height)
int32_t basilisk_blockheight(struct iguana_info *coin,bits256 hash2)
{
char *blockhashstr; bits256 hash2;
char buf[128],str[65],*blocktxt; cJSON *blockjson; int32_t height=-1;
sprintf(buf,"\"%s\"",bits256_str(str,hash2));
if ( (blocktxt= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"getblock",buf)) != 0 )
{
if ( (blockjson= cJSON_Parse(blocktxt)) != 0 )
{
height = jint(blockjson,"height");
free_json(blockjson);
}
free(blocktxt);
}
return(height);
}
bits256 basilisk_blockhash(struct iguana_info *coin,bits256 prevhash2)
{
char *blockhashstr; bits256 hash2; int32_t height;
memset(hash2.bytes,0,sizeof(hash2));
if ( coin->MAXPEERS == 1 )
if ( (height= basilisk_blockheight(coin,prevhash2)) >= 0 )
{
if ( (blockhashstr= bitcoin_blockhashstr(coin->symbol,coin->chain->serverport,coin->chain->userpass,height)) != 0 )
if ( (blockhashstr= bitcoin_blockhashstr(coin->symbol,coin->chain->serverport,coin->chain->userpass,height+1)) != 0 )
{
hash2 = bits256_conv(blockhashstr);
free(blockhashstr);

2
iguana/iguana777.h

@ -1015,7 +1015,7 @@ void basilisk_functions(struct iguana_info *coin);
char *bitcoind_passthru(char *coinstr,char *serverport,char *userpass,char *method,char *params);
char *bitcoin_calcrawtx(struct supernet_info *myinfo,struct iguana_info *coin,cJSON **vinsp,int64_t satoshis,char *paymentscriptstr,char *changeaddr,int64_t txfee,cJSON *addresses,int32_t minconf,uint32_t locktime);
char *bitcoin_blockhashstr(char *coinstr,char *serverport,char *userpass,int32_t height);
bits256 basilisk_blockhash(struct iguana_info *coin,int32_t height);
bits256 basilisk_blockhash(struct iguana_info *coin,bits256 prevhash2);
extern int32_t HDRnet,netBLOCKS;

2
iguana/iguana_accept.c

@ -299,8 +299,6 @@ int32_t iguana_peerhdrrequest(struct iguana_info *coin,uint8_t *serialized,int32
{
iguana_blockunconv(&msgB,block,1);
len += iguana_rwblock(coin->chain->hashalgo,1,&checkhash2,&serialized[sizeof(struct iguana_msghdr) + len],&msgB);
if ( coin->MAXPEERS == 1 )
checkhash2 = basilisk_blockhash(coin,bp->bundleheight + i);
flag++;
if ( bits256_cmp(checkhash2,block->RO.hash2) != 0 )
{

5
iguana/iguana_blocks.c

@ -190,6 +190,8 @@ int32_t iguana_blockvalidate(struct iguana_info *coin,int32_t *validp,struct igu
bits256 hash2; uint8_t serialized[sizeof(struct iguana_msgblock) + 4096];
*validp = 0;
iguana_serialize_block(coin->chain,&hash2,serialized,block);
if ( coin->MAXPEERS == 1 )
hash2 = basilisk_blockhash(coin,block->RO.prev_block);
*validp = (memcmp(hash2.bytes,block->RO.hash2.bytes,sizeof(hash2)) == 0);
block->valid = *validp;
char str[65]; char str2[65];
@ -492,9 +494,6 @@ struct iguana_block *_iguana_chainlink(struct iguana_info *coin,struct iguana_bl
//char str[65]; printf("extend? %s.h%d: %.15f vs %.15f ht.%d vs %d\n",bits256_str(str,block->RO.hash2),height,block->PoW,coin->blocks.hwmchain.PoW,height,coin->blocks.hwmchain.height);
if ( iguana_blockvalidate(coin,&valid,newblock,0) < 0 || valid == 0 )
return(0);
block->RO.hash2 = basilisk_blockhash(coin,height);
if ( hash2p != 0 )
*hash2p = block->RO.hash2;
block->height = height;
block->valid = 1;
if ( block->PoW >= hwmchain->PoW )

1
iguana/iguana_bundles.c

@ -898,7 +898,6 @@ int64_t iguana_bundlecalcs(struct iguana_info *coin,struct iguana_bundle *bp,int
datasize = numhashes = numsaved = numrecv = numcached = minrequests = 0;
for (bundlei=0; bundlei<bp->n; bundlei++)
{
bp->hashes[bundlei] = basilisk_blockhash(coin,bp->bundleheight + bundlei);
if ( bits256_nonz(bp->hashes[bundlei]) != 0 )
{
numhashes++;

2
iguana/iguana_tx.c

@ -231,8 +231,6 @@ int32_t iguana_peerblockrequest(struct iguana_info *coin,uint8_t *blockspace,int
iguana_blockunconv(&msgB,block,0);
msgB.txn_count = block->RO.txn_count;
total = iguana_rwblock(coin->chain->hashalgo,1,&checkhash2,&blockspace[sizeof(struct iguana_msghdr) + 0],&msgB);
if ( coin->MAXPEERS == 1 )
checkhash2 = basilisk_blockhash(coin,bp->bundleheight + bundlei);
if ( bits256_cmp(checkhash2,block->RO.hash2) != 0 )
{
static int counter;

Loading…
Cancel
Save