From 5aacd82b8ac3c582a6ceb4f869a88043f1fd3aed Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 29 Apr 2017 11:11:30 +0300 Subject: [PATCH] Test --- .gitignore | 2 ++ basilisk/basilisk_swap.c | 32 +++++++++++++++++--------------- basilisk/smartaddress.c | 16 ++++++++++++++-- iguana/dpow/dpow_network.c | 27 +++++++++++++++++++-------- 4 files changed, 52 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 22b82b68f..b3674ef11 100755 --- a/.gitignore +++ b/.gitignore @@ -409,3 +409,5 @@ iguana/DB/SWAPS/1306454711-1938980379 iguana/DB/SWAPS/912783809-2523701920 iguana/DB/SWAPS/1238069553-2363573428 + +iguana/DB/SWAPS/2895470622-2170247626 diff --git a/basilisk/basilisk_swap.c b/basilisk/basilisk_swap.c index b36395556..0b66d301f 100755 --- a/basilisk/basilisk_swap.c +++ b/basilisk/basilisk_swap.c @@ -3568,7 +3568,7 @@ cJSON *basilisk_remember(struct supernet_info *myinfo,int64_t *KMDtotals,int64_t } origfinishedflag = finishedflag = 1; free(fstr); - } + } else printf("%s not finished\n",fname); if ( iambob < 0 ) return(0); item = cJSON_CreateObject(); @@ -3602,24 +3602,26 @@ cJSON *basilisk_remember(struct supernet_info *myinfo,int64_t *KMDtotals,int64_t safecopy(bobcoin,symbol,sizeof(bobcoin)); else if ( i == BASILISK_BOBSPEND || i == BASILISK_ALICEPAYMENT || i == BASILISK_ALICERECLAIM ) safecopy(alicecoin,symbol,sizeof(alicecoin)); - if ( (sentobj= basilisk_swapgettx(myinfo,symbol,txid)) == 0 ) - { - //printf("%s %s ready to broadcast\n",symbol,bits256_str(str2,txid)); - } - else + if ( finishedflag == 0 ) { - checktxid = jbits256(sentobj,"txid"); - if ( bits256_nonz(checktxid) == 0 ) - checktxid = jbits256(sentobj,"hash"); - if ( bits256_cmp(checktxid,txid) == 0 ) + if ( (sentobj= basilisk_swapgettx(myinfo,symbol,txid)) == 0 ) { - //printf(">>>>>> %s txid %s\n",jprint(sentobj,0),bits256_str(str,txid)); - sentflags[i] = 1; + //printf("%s %s ready to broadcast\n",symbol,bits256_str(str2,txid)); + } + else + { + checktxid = jbits256(sentobj,"txid"); + if ( bits256_nonz(checktxid) == 0 ) + checktxid = jbits256(sentobj,"hash"); + if ( bits256_cmp(checktxid,txid) == 0 ) + { + //printf(">>>>>> %s txid %s\n",jprint(sentobj,0),bits256_str(str,txid)); + sentflags[i] = 1; + } + free_json(sentobj); } - free_json(sentobj); - } - if ( finishedflag == 0 ) printf("%s %s %.8f\n",txnames[i],bits256_str(str,txid),dstr(value)); + } } } //else printf("no symbol\n"); free(fstr); diff --git a/basilisk/smartaddress.c b/basilisk/smartaddress.c index 76de3948d..15a3c9ac2 100755 --- a/basilisk/smartaddress.c +++ b/basilisk/smartaddress.c @@ -85,9 +85,21 @@ cJSON *smartaddress_json(struct smartaddress *ap) bitcoin_addr2rmd160(&tmp,rmd160,coinaddr); bitcoin_address(coinaddr,desttype,rmd160,20); jaddstr(item,"dest",coinaddr); + if ( coin->DEXinfo.depositaddr[0] != 0 ) + { + jaddstr(item,"jumblr_deposit",coin->DEXinfo.depositaddr); + jaddnum(item,"deposit_avail",coin->DEXinfo.avail); + } + if ( coin->DEXinfo.jumblraddr[0] != 0 ) + { + jaddstr(item,"jumblr",coin->DEXinfo.jumblraddr); + jaddnum(item,"jumblr_avail",coin->DEXinfo.jumblravail); + } + if ( ap->symbols[j].maxbid != 0. ) + jaddnum(item,"maxbid",ap->symbols[j].maxbid); + if ( ap->symbols[j].minask != 0. ) + jaddnum(item,"minask",ap->symbols[j].minask); } - jaddnum(item,"maxbid",ap->symbols[j].maxbid); - jaddnum(item,"minask",ap->symbols[j].minask); jadd(item,"extra",smartaddress_extrajson(ap)); jaddi(array,item); } diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index 528aced8a..201024a9d 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -140,12 +140,23 @@ int32_t signed_nn_send(struct supernet_info *myinfo,void *ctx,bits256 privkey,in return(-1); } -int32_t signed_nn_recv(void **freeptrp,void *ctx,uint8_t notaries[64][33],int32_t n,int32_t sock,void *packetp) +int32_t signed_nn_recv(void **freeptrp,struct supernet_info *myinfo,uint8_t notaries[64][33],int32_t n,int32_t sock,void *packetp) { int32_t i,recvbytes; uint8_t pubkey33[33],pubkey0[33]; bits256 packethash; struct signed_nnpacket *sigpacket=0; *(void **)packetp = 0; *freeptrp = 0; - if ( (recvbytes= nn_recv(sock,&sigpacket,NN_MSG,0)) > 0 ) + for (i=0; i<100; i++) + { + struct nn_pollfd pfd; + pfd.fd = myinfo->reqsock; + pfd.events = NN_POLLIN; + if ( nn_poll(&pfd,1,100) > 0 ) + break; + usleep(1000); + } + if ( i == 100 ) + recvbytes = 0; + else if ( (recvbytes= nn_recv(sock,&sigpacket,NN_MSG,0)) > 0 ) { //for (i=0; inonce,(int32_t)(sigpacket->packetlen+sizeof(sigpacket->nonce)+sizeof(sigpacket->packetlen))); if ( bits256_cmp(packethash,sigpacket->packethash) == 0 && sigpacket->packethash.bytes[0] == 0 ) { - if ( bitcoin_recoververify(ctx,"nnrecv",sigpacket->sig64,sigpacket->packethash,pubkey33,33) == 0 ) + if ( bitcoin_recoververify(myinfo->ctx,"nnrecv",sigpacket->sig64,sigpacket->packethash,pubkey33,33) == 0 ) { char *notary0 = "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828"; // expand to official notaries @@ -474,7 +485,7 @@ char *_dex_reqsend(struct supernet_info *myinfo,char *handler,uint8_t *key,int32 } //for (i=0; ictx,myinfo->notaries,myinfo->numnotaries,myinfo->reqsock,&retptr)) >= 0 ) + if ( (recvbytes= signed_nn_recv(&freeptr,myinfo,myinfo->notaries,myinfo->numnotaries,myinfo->reqsock,&retptr)) >= 0 ) { //printf("req returned.[%d]\n",recvbytes); portable_mutex_lock(&myinfo->dexmutex); @@ -819,7 +830,7 @@ char *dex_reqsend(struct supernet_info *myinfo,char *handler,uint8_t *data,int32 { if ( (retstrs[j]= _dex_reqsend(myinfo,handler,0,0,data,datalen)) != 0 ) { -//printf("j.%d of max.%d M.%d (%s)\n",j,max,M,retstrs[j]); +printf("j.%d of max.%d M.%d (%s)\n",j,max,M,retstrs[j]); if ( strncmp(retstrs[j],"{\"error\":\"null return\"}",strlen("{\"error\":\"null return\"}")) != 0 && strncmp(retstrs[j],"[]",strlen("[]")) != 0 && strcmp("0",retstrs[j]) != 0 ) { if ( ++j == M ) @@ -1265,7 +1276,7 @@ int32_t dex_subsock_poll(struct supernet_info *myinfo) int32_t size= -1; struct dex_nanomsghdr *dexp; void *freeptr; //return(0); //fprintf(stderr,"subsock.%d\n",myinfo->subsock); - if ( myinfo->subsock >= 0 && (size= signed_nn_recv(&freeptr,myinfo->ctx,myinfo->notaries,myinfo->numnotaries,myinfo->subsock,&dexp)) >= 0 ) + if ( myinfo->subsock >= 0 && (size= signed_nn_recv(&freeptr,myinfo,myinfo->notaries,myinfo->numnotaries,myinfo->subsock,&dexp)) >= 0 ) { if ( dexp != 0 ) { @@ -2071,7 +2082,7 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo) for (iter=0; iter<100; iter++) { freeptr = 0; - if ( (flags & 1) == 0 && (size= signed_nn_recv(&freeptr,myinfo->ctx,myinfo->notaries,myinfo->numnotaries,myinfo->dpowsock,&np)) > 0 ) + if ( (flags & 1) == 0 && (size= signed_nn_recv(&freeptr,myinfo,myinfo->notaries,myinfo->numnotaries,myinfo->dpowsock,&np)) > 0 ) { num++; if ( size > 0 ) @@ -2125,7 +2136,7 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo) if ( myinfo->dexsock >= 0 ) // from servers { freeptr = 0; - if ( (flags & 2) == 0 && (size= signed_nn_recv(&freeptr,myinfo->ctx,myinfo->notaries,myinfo->numnotaries,myinfo->dexsock,&dexp)) > 0 ) + if ( (flags & 2) == 0 && (size= signed_nn_recv(&freeptr,myinfo,myinfo->notaries,myinfo->numnotaries,myinfo->dexsock,&dexp)) > 0 ) { //fprintf(stderr,"%d ",size); n++;