Browse Source

Test

etomic
jl777 8 years ago
parent
commit
4a21f04c41
  1. 13
      iguana/exchanges/LP_commands.c
  2. 10
      iguana/exchanges/LP_forwarding.c

13
iguana/exchanges/LP_commands.c

@ -257,7 +257,9 @@ forwardhex(pubkey,hex)\n\
return(clonestr("{\"result\":\"success\",\"notifyutxo\":\"received\"}")); return(clonestr("{\"result\":\"success\",\"notifyutxo\":\"received\"}"));
else return(clonestr("{\"result\":\"couldnt add utxo\"}")); else return(clonestr("{\"result\":\"couldnt add utxo\"}"));
} }
else if ( IAMLP != 0 ) else
{
if ( IAMLP != 0 )
{ {
if ( strcmp(method,"register") == 0 ) if ( strcmp(method,"register") == 0 )
{ {
@ -282,6 +284,15 @@ forwardhex(pubkey,hex)\n\
else if ( strcmp(method,"notify") == 0 ) else if ( strcmp(method,"notify") == 0 )
retstr = clonestr("{\"result\":\"success\",\"notify\":\"received\"}"); retstr = clonestr("{\"result\":\"success\",\"notify\":\"received\"}");
} }
else
{
if ( strcmp(method,"register") == 0 )
{
printf("nonLP got (%s)\n",jprint(argjson,0));
retstr = clonestr("{\"result\":\"success\",\"register\":\"received\"}");
}
}
}
if ( retstr != 0 ) if ( retstr != 0 )
{ {
free(retstr); free(retstr);

10
iguana/exchanges/LP_forwarding.c

@ -110,7 +110,7 @@ char *LP_register(bits256 pubkey,char *ipaddr,uint16_t port)
if ( ipaddr == 0 || ipaddr[0] == 0 || is_ipaddr(ipaddr) == 0 || bits256_nonz(pubkey) == 0 ) if ( ipaddr == 0 || ipaddr[0] == 0 || is_ipaddr(ipaddr) == 0 || bits256_nonz(pubkey) == 0 )
return(clonestr("{\"result\":\"illegal ipaddr or null pubkey\"}")); return(clonestr("{\"result\":\"illegal ipaddr or null pubkey\"}"));
nanomsg_transportname(0,pushaddr,ipaddr,port); nanomsg_transportname(0,pushaddr,ipaddr,port);
char str[65]; printf("register.(%s) %s\n",pushaddr,bits256_str(str,pubkey)); //char str[65]; printf("register.(%s) %s\n",pushaddr,bits256_str(str,pubkey));
if ( (ptr= LP_forwardfind(pubkey)) != 0 ) if ( (ptr= LP_forwardfind(pubkey)) != 0 )
{ {
ptr->lasttime = (uint32_t)time(NULL); ptr->lasttime = (uint32_t)time(NULL);
@ -126,13 +126,13 @@ char *LP_register(bits256 pubkey,char *ipaddr,uint16_t port)
char str[65]; printf("%u recreate pushsock for %s <- %s\n",(uint32_t)time(NULL),pushaddr,bits256_str(str,pubkey)); char str[65]; printf("%u recreate pushsock for %s <- %s\n",(uint32_t)time(NULL),pushaddr,bits256_str(str,pubkey));
strcpy(ptr->pushaddr,pushaddr); strcpy(ptr->pushaddr,pushaddr);
if ( (ptr->pushsock= LP_pushsock_create(ptr,pushaddr)) < 0 ) if ( (ptr->pushsock= LP_pushsock_create(ptr,pushaddr)) < 0 )
return(clonestr("{\"result\":\"couldnt recreate pushsock\",\"registered\":0}")); return(clonestr("{\"result\":\"success\",\"status\":\"couldnt recreate pushsock\",\"registered\":0}"));
} //else printf("no need to create identical endpoint\n"); } //else printf("no need to create identical endpoint\n");
} }
return(clonestr("{\"result\":\"already registered\",\"registered\":1}")); return(clonestr("{\"result\":\"success\",\"status\":\"already registered\",\"registered\":1}"));
} }
else if ( (pushsock= LP_pushsock_create(0,pushaddr)) < 0 ) else if ( (pushsock= LP_pushsock_create(0,pushaddr)) < 0 )
return(clonestr("{\"result\":\"couldnt create pushsock\"}")); return(clonestr("{\"result\":\"success\",\"status\":\"couldnt create pushsock\"}"));
else else
{ {
ptr = calloc(1,sizeof(*ptr)); ptr = calloc(1,sizeof(*ptr));
@ -143,7 +143,7 @@ char *LP_register(bits256 pubkey,char *ipaddr,uint16_t port)
portable_mutex_lock(&LP_forwardmutex); portable_mutex_lock(&LP_forwardmutex);
HASH_ADD_KEYPTR(hh,LP_forwardinfos,&ptr->pubkey,sizeof(ptr->pubkey),ptr); HASH_ADD_KEYPTR(hh,LP_forwardinfos,&ptr->pubkey,sizeof(ptr->pubkey),ptr);
portable_mutex_unlock(&LP_forwardmutex); portable_mutex_unlock(&LP_forwardmutex);
char str[65]; printf("registered (%s) -> (%s) pushsock.%d\n",bits256_str(str,pubkey),pushaddr,ptr->pushsock); //char str[65]; printf("registered (%s) -> (%s) pushsock.%d\n",bits256_str(str,pubkey),pushaddr,ptr->pushsock);
LP_hello(ptr); LP_hello(ptr);
return(LP_lookup(pubkey)); return(LP_lookup(pubkey));
} }

Loading…
Cancel
Save