Browse Source

Test

etomic
jl777 8 years ago
parent
commit
5aacd82b8a
  1. 2
      .gitignore
  2. 32
      basilisk/basilisk_swap.c
  3. 16
      basilisk/smartaddress.c
  4. 27
      iguana/dpow/dpow_network.c

2
.gitignore

@ -409,3 +409,5 @@ iguana/DB/SWAPS/1306454711-1938980379
iguana/DB/SWAPS/912783809-2523701920 iguana/DB/SWAPS/912783809-2523701920
iguana/DB/SWAPS/1238069553-2363573428 iguana/DB/SWAPS/1238069553-2363573428
iguana/DB/SWAPS/2895470622-2170247626

32
basilisk/basilisk_swap.c

@ -3568,7 +3568,7 @@ cJSON *basilisk_remember(struct supernet_info *myinfo,int64_t *KMDtotals,int64_t
} }
origfinishedflag = finishedflag = 1; origfinishedflag = finishedflag = 1;
free(fstr); free(fstr);
} } else printf("%s not finished\n",fname);
if ( iambob < 0 ) if ( iambob < 0 )
return(0); return(0);
item = cJSON_CreateObject(); item = cJSON_CreateObject();
@ -3602,24 +3602,26 @@ cJSON *basilisk_remember(struct supernet_info *myinfo,int64_t *KMDtotals,int64_t
safecopy(bobcoin,symbol,sizeof(bobcoin)); safecopy(bobcoin,symbol,sizeof(bobcoin));
else if ( i == BASILISK_BOBSPEND || i == BASILISK_ALICEPAYMENT || i == BASILISK_ALICERECLAIM ) else if ( i == BASILISK_BOBSPEND || i == BASILISK_ALICEPAYMENT || i == BASILISK_ALICERECLAIM )
safecopy(alicecoin,symbol,sizeof(alicecoin)); safecopy(alicecoin,symbol,sizeof(alicecoin));
if ( (sentobj= basilisk_swapgettx(myinfo,symbol,txid)) == 0 ) if ( finishedflag == 0 )
{
//printf("%s %s ready to broadcast\n",symbol,bits256_str(str2,txid));
}
else
{ {
checktxid = jbits256(sentobj,"txid"); if ( (sentobj= basilisk_swapgettx(myinfo,symbol,txid)) == 0 )
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)); //printf("%s %s ready to broadcast\n",symbol,bits256_str(str2,txid));
sentflags[i] = 1; }
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)); printf("%s %s %.8f\n",txnames[i],bits256_str(str,txid),dstr(value));
}
} }
} //else printf("no symbol\n"); } //else printf("no symbol\n");
free(fstr); free(fstr);

16
basilisk/smartaddress.c

@ -85,9 +85,21 @@ cJSON *smartaddress_json(struct smartaddress *ap)
bitcoin_addr2rmd160(&tmp,rmd160,coinaddr); bitcoin_addr2rmd160(&tmp,rmd160,coinaddr);
bitcoin_address(coinaddr,desttype,rmd160,20); bitcoin_address(coinaddr,desttype,rmd160,20);
jaddstr(item,"dest",coinaddr); 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)); jadd(item,"extra",smartaddress_extrajson(ap));
jaddi(array,item); jaddi(array,item);
} }

27
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); 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; int32_t i,recvbytes; uint8_t pubkey33[33],pubkey0[33]; bits256 packethash; struct signed_nnpacket *sigpacket=0;
*(void **)packetp = 0; *(void **)packetp = 0;
*freeptrp = 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; i<recvbytes; i++) //for (i=0; i<recvbytes; i++)
// printf("%02x",((uint8_t *)sigpacket)[i]); // printf("%02x",((uint8_t *)sigpacket)[i]);
@ -156,7 +167,7 @@ int32_t signed_nn_recv(void **freeptrp,void *ctx,uint8_t notaries[64][33],int32_
vcalc_sha256(0,packethash.bytes,(void *)&sigpacket->nonce,(int32_t)(sigpacket->packetlen+sizeof(sigpacket->nonce)+sizeof(sigpacket->packetlen))); vcalc_sha256(0,packethash.bytes,(void *)&sigpacket->nonce,(int32_t)(sigpacket->packetlen+sizeof(sigpacket->nonce)+sizeof(sigpacket->packetlen)));
if ( bits256_cmp(packethash,sigpacket->packethash) == 0 && sigpacket->packethash.bytes[0] == 0 ) 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"; char *notary0 = "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828";
// expand to official notaries // expand to official notaries
@ -474,7 +485,7 @@ char *_dex_reqsend(struct supernet_info *myinfo,char *handler,uint8_t *key,int32
} }
//for (i=0; i<datalen; i++) //for (i=0; i<datalen; i++)
// printf("%02x",((uint8_t *)data)[i]); // printf("%02x",((uint8_t *)data)[i]);
if ( (recvbytes= signed_nn_recv(&freeptr,myinfo->ctx,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); //printf("req returned.[%d]\n",recvbytes);
portable_mutex_lock(&myinfo->dexmutex); 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 ) 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 ( strncmp(retstrs[j],"{\"error\":\"null return\"}",strlen("{\"error\":\"null return\"}")) != 0 && strncmp(retstrs[j],"[]",strlen("[]")) != 0 && strcmp("0",retstrs[j]) != 0 )
{ {
if ( ++j == M ) 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; int32_t size= -1; struct dex_nanomsghdr *dexp; void *freeptr;
//return(0); //return(0);
//fprintf(stderr,"subsock.%d\n",myinfo->subsock); //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 ) if ( dexp != 0 )
{ {
@ -2071,7 +2082,7 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
for (iter=0; iter<100; iter++) for (iter=0; iter<100; iter++)
{ {
freeptr = 0; 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++; num++;
if ( size > 0 ) if ( size > 0 )
@ -2125,7 +2136,7 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
if ( myinfo->dexsock >= 0 ) // from servers if ( myinfo->dexsock >= 0 ) // from servers
{ {
freeptr = 0; 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); //fprintf(stderr,"%d ",size);
n++; n++;

Loading…
Cancel
Save