From 20e6870efa790e97520c3514bd4e990b23e08514 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 Apr 2016 18:09:58 -0500 Subject: [PATCH] test --- iguana/iguana777.c | 5 ++++- iguana/iguana_accept.c | 2 ++ iguana/iguana_msg.c | 8 ++++---- iguana/iguana_peers.c | 6 +++--- iguana/main.c | 2 +- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 34c1b62af..70a240d91 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -674,6 +674,8 @@ void iguana_coinloop(void *arg) if ( coin->peers.numranked < (7*coin->MAXPEERS/8) && now > coin->lastpossible ) { //fprintf(stderr,"possible\n"); + if ( coin->peers.numranked > 0 && (now % 60) == 0 ) + iguana_send_ping(coin,coin->peers.ranked[rand() % coin->peers.numranked]); coin->lastpossible = iguana_possible_peer(coin,0); // tries to connect to new peers } } @@ -681,7 +683,8 @@ void iguana_coinloop(void *arg) { if ( coin->peers.numranked < ((7*coin->MAXPEERS)>>3) && now > coin->lastpossible ) { - //fprintf(stderr,"possible\n"); + if ( coin->peers.numranked > 0 && (now % 60) == 0 ) + iguana_send_ping(coin,coin->peers.ranked[rand() % coin->peers.numranked]); coin->lastpossible = iguana_possible_peer(coin,0); // tries to connect to new peers } } diff --git a/iguana/iguana_accept.c b/iguana/iguana_accept.c index 1fc0c3bd2..3a7b9ae2d 100755 --- a/iguana/iguana_accept.c +++ b/iguana/iguana_accept.c @@ -234,5 +234,7 @@ int32_t iguana_peeraddrrequest(struct iguana_info *coin,struct iguana_peer *addr } iguana_rwvarint(1,&space[sizeof(H)],&x); printf("addrrequest: sendlen.%d x.%d\n",sendlen,(int32_t)x); + if ( x == 0 ) + return(-1); return(sendlen); } \ No newline at end of file diff --git a/iguana/iguana_msg.c b/iguana/iguana_msg.c index 388655955..9f1e62a71 100755 --- a/iguana/iguana_msg.c +++ b/iguana/iguana_msg.c @@ -217,7 +217,7 @@ void iguana_gotverack(struct iguana_info *coin,struct iguana_peer *addr) uint8_t serialized[sizeof(struct iguana_msghdr)]; if ( addr != 0 ) { - //printf("gotverack from %s\n",addr->ipaddr); + printf("gotverack from %s\n",addr->ipaddr); addr->A.nTime = (uint32_t)time(NULL); iguana_queue_send(coin,addr,0,serialized,"getaddr",0,0,0); if ( addr->supernet != 0 ) @@ -237,7 +237,7 @@ void iguana_gotaddr(struct iguana_info *coin,struct iguana_peer *addr,struct igu if ( port != 0 ) sprintf(ipport,"%s:%d",ipaddr,port); iguana_possible_peer(coin,ipport); - //printf("gotaddr.(%s:%d)\n",ipaddr,port); + printf("gotaddr.(%s:%d) from (%s)\n",ipaddr,port,addr->ipaddr); } void iguana_gotping(struct iguana_info *coin,struct iguana_peer *addr,uint64_t nonce,uint8_t *data) @@ -264,7 +264,7 @@ int32_t iguana_send_ping(struct iguana_info *coin,struct iguana_peer *addr) addr->pingnonce = ((nonce & 0xffffffff) << 32) | ((uint32_t)addr->ipbits & 0xffffffff); addr->pingtime = (uint32_t)time(NULL); } - //printf("pingnonce.%llx\n",(long long)nonce); + printf("pingnonce.%llx from (%s)\n",(long long)nonce,addr->ipaddr); len = iguana_rwnum(1,&serialized[sizeof(struct iguana_msghdr)],sizeof(uint64_t),&nonce); if ( addr->supernet != 0 ) iguana_send_supernet(coin,addr,SUPERNET_GETPEERSTR,0); @@ -540,7 +540,7 @@ int32_t iguana_msgparser(struct iguana_info *coin,struct iguana_peer *addr,struc strcpy(addr->lastcommand,H->command); } retval = 0; - //printf("iguana_msgparser %s parse.(%s)\n",addr->ipaddr,H->command); + printf("iguana_msgparser from (%s) parse.(%s) len.%d\n",addr->ipaddr,H->command,recvlen); if ( strncmp(H->command,"SuperNET",strlen("SuperNET")) == 0 ) { addr->supernet = 1; diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index 4cc6e6f2e..d872075e2 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -463,7 +463,7 @@ int32_t iguana_queue_send(struct iguana_info *coin,struct iguana_peer *addr,int3 packet->embargo.millis += delay; } memcpy(packet->serialized,serialized,datalen); - //printf("%p queue send.(%s) %d to (%s)\n",packet,serialized+4,datalen,addr->ipaddr); + printf("%p queue send.(%s) %d to (%s)\n",packet,serialized+4,datalen,addr->ipaddr); queue_enqueue("sendQ",&addr->sendQ,&packet->DL,0); return(datalen); } @@ -757,12 +757,12 @@ void *iguana_iAddriterator(struct iguana_info *coin,struct iguana_iAddr *iA) uint32_t iguana_possible_peer(struct iguana_info *coin,char *ipaddr) { char checkaddr[64]; uint64_t ipbits; uint32_t now = (uint32_t)time(NULL); int32_t i,n; struct iguana_iAddr *iA; - if ( ipaddr != 0 ) + if ( ipaddr != 0 && ipaddr[0] != 0 ) { for (i=n=0; iMAXPEERS; i++) if ( strcmp(ipaddr,coin->peers.active[i].ipaddr) == 0 ) { - printf("%s possible peer.%s already there\n",coin->symbol,ipaddr); + printf("%s possible peer.(%s) %x already there\n",coin->symbol,ipaddr,(uint32_t)coin->peers.active[i].ipbits); return(0); } queue_enqueue("possibleQ",&coin->possibleQ,queueitem(ipaddr),1); diff --git a/iguana/main.c b/iguana/main.c index efa9e5e07..304b901f7 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -1142,7 +1142,7 @@ void iguana_appletests(struct supernet_info *myinfo) exit(-1); } sleep(1);*/ - if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"prefetchlag\":13,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":500,\"endpend\":500,\"services\":129,\"maxpeers\":64,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":4,\"poll\":1}"),0,myinfo->rpcport)) != 0 ) + if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"prefetchlag\":13,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":500,\"endpend\":500,\"services\":128,\"maxpeers\":64,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":4,\"poll\":1}"),0,myinfo->rpcport)) != 0 ) { free(str); if ( 0 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":1024,\"maxpeers\":256,\"newcoin\":\"BTCD\",\"active\":1}"),0,myinfo->rpcport)) != 0 )