Browse Source

Test

etomic
jl777 8 years ago
parent
commit
5f3e2b8373
  1. 8
      iguana/exchanges/LP_forwarding.c
  2. 2
      iguana/exchanges/LP_rpc.c

8
iguana/exchanges/LP_forwarding.c

@ -41,6 +41,8 @@ struct LP_forwardinfo *LP_forwardfind(bits256 pubkey)
char *LP_lookup(bits256 pubkey)
{
if ( bits256_nonz(pubkey) == 0 )
return(clonestr("{\"error\":\"illegal pubkey\"}"));
if ( LP_forwardfind(pubkey) != 0 )
return(clonestr("{\"result\":\"success\",\"forwarding\":1}"));
else return(clonestr("{\"error\":\"notfound\"}"));
@ -49,6 +51,8 @@ char *LP_lookup(bits256 pubkey)
char *LP_register(bits256 pubkey,char *pushaddr)
{
struct LP_forwardinfo *ptr=0; int32_t pushsock;
if ( pushaddr == 0 || pushaddr[0] == 0 || bits256_nonz(pubkey) == 0 )
return(clonestr("{\"error\":\"illegal ipaddr\"}"));
if ( strlen(pushaddr) <= strlen("tcp://") || is_ipaddr(pushaddr+strlen("tcp://")) == 0 )
return(clonestr("{\"error\":\"illegal ipaddr\"}"));
if ( (ptr= LP_forwardfind(pubkey)) != 0 )
@ -111,6 +115,8 @@ char *LP_forward(bits256 pubkey,char *hexstr)
void LP_forwarding_register(bits256 pubkey,char *pushaddr)
{
char *retstr; cJSON *retjson; struct LP_peerinfo *peer,*tmp; int32_t retval = -1;
if ( pushaddr == 0 || pushaddr[0] == 0 || bits256_nonz(pubkey) == 0 )
return;
HASH_ITER(hh,LP_peerinfos,peer,tmp)
{
if ( (retstr= issue_LP_register(peer->ipaddr,peer->port,pubkey,pushaddr)) != 0 )
@ -131,6 +137,8 @@ void LP_forwarding_register(bits256 pubkey,char *pushaddr)
int32_t LP_pubkey_send(bits256 pubkey,char *jsonstr,int32_t freeflag)
{
struct LP_forwardinfo *ptr; struct LP_peerinfo *peer,*tmp; char *hexstr,*retstr; int32_t len,retval = -1; cJSON *retjson;
if ( jsonstr == 0 || jsonstr[0] == 0 || bits256_nonz(pubkey) == 0 )
return(-1);
if ( IAMLP != 0 && (ptr= LP_forwardfind(pubkey)) != 0 && ptr->pushsock >= 0 && ptr->lasttime > time(NULL)-LP_KEEPALIVE )
{
return(LP_send(ptr->pushsock,jsonstr,1));

2
iguana/exchanges/LP_rpc.c

@ -71,7 +71,7 @@ char *issue_LP_register(char *destip,uint16_t destport,bits256 pubkey,char *push
char *issue_LP_lookup(char *destip,uint16_t destport,bits256 pubkey)
{
char url[512],str[65];
sprintf(url,"http://%s:%u/api/stats/register?pubkey=%s",destip,destport,bits256_str(str,pubkey));
sprintf(url,"http://%s:%u/api/stats/lookup?pubkey=%s",destip,destport,bits256_str(str,pubkey));
//printf("getutxo.(%s)\n",url);
return(issue_curl(url));
}

Loading…
Cancel
Save