Browse Source

Test

etomic
jl777 7 years ago
parent
commit
828314c43d
  1. 49
      iguana/exchanges/LP_socket.c

49
iguana/exchanges/LP_socket.c

@ -295,23 +295,38 @@ struct electrum_info *electrum_server(char *symbol,struct electrum_info *ep)
struct electrum_info *LP_electrum_info(char *symbol,char *ipaddr,uint16_t port,int32_t bufsize) struct electrum_info *LP_electrum_info(char *symbol,char *ipaddr,uint16_t port,int32_t bufsize)
{ {
struct electrum_info *ep; struct stritem *sitem; char name[512],*str = "init string"; struct electrum_info *ep=0; int32_t i; struct stritem *sitem; char name[512],*str = "init string";
ep = calloc(1,sizeof(*ep) + bufsize); portable_mutex_lock(&LP_electrummutex);
ep->sock = LP_socket(0,ipaddr,port); for (i=0; i<Num_electrums; i++)
safecopy(ep->symbol,symbol,sizeof(ep->symbol)); {
safecopy(ep->ipaddr,ipaddr,sizeof(ep->ipaddr)); ep = Electrums[i];
ep->port = port; if ( strcmp(ep->ipaddr,ipaddr) == 0 && ep->port == port && strcmp(ep->symbol,symbol) == 0 )
ep->bufsize = bufsize; {
ep->lasttime = (uint32_t)time(NULL); printf("%s.(%s:%u) already an electrum server\n",symbol,ipaddr,port);
sprintf(name,"%s_%s_%u_electrum_sendQ",symbol,ipaddr,port); break;
queue_enqueue(name,&ep->sendQ,queueitem(str)); }
if ( (sitem= queue_dequeue(&ep->sendQ)) == 0 && strcmp(sitem->str,str) != 0 ) ep = 0;
printf("error with string sendQ sitem.%p (%s)\n",sitem,sitem==0?0:sitem->str); }
sprintf(name,"%s_%s_%u_electrum_pendingQ",symbol,ipaddr,port); portable_mutex_unlock(&LP_electrummutex);
queue_enqueue(name,&ep->pendingQ,queueitem(str)); if ( ep == 0 )
if ( (sitem= queue_dequeue(&ep->pendingQ)) == 0 && strcmp(sitem->str,str) != 0 ) {
printf("error with string pendingQ sitem.%p (%s)\n",sitem,sitem==0?0:sitem->str); ep = calloc(1,sizeof(*ep) + bufsize);
electrum_server(symbol,ep); ep->sock = LP_socket(0,ipaddr,port);
safecopy(ep->symbol,symbol,sizeof(ep->symbol));
safecopy(ep->ipaddr,ipaddr,sizeof(ep->ipaddr));
ep->port = port;
ep->bufsize = bufsize;
ep->lasttime = (uint32_t)time(NULL);
sprintf(name,"%s_%s_%u_electrum_sendQ",symbol,ipaddr,port);
queue_enqueue(name,&ep->sendQ,queueitem(str));
if ( (sitem= queue_dequeue(&ep->sendQ)) == 0 && strcmp(sitem->str,str) != 0 )
printf("error with string sendQ sitem.%p (%s)\n",sitem,sitem==0?0:sitem->str);
sprintf(name,"%s_%s_%u_electrum_pendingQ",symbol,ipaddr,port);
queue_enqueue(name,&ep->pendingQ,queueitem(str));
if ( (sitem= queue_dequeue(&ep->pendingQ)) == 0 && strcmp(sitem->str,str) != 0 )
printf("error with string pendingQ sitem.%p (%s)\n",sitem,sitem==0?0:sitem->str);
electrum_server(symbol,ep);
}
return(ep); return(ep);
} }

Loading…
Cancel
Save