From 63b87552a0d4c97a3ed02301d7dbb4f34503e224 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Jun 2016 07:51:24 -0300 Subject: [PATCH] test --- basilisk/basilisk.c | 26 +++++++++++++++++--------- basilisk/basilisk_CMD.c | 7 ------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index 576a30584..c0538d878 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -531,6 +531,13 @@ void basilisk_wait(struct supernet_info *myinfo,struct iguana_info *coin) } } +char *basilisk_respond_ping(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk) +{ + char *retstr=0; + printf("PING got %d from (%s)\n",datalen,remoteaddr!=0?remoteaddr:""); + return(retstr); +} + void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t senderipbits,char *type,uint32_t basilisktag,uint8_t *data,int32_t datalen) { cJSON *valsobj; char *symbol,*retstr=0,remoteaddr[64],CMD[4],cmd[4]; int32_t height,origlen,from_basilisk,i,timeoutmillis,flag,numrequired,jsonlen; uint8_t *origdata; struct iguana_info *coin=0; bits256 hash; struct iguana_peer *addr = _addr; @@ -690,21 +697,23 @@ void basilisks_loop(void *arg) } } //portable_mutex_unlock(&myinfo->allcoins_mutex); - if ( myinfo->RELAYID >= 0 ) + if ( (rand() % 10) == 0 && myinfo->RELAYID >= 0 ) { struct iguana_peer *addr; struct basilisk_relay *rp; int32_t i,j,datalen=0; uint8_t data[1024]; + data[datalen++] = myinfo->numrelays; + for (j=0; jnumrelays; j++) + data[datalen++] = myinfo->relays[j].status; for (i=0; inumrelays; i++) { rp = &myinfo->relays[i]; - if ( (addr= iguana_peerfindipbits(btcd,rp->ipbits,1)) != 0 && addr->usock >= 0 ) + addr = 0; + if ( rp->ipbits == myinfo->myaddr.myipbits ) + basilisk_msgprocess(myinfo,0,0,"PIN",0,&data[sizeof(struct iguana_msghdr)],datalen); + else if ( (addr= iguana_peerfindipbits(btcd,rp->ipbits,1)) != 0 && addr->usock >= 0 ) { - data[datalen++] = myinfo->numrelays; - for (j=0; jnumrelays; j++) - data[datalen++] = myinfo->relays[j].status; - if ( iguana_queue_send(addr,0,&data[sizeof(struct iguana_msghdr)],"SuperNET",datalen) != datalen ) + if ( iguana_queue_send(addr,0,&data[sizeof(struct iguana_msghdr)],"SuperNETPIN",datalen) != datalen ) printf("error sending %d to (%s)\n",datalen,addr->ipaddr); else printf("sent %d to (%s)\n",datalen,addr->ipaddr); - flag++; } } } @@ -713,8 +722,7 @@ void basilisks_loop(void *arg) //for (i=0; iRELAYNODE == 0 && coin->VALIDATENODE == 0 && coin->active != 0 && coin->chain->userpass[0] != 0 && coin->MAXPEERS == 1 ) // basilisk_bitcoinscan(coin,blockspace,&RAWMEM); - if ( flag == 0 ) - usleep(1000000); + usleep(100000); } } diff --git a/basilisk/basilisk_CMD.c b/basilisk/basilisk_CMD.c index 8b6c11553..764b9ec42 100755 --- a/basilisk/basilisk_CMD.c +++ b/basilisk/basilisk_CMD.c @@ -103,13 +103,6 @@ char *basilisk_respond_instantdex(struct supernet_info *myinfo,char *CMD,void *a return(retstr); } -char *basilisk_respond_ping(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk) -{ - char *retstr=0; - printf("PING got %d from (%s)\n",datalen,remoteaddr!=0?remoteaddr:""); - return(retstr); -} - char *basilisk_respond_addrelay(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk) { char *ipaddr,*retstr=0;