From f65aab63853f173703ceeff2d438f0ae9e526e7b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 10 May 2016 19:27:41 -0500 Subject: [PATCH] test --- iguana/iguana_instantdex.c | 2 +- iguana/iguana_json.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/iguana/iguana_instantdex.c b/iguana/iguana_instantdex.c index 866862d35..87022e230 100755 --- a/iguana/iguana_instantdex.c +++ b/iguana/iguana_instantdex.c @@ -374,7 +374,7 @@ char *instantdex_sendcmd(struct supernet_info *myinfo,struct instantdex_offer *o iguana_queue_send(coin,addr,0,serialized,"InstantDEX",msg->sig.allocsize,0,1); if ( --hops <= 0 ) break; - } else printf("skip.%d addr.%p (%s)\n",j,addr,addr!=0?addr->ipaddr:""); + } else printf("skip.%d addr.%p (%s) max.%d hops.%d\n",j,addr,addr!=0?addr->ipaddr:"",max,hops); } } else printf("cant find coin.%p or no ranked.%d\n",coin,max); free(msg); //free(hexstr), diff --git a/iguana/iguana_json.c b/iguana/iguana_json.c index d36f7805f..66af15aef 100755 --- a/iguana/iguana_json.c +++ b/iguana/iguana_json.c @@ -657,7 +657,7 @@ STRING_ARG(iguana,pausecoin,activecoin) TWO_STRINGS(iguana,addnode,activecoin,ipaddr) { - struct iguana_peer *addr; + struct iguana_peer *addr; int32_t i,n; if ( coin == 0 ) coin = iguana_coinfind(activecoin); printf("coin.%p.[%s] addnode.%s -> %s\n",coin,coin!=0?coin->symbol:"",activecoin,ipaddr); @@ -668,7 +668,24 @@ TWO_STRINGS(iguana,addnode,activecoin,ipaddr) { addr->supernet = 1; if ( addr->usock >= 0 ) + { + if ( (n= coin->peers.numranked) != 0 ) + { + for (i=0; ipeers.ranked[i] ) + break; + } + if ( i == n ) + { + if ( i == IGUANA_MAXPEERS ) + i--; + else coin->peers.numranked = n+1; + coin->peers.ranked[i] = addr; + } + } return(clonestr("{\"result\":\"peer was already connected\"}")); + } if ( addr->pending == 0 ) { addr->pending = (uint32_t)time(NULL);