Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
ebcc32ba69
  1. 11
      iguana/iguana_accept.c
  2. 8
      iguana/iguana_instantdex.c

11
iguana/iguana_accept.c

@ -65,7 +65,7 @@ void iguana_acceptloop(void *args)
{
struct iguana_peer *addr; struct iguana_info *coin = args;
struct pollfd pfd; int32_t sock; struct iguana_accept *ptr; uint16_t port = coin->chain->portp2p;
socklen_t clilen; struct sockaddr_in cli_addr; char ipaddr[64]; uint32_t i,ipbits;
socklen_t clilen; struct sockaddr_in cli_addr; char ipaddr[64]; uint32_t i,ipbits,flag;
while ( (coin->bindsock= iguana_socket(1,"0.0.0.0",port)) < 0 )
{
if ( coin->peers.localaddr != 0 )
@ -96,19 +96,20 @@ void iguana_acceptloop(void *args)
}
memcpy(&ipbits,&cli_addr.sin_addr.s_addr,sizeof(ipbits));
expand_ipbits(ipaddr,ipbits);
for (i=0; i<IGUANA_MAXPEERS; i++)
for (i=flag=0; i<IGUANA_MAXPEERS; i++)
{
if ( coin->peers.active[i].ipbits == (uint32_t)ipbits && coin->peers.active[i].usock >= 0 )
{
printf("found existing peer.(%s) in slot[%d]\n",ipaddr,i);
close(sock);
sock = -1;
close(coin->peers.active[i].usock);
coin->peers.active[i].usock = sock;
flag = 1;
//iguana_iAkill(coin,&coin->peers.active[i],0);
//sleep(1);
break;
}
}
if ( sock < 0 )
if ( flag != 0 )
continue;
printf("NEWSOCK.%d for %x (%s)\n",sock,ipbits,ipaddr);
/*if ( (uint32_t)ipbits == myinfo->myaddr.myipbits )

8
iguana/iguana_instantdex.c

@ -867,12 +867,16 @@ struct iguana_bundlereq *instantdex_recvquotes(struct iguana_info *coin,struct i
int32_t instantdex_quoterequest(struct supernet_info *myinfo,struct iguana_info *coin,uint8_t *serialized,int32_t maxlen,struct iguana_peer *addr,bits256 encodedhash)
{
struct instantdex_accept *ap; int32_t olen; bits256 orderhash;
struct instantdex_accept *ap; int32_t olen,checklen; struct instantdex_offer checkoffer; bits256 orderhash,checkhash;
if ( (ap= instantdex_quotefind(myinfo,coin,addr,encodedhash)) != 0 )
{
orderhash = instantdex_rwoffer(1,&olen,serialized,&ap->offer);
if ( orderhash.ulongs[0] == ap->orderid )
{
checkhash = instantdex_rwoffer(0,&checklen,serialized,&checkoffer);
printf("%llu vs %llu, %d vs %d\n",(long long)checkhash.txid,(long long)orderhash.txid,checklen,olen);
return(olen);
}
else return(-1);
}
return(0);
@ -882,7 +886,7 @@ int32_t instantdex_quote(struct supernet_info *myinfo,struct iguana_info *coin,s
{
bits256 orderhash,encodedhash; int32_t checklen; struct instantdex_accept A,*ap; char hexstr[8192];
memset(&A,0,sizeof(A));
orderhash = instantdex_rwoffer(0,&checklen,serialized,&A.offer);
orderhash = instantdex_rwoffer(0,&checklen,serialized,&A.offer), A.orderid = orderhash.txid;
if ( checklen == recvlen )
{
encodedhash = instantdex_encodehash(A.offer.base,A.offer.rel,A.offer.price64 * instantdex_bidaskdir(&A.offer),A.orderid,A.offer.offer64);

Loading…
Cancel
Save