Browse Source

test

release/v0.1
jl777 8 years ago
parent
commit
681f772843
  1. 13
      basilisk/basilisk_bitcoin.c
  2. 27
      iguana/main.c

13
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; i<myinfo->numspends; i++)
if ( myinfo->numspends > 0 )
{
if ( myinfo->spends[i].vout == vout && bits256_cmp(txid,myinfo->spends[i].txid) == 0 )
for (i=0; i<myinfo->numspends; 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;

27
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));

Loading…
Cancel
Save