From dfbbc1d48fc393dde3ffe1543d84ea98e7418570 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 9 Nov 2017 11:46:14 +0200 Subject: [PATCH] Test --- iguana/exchanges/LP_peers.c | 20 +++++++++++--------- iguana/exchanges/LP_signatures.c | 7 +++++-- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/iguana/exchanges/LP_peers.c b/iguana/exchanges/LP_peers.c index a7e2479b4..250fe68b2 100644 --- a/iguana/exchanges/LP_peers.c +++ b/iguana/exchanges/LP_peers.c @@ -210,7 +210,8 @@ int32_t LP_numpeers() struct LP_peerinfo *peer,*tmp; int32_t numpeers = 0; HASH_ITER(hh,LP_peerinfos,peer,tmp) { - numpeers++; + if ( peer->isLP != 0 ) + numpeers++; } return(numpeers); } @@ -218,21 +219,22 @@ int32_t LP_numpeers() uint16_t LP_randpeer(char *destip) { struct LP_peerinfo *peer,*tmp; uint16_t port = 0; int32_t n,r,numpeers = 0; - HASH_ITER(hh,LP_peerinfos,peer,tmp) - { - numpeers++; - } + destip[0] = 0; + numpeers = LP_numpeers(); if ( numpeers > 0 ) { r = rand() % numpeers; n = 0; HASH_ITER(hh,LP_peerinfos,peer,tmp) { - if ( n++ == r ) + if ( peer->isLP != 0 ) { - strcpy(destip,peer->ipaddr); - port = peer->port; - break; + if ( n++ == r ) + { + strcpy(destip,peer->ipaddr); + port = peer->port; + break; + } } } } diff --git a/iguana/exchanges/LP_signatures.c b/iguana/exchanges/LP_signatures.c index e28a1974f..72cbd6b43 100644 --- a/iguana/exchanges/LP_signatures.c +++ b/iguana/exchanges/LP_signatures.c @@ -559,7 +559,7 @@ int32_t LP_pubkey_sigcheck(struct LP_pubkeyinfo *pubp,cJSON *item) void LP_notify_pubkeys(void *ctx,int32_t pubsock) { - bits256 zero; uint32_t timestamp; char secpstr[67]; cJSON *reqjson = cJSON_CreateObject(); + bits256 zero; uint32_t timestamp; char LPipaddr[64],secpstr[67]; cJSON *reqjson = cJSON_CreateObject(); memset(zero.bytes,0,sizeof(zero)); jaddstr(reqjson,"method","notify"); jaddstr(reqjson,"rmd160",G.LP_myrmd160str); @@ -570,7 +570,10 @@ void LP_notify_pubkeys(void *ctx,int32_t pubsock) jaddnum(reqjson,"timestamp",timestamp); LP_pubkey_sigadd(reqjson,timestamp,G.LP_privkey,G.LP_mypub25519,G.LP_myrmd160,G.LP_pubsecp); if ( IAMLP != 0 ) - jaddstr(reqjson,"isLP",LP_myipaddr); + { + if ( LP_randpeer(LPipaddr) != 0 ) + jaddstr(reqjson,"isLP",LPipaddr); + } jaddnum(reqjson,"session",G.LP_sessionid); LP_reserved_msg(0,"","",zero,jprint(reqjson,1)); }