Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
e35759ba35
  1. 2
      iguana/iguana777.c
  2. 18
      iguana/iguana_peers.c
  3. 1
      iguana/main.c

2
iguana/iguana777.c

@ -319,7 +319,7 @@ void iguana_helper(void *arg)
MEMB = mycalloc('b',IGUANA_MAXBUNDLESIZE,sizeof(*MEMB)); MEMB = mycalloc('b',IGUANA_MAXBUNDLESIZE,sizeof(*MEMB));
while ( 1 ) while ( 1 )
{ {
iguana_jsonQ(); //iguana_jsonQ();
flag = 0; flag = 0;
if ( (ptr= queue_dequeue(&helperQ,0)) != 0 ) if ( (ptr= queue_dequeue(&helperQ,0)) != 0 )
{ {

18
iguana/iguana_peers.c

@ -925,6 +925,8 @@ void iguana_dedicatedloop(struct iguana_info *coin,struct iguana_peer *addr)
bufsize = IGUANA_MAXPACKETSIZE; bufsize = IGUANA_MAXPACKETSIZE;
buf = mycalloc('r',1,bufsize); buf = mycalloc('r',1,bufsize);
printf("send version myservices.%llu to (%s)\n",(long long)coin->myservices,addr->ipaddr); printf("send version myservices.%llu to (%s)\n",(long long)coin->myservices,addr->ipaddr);
//if ( addr->supernet != 0 )
// iguana_send_supernet(coin,addr,"{\"agent\":\"SuperNET\",\"method\":\"getpeers\"}",0);
iguana_send_version(coin,addr,coin->myservices); iguana_send_version(coin,addr,coin->myservices);
sleep(1+(rand()%5)); sleep(1+(rand()%5));
iguana_queue_send(coin,addr,0,serialized,"getaddr",0,0,0); iguana_queue_send(coin,addr,0,serialized,"getaddr",0,0,0);
@ -982,17 +984,25 @@ void iguana_dedicatedloop(struct iguana_info *coin,struct iguana_peer *addr)
} }
} }
} }
if ( flag == 0 )
{
if ( run++ > 1000 )
{
//printf("sleep\n");
usleep(100000);
}
else if ( addr->rank != 1 )
usleep(coin->polltimeout*100 + 0*(rand() % (coin->polltimeout*100)));
else usleep(100 + coin->polltimeout*1000);
} else run >>= 2;
} }
if ( flag != 0 ) if ( flag != 0 )
run = 0; run = 0;
else if ( flag == 0 ) else if ( addr->supernet != 0 && time(NULL) > lastping+10 )
{
if ( addr->supernet != 0 && time(NULL) > lastping+10 )
{ {
iguana_send_supernet(coin,addr,"{\"agent\":\"SuperNET\",\"method\":\"getpeers\"}",0); iguana_send_supernet(coin,addr,"{\"agent\":\"SuperNET\",\"method\":\"getpeers\"}",0);
lastping = (uint32_t)time(NULL); lastping = (uint32_t)time(NULL);
} }
} else run >>= 2;
if ( coin->isRT != 0 && addr->rank > coin->MAXPEERS && (rand() % 100) == 0 ) if ( coin->isRT != 0 && addr->rank > coin->MAXPEERS && (rand() % 100) == 0 )
{ {
printf("isRT and low rank.%d ",addr->rank); printf("isRT and low rank.%d ",addr->rank);

1
iguana/main.c

@ -331,6 +331,7 @@ void iguana_main(void *arg)
while ( 1 ) while ( 1 )
{ {
flag = 0; flag = 0;
iguana_jsonQ();
if ( flag == 0 )//|| addr->rank >= (coin->peers.numranked>>1) ) if ( flag == 0 )//|| addr->rank >= (coin->peers.numranked>>1) )
{ {
struct iguana_helper *ptr; struct iguana_helper *ptr;

Loading…
Cancel
Save