From b2363ea0979dedd2ba138d69e32a7ece10921399 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 27 Sep 2016 13:53:08 -0300 Subject: [PATCH] test --- iguana/iguana777.c | 1 + iguana/iguana_unspents.c | 45 +++++++++++++++++++++++++++++++++------- includes/iguana_funcs.h | 1 + 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 88c3f489e..9afee4f97 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -836,6 +836,7 @@ void iguana_callcoinstart(struct supernet_info *myinfo,struct iguana_info *coin) memset(zero.bytes,0,sizeof(zero)); if ( (bp= iguana_bundlecreate(coin,&bundlei,0,*(bits256 *)coin->chain->genesis_hashdata,zero,1)) != 0 ) bp->bundleheight = 0; + iguana_unspents_markinit(myinfo,coin); } void iguana_coinloop(void *arg) diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 926c0e8e6..2e0972ed0 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -839,13 +839,7 @@ int32_t iguana_staker_sort(struct iguana_info *coin,bits256 *hash2p,uint8_t *ref int32_t iguana_markedunspents_find(struct iguana_info *coin,int32_t *firstslotp,bits256 txid,int32_t vout) { - static int32_t didinit; - int32_t i; //char str[65]; - if ( didinit == 0 ) - { - printf("Load recent unspents here!\n"); - didinit = 1; - } + int32_t i; *firstslotp = -1; if ( bits256_nonz(txid) != 0 && vout >= 0 ) { @@ -902,6 +896,43 @@ void iguana_unspents_mark(struct supernet_info *myinfo,struct iguana_info *coin, } } +void iguana_unspents_markinit(struct supernet_info *myinfo,struct iguana_info *coin) +{ + static int32_t didinit; + if ( didinit == 0 ) + { + char *filestr,fname[1024]; long filesize; bits256 filetxid; cJSON *array,*item; int32_t i,filevout,n,firstslot; + sprintf(fname,"%s/%s/utxo.json",GLOBAL_DBDIR,coin->symbol); + if ( (filestr= OS_filestr(&filesize,fname)) != 0 ) + { + if ( (array= cJSON_Parse(filestr)) != 0 ) + { + if ( is_cJSON_Array(array) != 0 && (n= cJSON_GetArraySize(array)) > 0 ) + { + for (i=0; i= 0 ) + { + char str[65]; printf("slot.[%d] <- %s/v%d\n",firstslot,bits256_str(str,filetxid),filevout); + coin->markedunspents[firstslot] = filetxid; + coin->markedunspents[firstslot].ushorts[15] = filevout; + } + } + } + } + free_json(array); + } + free(filestr); + } + didinit = 1; + } +} + int32_t iguana_RTunspent_check(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_outpoint outpt) { int32_t firstslot; diff --git a/includes/iguana_funcs.h b/includes/iguana_funcs.h index d067d3e4e..6ecc3f513 100755 --- a/includes/iguana_funcs.h +++ b/includes/iguana_funcs.h @@ -422,6 +422,7 @@ void revcalc_rmd160_sha256(uint8_t rmd160[20],bits256 revhash); struct iguana_utxo iguana_utxofind(struct iguana_info *coin,struct iguana_outpoint spentpt,int32_t *RTspendflagp,int32_t lockflag); int32_t iguana_vinifind(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *spentfrom,bits256 txid,int32_t vout); int32_t iguana_scriptsigextract(struct supernet_info *myinfo,struct iguana_info *coin,uint8_t *script,int32_t maxsize,bits256 txid,int32_t vini); +void iguana_unspents_markinit(struct supernet_info *myinfo,struct iguana_info *coin); bits256 iguana_str2priv(struct supernet_info *myinfo,struct iguana_info *coin,char *str); int32_t iguana_RTspentflag(struct supernet_info *myinfo,struct iguana_info *coin,uint64_t *RTspendp,int32_t *spentheightp,struct iguana_ramchain *ramchain,struct iguana_outpoint spentpt,int32_t height,int32_t minconf,int32_t maxconf,uint64_t amount);