Browse Source

getrawtransaction fields

release/v0.1
jl777 9 years ago
parent
commit
09f0186f46
  1. 13
      gecko/gecko.c
  2. 14
      gecko/gecko_miner.c
  3. 6
      iguana/iguana777.c
  4. 10
      iguana/iguana_payments.c

13
gecko/gecko.c

@ -1,3 +1,4 @@
/****************************************************************************** /******************************************************************************
* Copyright © 2014-2016 The SuperNET Developers. * * Copyright © 2014-2016 The SuperNET Developers. *
* * * *
@ -44,22 +45,28 @@
void gecko_iteration(struct supernet_info *myinfo,struct iguana_info *btcd,struct iguana_info *virt,int32_t maxmillis) void gecko_iteration(struct supernet_info *myinfo,struct iguana_info *btcd,struct iguana_info *virt,int32_t maxmillis)
{ {
char mineraddr[64]; int32_t hwmhdrsi,longesthdrsi; char mineraddr[64]; int32_t hwmhdrsi,longesthdrsi;
struct iguana_info *coin,*tmp;
HASH_ITER(hh,myinfo->allcoins,coin,tmp)
{
printf("%s ",coin->symbol);
}
printf("allcoins iteration\n");
hwmhdrsi = virt->blocks.hwmchain.height / virt->chain->bundlesize; hwmhdrsi = virt->blocks.hwmchain.height / virt->chain->bundlesize;
longesthdrsi = virt->longestchain / virt->chain->bundlesize; longesthdrsi = virt->longestchain / virt->chain->bundlesize;
if ( hwmhdrsi <= longesthdrsi )//&& virt->blocks.hwmchain.height < virt->longestchain-1 ) if ( hwmhdrsi <= longesthdrsi )//&& virt->blocks.hwmchain.height < virt->longestchain-1 )
{ {
if ( time(NULL) > virt->hdrstime+3 ) if ( time(NULL) > virt->hdrstime+3 )
{ {
fprintf(stderr,"request headers\n"); fprintf(stderr,"request %s headers\n",virt->symbol);
gecko_requesthdrs(myinfo,virt,hwmhdrsi); gecko_requesthdrs(myinfo,virt,hwmhdrsi);
//fprintf(stderr,"R"); //fprintf(stderr,"R");
virt->hdrstime = (uint32_t)time(NULL); virt->hdrstime = (uint32_t)time(NULL);
} }
} }
if ( btcd->RELAYNODE != 0 && myinfo->RELAYID == 0 )//&& virt->blocks.hwmchain.height >= virt->longestchain-virt->chain->bundlesize ) //if ( btcd->RELAYNODE != 0 && myinfo->RELAYID == 0 )//&& virt->blocks.hwmchain.height >= virt->longestchain-virt->chain->bundlesize )
{ {
bitcoin_address(mineraddr,virt->chain->pubtype,myinfo->persistent_pubkey33,33); bitcoin_address(mineraddr,virt->chain->pubtype,myinfo->persistent_pubkey33,33);
//fprintf(stderr,"mine.%s %s\n",virt->symbol,mineraddr); fprintf(stderr,"mine.%s %s\n",virt->symbol,mineraddr);
gecko_miner(myinfo,btcd,virt,maxmillis,myinfo->persistent_pubkey33); gecko_miner(myinfo,btcd,virt,maxmillis,myinfo->persistent_pubkey33);
} }
} }

14
gecko/gecko_miner.c

@ -331,9 +331,12 @@ int32_t gecko_blocksubmit(struct supernet_info *myinfo,struct iguana_info *btcd,
void gecko_miner(struct supernet_info *myinfo,struct iguana_info *btcd,struct iguana_info *virt,int32_t maxmillis,uint8_t *minerpubkey33) void gecko_miner(struct supernet_info *myinfo,struct iguana_info *btcd,struct iguana_info *virt,int32_t maxmillis,uint8_t *minerpubkey33)
{ {
struct iguana_zblock newblock; uint32_t prevtimestamp,nBits; int64_t reward = 0; int32_t i,gap,txn_count; char *blockstr,*space[256]; struct gecko_memtx **txptrs; void *ptr; //struct iguana_bundle *bp; struct iguana_zblock newblock; uint32_t prevtimestamp,nBits; int64_t reward = 0; int32_t i,gap,txn_count; char *blockstr,*space[256]; struct gecko_memtx **txptrs; void *ptr; //struct iguana_bundle *bp;
if ( virt->virtualchain == 0 || myinfo->RELAYID < 0 || myinfo->numrelays < 1 ) if ( virt->virtualchain == 0 )//|| myinfo->RELAYID < 0 || myinfo->numrelays < 1 )
{
printf("skip non-virtual chain.%s\n",virt->symbol);
return; return;
if ( (virt->blocks.hwmchain.height % myinfo->numrelays) != myinfo->RELAYID ) }
if ( 0 && (virt->blocks.hwmchain.height % myinfo->numrelays) != myinfo->RELAYID )
{ {
if ( myinfo->numrelays < 3 ) if ( myinfo->numrelays < 3 )
return; return;
@ -362,7 +365,7 @@ void gecko_miner(struct supernet_info *myinfo,struct iguana_info *btcd,struct ig
if ( (nBits= gecko_nBits(virt,&prevtimestamp,(void *)&newblock,GECKO_DIFFITERS)) != 0 ) if ( (nBits= gecko_nBits(virt,&prevtimestamp,(void *)&newblock,GECKO_DIFFITERS)) != 0 )
{ {
newblock.RO.bits = nBits; newblock.RO.bits = nBits;
//printf("mine.%s nBits.%x ht.%d\n",virt->symbol,nBits,newblock.height); printf("mine.%s nBits.%x ht.%d\n",virt->symbol,nBits,newblock.height);
txptrs = gecko_mempool_txptrs(myinfo,virt,&reward,&txn_count,&ptr,space,(int32_t)(sizeof(space)/sizeof(*space)),newblock.height); txptrs = gecko_mempool_txptrs(myinfo,virt,&reward,&txn_count,&ptr,space,(int32_t)(sizeof(space)/sizeof(*space)),newblock.height);
//char str[65]; printf("HWM.%s %p\n",bits256_str(str,newblock.RO.prev_block),&newblock.RO.prev_block); //char str[65]; printf("HWM.%s %p\n",bits256_str(str,newblock.RO.prev_block),&newblock.RO.prev_block);
if ( (blockstr= gecko_createblock(myinfo,virt->chain->estblocktime,prevtimestamp,btcd,virt->chain->isPoS,(void *)&newblock,virt->symbol,txptrs,txn_count,maxmillis,minerpubkey33,reward)) != 0 ) if ( (blockstr= gecko_createblock(myinfo,virt->chain->estblocktime,prevtimestamp,btcd,virt->chain->isPoS,(void *)&newblock,virt->symbol,txptrs,txn_count,maxmillis,minerpubkey33,reward)) != 0 )
@ -372,8 +375,9 @@ void gecko_miner(struct supernet_info *myinfo,struct iguana_info *btcd,struct ig
free(blockstr); free(blockstr);
else else
{ {
virt->newblockstr = blockstr; //virt->newblockstr = blockstr;
virt->newblock = newblock; //virt->newblock = newblock;
free(blockstr);
} }
} }
if ( txptrs != (void *)space ) if ( txptrs != (void *)space )

6
iguana/iguana777.c

@ -78,6 +78,12 @@ struct iguana_info *iguana_coinadd(char *symbol,char *name,cJSON *argjson,int32_
//portable_mutex_lock(&myinfo->allcoins_mutex); //portable_mutex_lock(&myinfo->allcoins_mutex);
HASH_ADD(hh,myinfo->allcoins,symbolcrc,sizeof(coin->symbolcrc),coin); HASH_ADD(hh,myinfo->allcoins,symbolcrc,sizeof(coin->symbolcrc),coin);
//portable_mutex_unlock(&myinfo->allcoins_mutex); //portable_mutex_unlock(&myinfo->allcoins_mutex);
struct iguana_info *virt,*tmp;
HASH_ITER(hh,myinfo->allcoins,virt,tmp)
{
printf("%s ",virt->symbol);
}
printf("allcoins\n");
myinfo->allcoins_being_added = 0; myinfo->allcoins_being_added = 0;
} }
if ( (coin= iguana_coinfind(symbol)) == 0 ) if ( (coin= iguana_coinfind(symbol)) == 0 )

10
iguana/iguana_payments.c

@ -773,7 +773,7 @@ THREE_STRINGS(bitcoinrpc,verifymessage,address,sig,message)
HASH_AND_INT(bitcoinrpc,getrawtransaction,txid,verbose) HASH_AND_INT(bitcoinrpc,getrawtransaction,txid,verbose)
{ {
struct iguana_txid *tx,T; char *txbytes; bits256 checktxid; int32_t len,height,extralen=65536; cJSON *retjson,*txobj; uint8_t *extraspace; struct iguana_txid *tx,T; char *txbytes; bits256 checktxid; int32_t len,height,extralen=65536; cJSON *retjson,*txobj; uint8_t *extraspace; struct iguana_block *block; bits256 hash2;
if ( remoteaddr != 0 ) if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}")); return(clonestr("{\"error\":\"no remote\"}"));
if ( (tx= iguana_txidfind(coin,&height,&T,txid,coin->bundlescount-1)) != 0 ) if ( (tx= iguana_txidfind(coin,&height,&T,txid,coin->bundlescount-1)) != 0 )
@ -790,7 +790,15 @@ HASH_AND_INT(bitcoinrpc,getrawtransaction,txid,verbose)
free(extraspace); free(extraspace);
free(txbytes); free(txbytes);
if ( txobj != 0 ) if ( txobj != 0 )
{
hash2 = iguana_blockhash(coin,height);
jaddbits256(txobj,"blockhash",hash2);
if ( (block= iguana_blockfind("rawtx",coin,hash2)) != 0 )
jaddnum(txobj,"blocktime",block->RO.timestamp);
jaddnum(txobj,"height",height);
jaddnum(txobj,"confirmations",coin->blocks.hwmchain.height - height);
return(jprint(txobj,1)); return(jprint(txobj,1));
}
} }
jaddstr(retjson,"result",txbytes); jaddstr(retjson,"result",txbytes);
char str[65]; printf("txbytes.(%s) len.%d (%s) %s\n",txbytes,len,jprint(retjson,0),bits256_str(str,checktxid)); char str[65]; printf("txbytes.(%s) len.%d (%s) %s\n",txbytes,len,jprint(retjson,0),bits256_str(str,checktxid));

Loading…
Cancel
Save