diff --git a/basilisk/basilisk_bitcoin.c b/basilisk/basilisk_bitcoin.c index 4d798dc66..304d0a148 100755 --- a/basilisk/basilisk_bitcoin.c +++ b/basilisk/basilisk_bitcoin.c @@ -928,17 +928,22 @@ struct basilisk_spend *basilisk_addspend(struct supernet_info *myinfo,char *symb { int32_t i; struct basilisk_spend *s; // mutex - for (i=0; inumspends; i++) + if ( myinfo->numspends > 0 ) { - if ( myinfo->spends[i].vout == vout && bits256_cmp(txid,myinfo->spends[i].txid) == 0 ) + for (i=0; inumspends; i++) { - char str[65]; printf("found spend.%s v%d skip it\n",bits256_str(str,txid),vout); - return(&myinfo->spends[i]); + if ( myinfo->spends[i].vout == vout && bits256_cmp(txid,myinfo->spends[i].txid) == 0 ) + { + char str[65]; printf("found spend.%s v%d skip it\n",bits256_str(str,txid),vout); + return(&myinfo->spends[i]); + } } } if ( addflag != 0 && i == myinfo->numspends ) { + printf("realloc spends.[%d] %p\n",myinfo->numspends,myinfo->spends); myinfo->spends = realloc(myinfo->spends,sizeof(*myinfo->spends) * (myinfo->numspends+1)); + printf("allocated spends.[%d] %p\n",myinfo->numspends+1,myinfo->spends); s = &myinfo->spends[myinfo->numspends++]; memset(s,0,sizeof(*s)); s->txid = txid; diff --git a/iguana/main.c b/iguana/main.c index 70be31c3c..ed99ac274 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -408,6 +408,7 @@ rm BTC.xz; mksquashfs DB/BTC BTC.xz -comp xz -b 1048576 -comp xz -Xdict-size 102 void mainloop(struct supernet_info *myinfo) { struct iguana_info *coin,*tmp; int32_t i,depth; portable_mutex_t *stack[IGUANA_MAXCOINS]; + uint32_t lasttime = 0; sleep(3); printf("mainloop\n"); while ( 1 ) @@ -415,18 +416,22 @@ void mainloop(struct supernet_info *myinfo) //printf("main iteration\n"); if ( 1 ) { - coin = 0; - depth = 0; - HASH_ITER(hh,myinfo->allcoins,coin,tmp) + if ( time(NULL) > lasttime ) { - portable_mutex_lock(&coin->allcoins_mutex); - stack[depth++] = &coin->allcoins_mutex; - } - iguana_jsonQ(); - if ( depth > 0 ) - { - for (i=depth-1; i>=0; i--) - portable_mutex_unlock(stack[i]); + coin = 0; + depth = 0; + HASH_ITER(hh,myinfo->allcoins,coin,tmp) + { + portable_mutex_lock(&coin->allcoins_mutex); + stack[depth++] = &coin->allcoins_mutex; + } + iguana_jsonQ(); + if ( depth > 0 ) + { + for (i=depth-1; i>=0; i--) + portable_mutex_unlock(stack[i]); + } + lasttime = (uint32_t)time(NULL); } } //pangea_queues(SuperNET_MYINFO(0));