Browse Source

test

etomic
jl777 8 years ago
parent
commit
de215bf301
  1. 20
      iguana/dpow/dpow_network.c

20
iguana/dpow/dpow_network.c

@ -57,6 +57,8 @@ void dex_packet(struct supernet_info *myinfo,struct dex_nanomsghdr *dexp,int32_t
void dex_reqsend(struct supernet_info *myinfo,uint8_t *data,int32_t datalen) void dex_reqsend(struct supernet_info *myinfo,uint8_t *data,int32_t datalen)
{ {
struct dex_nanomsghdr *dexp; char ipaddr[64],str[128]; int32_t timeout,i,n,size,recvbytes,sentbytes = 0; uint32_t crc32,*retptr,ipbits; struct dex_nanomsghdr *dexp; char ipaddr[64],str[128]; int32_t timeout,i,n,size,recvbytes,sentbytes = 0; uint32_t crc32,*retptr,ipbits;
printf("dex_reqsend not active yet\n");
return;
if ( myinfo->reqsock < 0 && (myinfo->reqsock= nn_socket(AF_SP,NN_REQ)) >= 0 ) if ( myinfo->reqsock < 0 && (myinfo->reqsock= nn_socket(AF_SP,NN_REQ)) >= 0 )
{ {
if ( nn_connect(myinfo->reqsock,nanomsg_tcpname(str,myinfo->dexseed_ipaddr,REP_SOCK)) < 0 ) if ( nn_connect(myinfo->reqsock,nanomsg_tcpname(str,myinfo->dexseed_ipaddr,REP_SOCK)) < 0 )
@ -166,6 +168,7 @@ int32_t dex_packetcheck(struct supernet_info *myinfo,struct dex_nanomsghdr *dexp
void dex_subsock_poll(struct supernet_info *myinfo) void dex_subsock_poll(struct supernet_info *myinfo)
{ {
int32_t size,n=0; struct dex_nanomsghdr *dexp; int32_t size,n=0; struct dex_nanomsghdr *dexp;
printf("subsock poll not active yet\n");
while ( (size= nn_recv(myinfo->subsock,&dexp,NN_MSG,0)) >= 0 ) while ( (size= nn_recv(myinfo->subsock,&dexp,NN_MSG,0)) >= 0 )
{ {
n++; n++;
@ -789,8 +792,8 @@ void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_blo
np->version1 = (DPOW_VERSION >> 8) & 0xff; np->version1 = (DPOW_VERSION >> 8) & 0xff;
memcpy(np->packet,data,datalen); memcpy(np->packet,data,datalen);
sentbytes = -1; sentbytes = -1;
portable_mutex_lock(&myinfo->dpowmutex); //portable_mutex_lock(&myinfo->dpowmutex);
for (i=0; i<100; i++) /*for (i=0; i<100; i++)
{ {
struct nn_pollfd pfd; struct nn_pollfd pfd;
pfd.fd = myinfo->dpowsock; pfd.fd = myinfo->dpowsock;
@ -800,13 +803,14 @@ void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_blo
sentbytes = nn_send(myinfo->dpowsock,np,size,0); sentbytes = nn_send(myinfo->dpowsock,np,size,0);
break; break;
} }
} }*/
/*if ( myinfo->dexsock >= 0 ) /*if ( myinfo->dexsock >= 0 )
{ {
printf("SEND DEX PACKET\n"); printf("SEND DEX PACKET\n");
nn_send(myinfo->dexsock,np,size,0); nn_send(myinfo->dexsock,np,size,0);
}*/ }*/
portable_mutex_unlock(&myinfo->dpowmutex); //portable_mutex_unlock(&myinfo->dpowmutex);
sentbytes = nn_send(myinfo->dpowsock,np,size,0);
free(np); free(np);
if ( 0 && bp->myind <= 2 ) if ( 0 && bp->myind <= 2 )
printf("%d NANOSEND.%d ht.%d channel.%08x (%d) pax.%08x datalen.%d (%d %llx) (%d %llx) recv.%llx\n",i,sentbytes,np->height,np->channel,size,np->notarize.paxwdcrc,datalen,(int8_t)np->notarize.bestk,(long long)np->notarize.bestmask,bp->notaries[bp->myind].bestk,(long long)bp->notaries[bp->myind].bestmask,(long long)bp->recvmask); printf("%d NANOSEND.%d ht.%d channel.%08x (%d) pax.%08x datalen.%d (%d %llx) (%d %llx) recv.%llx\n",i,sentbytes,np->height,np->channel,size,np->notarize.paxwdcrc,datalen,(int8_t)np->notarize.bestk,(long long)np->notarize.bestmask,bp->notaries[bp->myind].bestk,(long long)bp->notaries[bp->myind].bestmask,(long long)bp->recvmask);
@ -859,7 +863,7 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
int32_t i,n=0,num=0,size,firstz = -1; uint32_t crc32,r,m; struct dpow_nanomsghdr *np=0; struct dpow_info *dp; struct dpow_block *bp; struct dex_nanomsghdr *dexp = 0; int32_t i,n=0,num=0,size,firstz = -1; uint32_t crc32,r,m; struct dpow_nanomsghdr *np=0; struct dpow_info *dp; struct dpow_block *bp; struct dex_nanomsghdr *dexp = 0;
if ( time(NULL) < myinfo->nanoinit+5 || myinfo->dpowsock < 0 ) if ( time(NULL) < myinfo->nanoinit+5 || myinfo->dpowsock < 0 )
return(-1); return(-1);
portable_mutex_lock(&myinfo->dpowmutex); /*portable_mutex_lock(&myinfo->dpowmutex);
for (i=0; i<100; i++) for (i=0; i<100; i++)
{ {
struct nn_pollfd pfd; struct nn_pollfd pfd;
@ -867,8 +871,8 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
pfd.events = NN_POLLIN; pfd.events = NN_POLLIN;
if ( nn_poll(&pfd,1,100) > 0 ) if ( nn_poll(&pfd,1,100) > 0 )
break; break;
} }*/
if ( i < 100 && (size= nn_recv(myinfo->dpowsock,&np,NN_MSG,0)) >= 0 ) if ( (size= nn_recv(myinfo->dpowsock,&np,NN_MSG,0)) >= 0 ) //i < 100 &&
{ {
num++; num++;
if ( size >= 0 ) if ( size >= 0 )
@ -955,7 +959,7 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
nn_freemsg(dexp), dexp = 0; nn_freemsg(dexp), dexp = 0;
} }
} }
portable_mutex_unlock(&myinfo->dpowmutex); //portable_mutex_unlock(&myinfo->dpowmutex);
return(num); return(num);
} }
#else #else

Loading…
Cancel
Save