Browse Source

test

etomic
jl777 8 years ago
parent
commit
e48f92db37
  1. 8
      iguana/dpow/dpow_fsm.c
  2. 24
      iguana/dpow/dpow_network.c

8
iguana/dpow/dpow_fsm.c

@ -89,7 +89,7 @@ int32_t dpow_datahandler(struct supernet_info *myinfo,struct dpow_info *dp,struc
if ( bits256_cmp(txid,srchash) == 0 )
{
//printf("verify (%s) it is properly signed! set ht.%d signedtxid to %s\n",coin->symbol,height,bits256_str(str,txid));
if ( src_or_dest != 0 )
if ( channel == DPOW_BTCTXIDCHANNEL )
{
if ( bp->state < 1000 )
{
@ -104,9 +104,9 @@ int32_t dpow_datahandler(struct supernet_info *myinfo,struct dpow_info *dp,struc
{
if ( bp->state != 0xffffffff )
{
bp->srctxid = txid;
printf("set state elapsed %d COMPLETED %s.(%s) %s.(%s)\n",(int32_t)(time(NULL) - bp->starttime),dp->symbol,bits256_str(str,bp->desttxid),dp->dest,bits256_str(str2,txid));
bp->state = 0xffffffff;
//bp->srctxid = txid;
//printf("set state elapsed %d COMPLETED %s.(%s) %s.(%s)\n",(int32_t)(time(NULL) - bp->starttime),dp->symbol,bits256_str(str,bp->desttxid),dp->dest,bits256_str(str2,txid));
//bp->state = 0xffffffff;
}
}
}

24
iguana/dpow/dpow_network.c

@ -110,8 +110,6 @@ int32_t dex_reqsend(struct supernet_info *myinfo,uint8_t *data,int32_t datalen)
ipbits = *retptr;
expand_ipbits(ipaddr,ipbits);
printf("req returned.[%d] %08x %s\n",recvbytes,*retptr,ipaddr);
if ( myinfo->IAMNOTARY == 0 )
{
portable_mutex_lock(&myinfo->dexmutex);
n = myinfo->numdexipbits;
for (i=0; i<n; i++)
@ -123,7 +121,7 @@ int32_t dex_reqsend(struct supernet_info *myinfo,uint8_t *data,int32_t datalen)
qsort(myinfo->dexipbits,n,sizeof(uint32_t),_increasing_ipbits);
if ( (myinfo->numdexipbits= n) < 3 )
{
if ( myinfo->subsock >= 0 )
if ( myinfo->IAMNOTARY == 0 && myinfo->subsock >= 0 )
{
nn_connect(myinfo->subsock,nanomsg_tcpname(0,str,ipaddr,PUB_SOCK));
printf("%d: subscribe connect (%s)\n",myinfo->numdexipbits,str);
@ -133,7 +131,6 @@ int32_t dex_reqsend(struct supernet_info *myinfo,uint8_t *data,int32_t datalen)
printf("%d: req connect (%s)\n",myinfo->numdexipbits,str);
}
portable_mutex_unlock(&myinfo->dexmutex);
}
nn_freemsg(retptr);
} else retval = -2;
free(dexp);
@ -806,8 +803,7 @@ void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_blo
for (i=0; i<32; i++)
np->srchash.bytes[i] = dp->minerkey33[i+1];
np->desthash = desthash;
if ( (np->channel= channel) == 0 )
np->channel = (uint32_t)time(NULL);
np->channel = channel;
np->height = msgbits;
np->myipbits = myinfo->myaddr.myipbits;
strcpy(np->symbol,dp->symbol);
@ -942,7 +938,7 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
nn_freemsg(np), np = 0;
} //else printf("no packets\n");
n = 0;
if ( myinfo->dexsock >= 0 )
if ( myinfo->dexsock >= 0 ) // from servers
{
if ( (size= nn_recv(myinfo->dexsock,&dexp,NN_MSG,0)) >= 0 )
{
@ -958,20 +954,22 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
nn_freemsg(dexp), dexp = 0;
}
}
if ( myinfo->repsock >= 0 )
if ( myinfo->repsock >= 0 ) // from clients
{
if ( (size= nn_recv(myinfo->repsock,&dexp,NN_MSG,0)) >= 0 )
{
num++;
if ( dex_packetcheck(myinfo,dexp,size) == 0 )
{
nn_send(myinfo->dexsock,dexp,size,0);
if ( (m= myinfo->numdpowipbits) > 0 )
{
r = myinfo->dpowipbits[rand() % m];
nn_send(myinfo->repsock,&r,sizeof(r),0);
printf("REP.%08x -> dexbus, rep.%08x",dexp->crc32,r);
}
printf("REP.%08x <- rand ip m.%d %x",dexp->crc32,m,r);
} else printf("illegal state without dpowipbits?\n");
if ( dex_packetcheck(myinfo,dexp,size) == 0 )
{
nn_send(myinfo->dexsock,dexp,size,0);
nn_send(myinfo->pubsock,dexp,size,0);
printf("REP.%08x -> dexbus and pub, t.%d lag.%d",dexp->crc32,dexp->timestamp,(int32_t)(time(NULL)-dexp->timestamp));
dex_packet(myinfo,dexp,size);
}
printf("GOT DEX rep PACKET.%d\n",size);

Loading…
Cancel
Save