From 36ca7470afafbbc35603fea19c9b9b51841fc7ce Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 7 Jul 2017 21:35:49 +0300 Subject: [PATCH] Test --- iguana/exchanges/LP_commands.c | 4 +-- iguana/exchanges/LP_nativeDEX.c | 47 +++++---------------------------- 2 files changed, 8 insertions(+), 43 deletions(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 0aa89ff1e..84e80801d 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -331,14 +331,14 @@ trust(pubkey, trust)\n\ bits256 zero; char *cipherstr; int32_t cipherlen; uint8_t cipher[LP_ENCRYPTED_MAXSIZE]; if ( (reqjson= LP_dereference(argjson,"broadcast")) != 0 ) { - if ( (cipherstr= jstr(reqjson,"cipherstr")) != 0 ) + if ( (cipherstr= jstr(reqjson,"cipher")) != 0 ) { cipherlen = (int32_t)strlen(cipherstr) >> 1; if ( cipherlen <= sizeof(cipher) ) { decode_hex(cipher,cipherlen,cipherstr); LP_queuesend(calc_crc32(0,&cipher[2],cipherlen-2),LP_mypubsock,base,rel,cipher,cipherlen); - } else retstr = clonestr("{\"error\":\"cipherstr too big\"}"); + } else retstr = clonestr("{\"error\":\"cipher too big\"}"); } else { diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 8ea08666d..58170e076 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -148,8 +148,7 @@ char *LP_process_message(void *ctx,char *typestr,char *myipaddr,int32_t pubsock, crc32 = calc_crc32(0,&ptr[2],recvlen-2); if ( (crc32 & 0xff) == ptr[0] && ((crc32>>8) & 0xff) == ptr[1] ) encrypted = 1; - //printf("%s encrypted.%d recv.%u (%s)\n",typestr,encrypted,crc32,(char *)ptr); - portable_mutex_lock(&LP_commandmutex); + printf("%s encrypted.%d recv.%u %02x %02x vs %02x %02x\n",typestr,encrypted,crc32,ptr[0],ptr[1],crc32&0xff,(crc32>>8)&0xff); i = LP_crc32find(&duplicate,-1,crc32); if ( duplicate == 0 ) { @@ -184,48 +183,14 @@ char *LP_process_message(void *ctx,char *typestr,char *myipaddr,int32_t pubsock, if ( jsonstr != 0 && (argjson= cJSON_Parse(jsonstr)) != 0 ) { len = (int32_t)strlen(jsonstr) + 1; - /*if ( jstr(argjson,"method") != 0 && strcmp(jstr(argjson,"method"),"forwardhex") == 0 ) - { - //printf("got forwardhex\n"); - if ( (retstr= LP_forwardhex(ctx,pubsock,jbits256(argjson,"pubkey"),jstr(argjson,"hex"))) != 0 ) - { - } - } - else if ( jstr(argjson,"method") != 0 && strcmp(jstr(argjson,"method"),"publish") == 0 ) - { - printf("got publish\n"); - if ( jobj(argjson,"method2") != 0 ) - jdelete(argjson,"method2"); - jaddstr(argjson,"method2","broadcast"); - if ( pubsock >= 0 && (reqjson= LP_dereference(argjson,"publish")) != 0 ) - { - msg = jprint(reqjson,1); - /LP_send(pubsock,msg,(int32_t)strlen(msg)+1,1); - } - } - else*/ if ( (retstr= LP_command_process(ctx,myipaddr,pubsock,argjson,&((uint8_t *)ptr)[len],recvlen - len)) != 0 ) - { - } - /*if ( LP_COMMAND_RECVSOCK == NN_REP ) - { - if ( retstr != 0 ) - { - if ( strcmp("PULL",typestr) == 0 ) - { - printf("%d got REQ.(%s) -> (%s)\n",recvsock,jprint(argjson,0),retstr); - /LP_send(recvsock,retstr,(int32_t)strlen(retstr)+1,0); - } - } - else if ( strcmp("PULL",typestr) == 0 ) - { - printf("%d got REQ.(%s) -> null\n",recvsock,jprint(argjson,0)); - /LP_send(recvsock,"{\"result\":null}",(int32_t)strlen("{\"result\":null}")+1,0); - } - }*/ + portable_mutex_lock(&LP_commandmutex); + if ( (retstr= LP_command_process(ctx,myipaddr,pubsock,argjson,&((uint8_t *)ptr)[len],recvlen - len)) != 0 ) + { + } + portable_mutex_unlock(&LP_commandmutex); free_json(argjson); } else printf("error parsing(%s)\n",jsonstr); } //else printf("DUPLICATE.(%s)\n",(char *)ptr); - portable_mutex_unlock(&LP_commandmutex); if ( jsonstr != 0 && (void *)jsonstr != (void *)ptr && (void *)jsonstr != (void *)decoded ) free(jsonstr); if ( ptr != 0 )