Browse Source

Test

etomic
jl777 7 years ago
parent
commit
fdf17a70ec
  1. 19
      iguana/exchanges/LP_network.c
  2. 2
      iguana/exchanges/mm.c

19
iguana/exchanges/LP_network.c

@ -157,9 +157,6 @@ void queue_loop(void *ignore)
{
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);
#ifdef FROM_JS
else printf("sent %d bytes of %d to sock.%d\n",sentbytes,ptr->msglen,ptr->sock);
#endif
ptr->sock = -1;
if ( ptr->peerind > 0 )
ptr->starttime = (uint32_t)time(NULL);
@ -290,7 +287,21 @@ void LP_broadcast_finish(int32_t pubsock,char *base,char *rel,uint8_t *msg,cJSON
// add signature here
msg = (void *)jprint(argjson,0);
msglen = (int32_t)strlen((char *)msg) + 1;
#ifdef FROM_JS
int32_t sentbytes,sock,peerind,maxind;
if ( (maxind= LP_numpeers()) > 0 )
peerind = (rand() % maxind) + 1;
else peerind = 1;
sock = LP_peerindsock(&peerind);
if ( sock >= 0 )
{
if ( (sentbytes= nn_send(sock,msg,msglen,0)) != msglen )
printf("%d LP_send sent %d instead of %d\n",n,sentbytes,msglen);
else printf("sent %d bytes of %d to sock.%d\n",sentbytes,msglen,sock);
} else printf("couldnt get valid sock\n");
#else
LP_queuesend(crc32,-1,base,rel,msg,msglen);
#endif
} else LP_queuesend(crc32,pubsock,base,rel,msg,msglen);
free(msg);
}
@ -335,7 +346,7 @@ void LP_broadcast_message(int32_t pubsock,char *base,char *rel,bits256 destpub25
// printf("finished %u\n",crc32);
} // else printf("no valid method in (%s)\n",msgstr);
free_json(argjson);
} else printf("couldnt parse (%s)\n",msgstr);
} else printf("couldnt parse %p (%s)\n",msgstr,msgstr);
}
else
{

2
iguana/exchanges/mm.c

@ -887,7 +887,7 @@ int main(int argc, const char * argv[])
retjson = cJSON_Parse("{\"client\":1,\"passphrase\":\"test\"}");
printf("calling LP_main(%s)\n",jprint(retjson,0));
LP_main(retjson);
emscripten_set_main_loop(LP_fromjs_iter,10,0);
emscripten_set_main_loop(LP_fromjs_iter,1,0);
#else
if ( argc > 1 && (retjson= cJSON_Parse(argv[1])) != 0 )
{

Loading…
Cancel
Save