Browse Source

Merge pull request #630 from jl777/jl777

tweak network broadcast
patch-3
jl777 7 years ago
committed by GitHub
parent
commit
193c76a1c4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      iguana/exchanges/LP_nativeDEX.c
  2. 11
      iguana/exchanges/LP_network.c
  3. 3
      iguana/exchanges/LP_signatures.c
  4. 2
      iguana/exchanges/prices/autoprice

23
iguana/exchanges/LP_nativeDEX.c

@ -1047,7 +1047,6 @@ void queue_loop(void *ctx)
continue;
}
LP_millistats_update(&queue_loop_stats);
//printf("LP_Q.%p next.%p prev.%p\n",LP_Q,LP_Q!=0?LP_Q->next:0,LP_Q!=0?LP_Q->prev:0);
n = nonz = flag = 0;
DL_FOREACH_SAFE(LP_Q,ptr,tmp)
{
@ -1055,6 +1054,7 @@ void queue_loop(void *ctx)
flag = 0;
if ( ptr->sock >= 0 )
{
//printf("sock.%d len.%d notready.%d\n",ptr->sock,ptr->msglen,ptr->notready);
if ( ptr->notready == 0 || (LP_rand() % ptr->notready) == 0 )
{
if ( LP_sockcheck(ptr->sock) > 0 )
@ -1081,27 +1081,38 @@ void queue_loop(void *ctx)
{
if ( (sentbytes= nn_send(ptr->sock,linebuf,k,0)) != k )
printf("%d LP_send mmjson sent %d instead of %d\n",n,sentbytes,k);
else flag++;
else
{
flag++;
ptr->sock = -1;
}
//printf("k.%d SEND.(%s) sock.%d\n",k,(char *)ptr->msg,ptr->sock);
}
//printf("k.%d flag.%d SEND.(%s) sock.%d\n",k,flag,(char *)ptr->msg,ptr->sock);
}
free_json(json);
}
if ( flag == 0 )
{
//printf("len.%d SEND.(%s) sock.%d\n",ptr->msglen,(char *)ptr->msg,ptr->sock);
// printf("non-encoded len.%d SEND.(%s) sock.%d\n",ptr->msglen,(char *)ptr->msg,ptr->sock);
if ( (sentbytes= nn_send(ptr->sock,ptr->msg,ptr->msglen,0)) != ptr->msglen )
printf("%d LP_send sent %d instead of %d\n",n,sentbytes,ptr->msglen);
else flag++;
}
else
{
flag++;
ptr->sock = -1;
}
}
if ( ptr->peerind > 0 )
ptr->starttime = (uint32_t)time(NULL);
}
else
{
if ( ptr->notready++ > 1000 )
{
flag = 1;
printf("queue_loop sock.%d len.%d notready.%d, skip\n",ptr->sock,ptr->msglen,ptr->notready);
ptr->sock = -1;
}
}
}
}

11
iguana/exchanges/LP_network.c

@ -267,7 +267,9 @@ int32_t LP_peerindsock(int32_t *peerindp)
void _LP_queuesend(uint32_t crc32,int32_t sock0,int32_t sock1,uint8_t *msg,int32_t msglen,int32_t needack)
{
int32_t maxind,peerind = 0; //sentbytes,
int32_t i,maxind,flag = 0,peerind = 0; //sentbytes,
for (i=0; i<2; i++)
{
if ( sock0 < 0 && sock1 < 0 )
{
if ( (maxind= LP_numpeers()) > 0 )
@ -278,11 +280,16 @@ void _LP_queuesend(uint32_t crc32,int32_t sock0,int32_t sock1,uint8_t *msg,int32
peerind = (LP_rand() % maxind) + 1;
else peerind = 1;
sock1 = LP_peerindsock(&peerind);
flag = 1;
}
if ( sock0 >= 0 )
_LP_sendqueueadd(crc32,sock0,msg,msglen,needack * peerind);
if ( sock1 >= 0 )
_LP_sendqueueadd(crc32,sock1,msg,msglen,needack);
if ( flag == 0 )
break;
sock0 = sock1 = -1;
}
}
void LP_queuesend(uint32_t crc32,int32_t pubsock,char *base,char *rel,uint8_t *msg,int32_t msglen)
@ -310,7 +317,7 @@ void LP_broadcast_finish(int32_t pubsock,char *base,char *rel,uint8_t *msg,cJSON
#ifdef FROM_MARKETMAKER
if ( (G.LP_IAMLP == 0 || pubsock < 0) && strcmp(method,"psock") != 0 )
#else
if ( (IAMLP == 0 || pubsock < 0 && strcmp(method,"psock") != 0 )
if ( (IAMLP == 0 || pubsock < 0) && strcmp(method,"psock") != 0 )
#endif
{
free(msg);

3
iguana/exchanges/LP_signatures.c

@ -698,11 +698,10 @@ void LP_query(void *ctx,char *myipaddr,int32_t mypubsock,char *method,struct LP_
jadd(reqjson,"proof",LP_instantdex_txids(0,coin->smartaddr));
}
msg = jprint(reqjson,1);
//printf("etomicdest.(%s) QUERY.(%s)\n",qp->etomicdest,msg);
printf("QUERY.(%s)\n",msg);
memset(&zero,0,sizeof(zero));
if ( bits256_nonz(qp->srchash) != 0 )
LP_reserved_msg(1,qp->srccoin,qp->destcoin,qp->srchash,clonestr(msg));
printf("QUERY.(%s)\n",msg);
LP_reserved_msg(1,qp->srccoin,qp->destcoin,zero,clonestr(msg));
free(msg);
}

2
iguana/exchanges/prices/autoprice

@ -37,7 +37,7 @@ source trackbtc
#source revs
#source trackbtc
sharkholdings="{\"coin\":\"iota\",\"balance\":1500000}, {\"coin\":\"bitcoin-cash\",\"balance\":1200}, {\"coin\":\"bitcoin\",\"balance\":145}"
sharkholdings="{\"coin\":\"iota\",\"balance\":1500000}, {\"coin\":\"komodo\",\"balance\":120000}, {\"coin\":\"bitcoin-cash\",\"balance\":1200}, {\"coin\":\"bitcoin\",\"balance\":100}"
curl --url "http://127.0.0.1:7783" --data "{\"base\":\"MSHARK\",\"rel\":\"KMD\",\"fundvalue_bid\":\"NAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"margin\":$margin,\"address\":\"RTu3JZZKLJTcfNwBa19dWRagEfQq49STqC\",\"holdings\":[$sharkholdings],\"divisor\":1400000}"

Loading…
Cancel
Save