From df96e66ac2eb96bbe69b6db77ec531d3c9f79eb4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 24 Aug 2016 01:22:47 -0300 Subject: [PATCH] test --- iguana/iguana_realtime.c | 17 +++++++++++------ iguana/iguana_volatiles.c | 10 ++++++++++ iguana/main.c | 4 ++-- includes/iguana_funcs.h | 1 + includes/iguana_structs.h | 2 +- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index 205413b05..85f5075d7 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -468,6 +468,11 @@ int32_t iguana_realtime_update(struct supernet_info *myinfo,struct iguana_info * } #endif +#undef uthash_malloc +#undef uthash_free +#define uthash_malloc(size) ((coin->RTHASHMEM.ptr == 0) ? mycalloc('u',1,size) : iguana_memalloc(&coin->RTHASHMEM,size,1)) +#define uthash_free(mem,size) ((coin->RTHASHMEM.ptr == 0) ? myfree(mem,size) : 0) + struct iguana_RTaddr *iguana_RTaddrfind(struct iguana_info *coin,uint8_t *rmd160,char *coinaddr) { struct iguana_RTaddr *RTaddr; int32_t len; char _coinaddr[64]; @@ -673,7 +678,7 @@ void iguana_RTtxid_free(struct iguana_RTtxid *RTptr) void iguana_RTdataset_free(struct iguana_info *coin) { - struct iguana_RTtxid *RTptr,*tmp; struct iguana_RTaddr *RTaddr,*tmp2; struct iguana_hhutxo *hhutxo,*tmphh; + struct iguana_RTtxid *RTptr,*tmp; struct iguana_RTaddr *RTaddr,*tmp2; struct iguana_hhutxo *hhutxo; HASH_ITER(hh,coin->RTdataset,RTptr,tmp) { HASH_DELETE(hh,coin->RTdataset,RTptr); @@ -684,11 +689,8 @@ void iguana_RTdataset_free(struct iguana_info *coin) HASH_DELETE(hh,coin->RTaddrs,RTaddr); free(RTaddr); } - HASH_ITER(hh,coin->utxotable,hhutxo,tmphh) - { - HASH_DELETE(hh,coin->utxotable,hhutxo); - free(hhutxo); - } + iguana_hhutxo_purge(coin); + iguana_memreset(&coin->RTHASHMEM); } struct iguana_RTtxid *iguana_RTtxid_create(struct iguana_info *coin,struct iguana_block *block,int64_t polarity,int32_t txi,int32_t txn_count,bits256 txid,int32_t numvouts,int32_t numvins,uint32_t locktime,uint32_t version,uint32_t timestamp) @@ -782,6 +784,9 @@ void iguana_RTreset(struct iguana_info *coin) coin->lastRTheight = 0; coin->RTheight = coin->firstRTheight; iguana_RTdataset_free(coin); + if ( coin->RTHASHMEM.ptr == 0 ) + iguana_meminit(&coin->RTHASHMEM,"RTHASHMEM",0,1024*1024*1024,0); + iguana_memreset(&coin->RTHASHMEM); printf("%s RTreset %d\n",coin->symbol,coin->RTheight); } diff --git a/iguana/iguana_volatiles.c b/iguana/iguana_volatiles.c index 84a486d5b..d03e592e6 100755 --- a/iguana/iguana_volatiles.c +++ b/iguana/iguana_volatiles.c @@ -100,6 +100,16 @@ int32_t iguana_utxoupdate(struct iguana_info *coin,int16_t spent_hdrsi,uint32_t } #endif +void iguana_hhutxo_purge(struct iguana_info *coin) +{ + struct iguana_hhutxo *hhutxo,*tmp; + HASH_ITER(hh,coin->utxotable,hhutxo,tmp) + { + HASH_DELETE(hh,coin->utxotable,hhutxo); + free(hhutxo); + } +} + struct iguana_hhutxo *iguana_hhutxofind(struct iguana_info *coin,uint64_t uval) { struct iguana_hhutxo *hhutxo; diff --git a/iguana/main.c b/iguana/main.c index 09c460fd6..2135b8c98 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -553,10 +553,10 @@ void iguana_appletests(struct supernet_info *myinfo) bitcoin_sharedsecret(myinfo->ctx,hash2,pubkey,33); printf("secp256k1 elapsed %.3f for %d iterations\n",OS_milliseconds() - startmillis,i); getchar();**/ - if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"protover\":70002,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":14631,\"rpc\":14632,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":64,\"endpend\":64,\"services\":129,\"maxpeers\":256,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":1,\"poll\":100}"),0,myinfo->rpcport)) != 0 ) + if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"protover\":70002,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":14631,\"rpc\":14632,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":64,\"endpend\":64,\"services\":129,\"maxpeers\":8,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":1,\"poll\":100}"),0,myinfo->rpcport)) != 0 ) { free(str); - if ( 0 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"portp2p\":8333,\"RELAY\":0,\"VALIDATE\":0,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":8,\"newcoin\":\"BTC\",\"active\":0,\"numhelpers\":1,\"poll\":100}"),0,myinfo->rpcport)) != 0 ) + if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"portp2p\":8333,\"RELAY\":0,\"VALIDATE\":0,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":8,\"newcoin\":\"BTC\",\"active\":0,\"numhelpers\":1,\"poll\":100}"),0,myinfo->rpcport)) != 0 ) { free(str); if ( 0 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"agent\":\"SuperNET\",\"method\":\"login\",\"handle\":\"alice\",\"password\":\"alice\",\"passphrase\":\"alice\"}"),0,myinfo->rpcport)) != 0 ) diff --git a/includes/iguana_funcs.h b/includes/iguana_funcs.h index ec18b5632..f28760bd9 100755 --- a/includes/iguana_funcs.h +++ b/includes/iguana_funcs.h @@ -321,6 +321,7 @@ long iguana_spentsfile(struct iguana_info *coin,int32_t n); uint8_t *iguana_rmdarray(struct supernet_info *myinfo,struct iguana_info *coin,int32_t *numrmdsp,cJSON *array,int32_t firsti); int64_t iguana_RTunspents(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *array,int32_t minconf,int32_t maxconf,uint8_t *rmdarray,int32_t numrmds,int32_t lastheight,struct iguana_outpoint *unspents,int32_t *numunspentsp,char *remoteaddr,int32_t includespent); uint8_t *iguana_walletrmds(struct supernet_info *myinfo,struct iguana_info *coin,int32_t *numrmdsp); +void iguana_hhutxo_purge(struct iguana_info *coin); char *iguana_bundleaddrs(struct iguana_info *coin,int32_t hdrsi); uint32_t iguana_sparseaddpk(uint8_t *bits,int32_t width,uint32_t tablesize,uint8_t rmd160[20],struct iguana_pkhash *P,uint32_t pkind,struct iguana_ramchain *ramchain); int32_t iguana_vinscriptparse(struct iguana_info *coin,struct vin_info *vp,uint32_t *sigsizep,uint32_t *pubkeysizep,uint32_t *p2shsizep,uint32_t *suffixp,uint8_t *vinscript,int32_t scriptlen); diff --git a/includes/iguana_structs.h b/includes/iguana_structs.h index d14e8c6b4..aaa66a29f 100755 --- a/includes/iguana_structs.h +++ b/includes/iguana_structs.h @@ -454,7 +454,7 @@ struct iguana_info int32_t disableUTXO,initialheight,mapflags,minconfirms,numrecv,bindsock,isRT,backstop,blocksrecv,merging,firstRTheight,polltimeout,numreqtxids,allhashes,balanceflush,basilisk_busy; bits256 reqtxids[64]; void *launched,*started,*rpcloop; uint64_t bloomsearches,bloomhits,bloomfalse,collisions,txfee_perkb,txfee; - uint8_t *blockspace; int32_t blockspacesize; struct OS_memspace blockMEM; + uint8_t *blockspace; int32_t blockspacesize; struct OS_memspace blockMEM,RTHASHMEM; bits256 APIblockhash,APItxid; char *APIblockstr; struct iguana_hhutxo *utxotable; #ifdef DEPRECATED_HHUTXO