|
|
@ -100,7 +100,7 @@ void dex_init(struct supernet_info *myinfo) |
|
|
|
portable_mutex_init(&myinfo->dexmutex); |
|
|
|
} |
|
|
|
|
|
|
|
int32_t signed_nn_send(void *ctx,bits256 privkey,int32_t sock,void *packet,int32_t size) |
|
|
|
int32_t signed_nn_send(struct supernet_info *myinfo,void *ctx,bits256 privkey,int32_t sock,void *packet,int32_t size) |
|
|
|
{ |
|
|
|
int32_t i,j,sentbytes,siglen = 0; uint8_t sig[65],pubkey33[33],signpubkey33[33]; struct signed_nnpacket *sigpacket; |
|
|
|
if ( (sigpacket= calloc(1,size + sizeof(*sigpacket))) != 0 ) |
|
|
@ -138,6 +138,7 @@ int32_t signed_nn_send(void *ctx,bits256 privkey,int32_t sock,void *packet,int32 |
|
|
|
} |
|
|
|
} |
|
|
|
free(sigpacket); |
|
|
|
iguana_fixsecp(myinfo); |
|
|
|
printf("error signing nnpacket\n"); |
|
|
|
} |
|
|
|
return(-1); |
|
|
@ -1710,7 +1711,7 @@ void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_blo |
|
|
|
pfd.events = NN_POLLOUT; |
|
|
|
if ( nn_poll(&pfd,1,100) > 0 ) |
|
|
|
{ |
|
|
|
sentbytes = signed_nn_send(myinfo->ctx,myinfo->persistent_priv,myinfo->dpowsock,np,size); |
|
|
|
sentbytes = signed_nn_send(myinfo,myinfo->ctx,myinfo->persistent_priv,myinfo->dpowsock,np,size); |
|
|
|
break; |
|
|
|
} |
|
|
|
usleep(1000); |
|
|
@ -1844,7 +1845,7 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo) |
|
|
|
if ( dex_packetcheck(myinfo,dexp,size) == 0 ) |
|
|
|
{ |
|
|
|
//printf("FROM BUS.%08x -> pub\n",dexp->crc32);
|
|
|
|
signed_nn_send(myinfo->ctx,myinfo->persistent_priv,myinfo->pubsock,dexp,size); |
|
|
|
signed_nn_send(myinfo,myinfo->ctx,myinfo->persistent_priv,myinfo->pubsock,dexp,size); |
|
|
|
dex_packet(myinfo,dexp,size); |
|
|
|
} |
|
|
|
//printf("GOT DEX bus PACKET.%d\n",size);
|
|
|
@ -1860,13 +1861,13 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo) |
|
|
|
//printf("REP got %d crc.%08x\n",size,calc_crc32(0,(void *)dexp,size));
|
|
|
|
if ( (retstr= dex_response(&broadcastflag,myinfo,dexp)) != 0 ) |
|
|
|
{ |
|
|
|
signed_nn_send(myinfo->ctx,myinfo->persistent_priv,myinfo->repsock,retstr,(int32_t)strlen(retstr)+1); |
|
|
|
signed_nn_send(myinfo,myinfo->ctx,myinfo->persistent_priv,myinfo->repsock,retstr,(int32_t)strlen(retstr)+1); |
|
|
|
//printf("send back[%ld]\n",strlen(retstr)+1);
|
|
|
|
free(retstr); |
|
|
|
if ( broadcastflag != 0 ) |
|
|
|
{ |
|
|
|
printf("BROADCAST dexp request.[%d]\n",size); |
|
|
|
signed_nn_send(myinfo->ctx,myinfo->persistent_priv,myinfo->dexsock,dexp,size); |
|
|
|
signed_nn_send(myinfo,myinfo->ctx,myinfo->persistent_priv,myinfo->dexsock,dexp,size); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
@ -1874,13 +1875,13 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo) |
|
|
|
if ( (m= myinfo->numdpowipbits) > 0 ) |
|
|
|
{ |
|
|
|
r = myinfo->dpowipbits[rand() % m]; |
|
|
|
signed_nn_send(myinfo->ctx,myinfo->persistent_priv,myinfo->repsock,&r,sizeof(r)); |
|
|
|
signed_nn_send(myinfo,myinfo->ctx,myinfo->persistent_priv,myinfo->repsock,&r,sizeof(r)); |
|
|
|
//printf("REP.%08x <- rand ip m.%d %x\n",dexp->crc32,m,r);
|
|
|
|
} else printf("illegal state without dpowipbits?\n"); |
|
|
|
if ( dex_packetcheck(myinfo,dexp,size) == 0 ) |
|
|
|
{ |
|
|
|
signed_nn_send(myinfo->ctx,myinfo->persistent_priv,myinfo->dexsock,dexp,size); |
|
|
|
signed_nn_send(myinfo->ctx,myinfo->persistent_priv,myinfo->pubsock,dexp,size); |
|
|
|
signed_nn_send(myinfo,myinfo->ctx,myinfo->persistent_priv,myinfo->dexsock,dexp,size); |
|
|
|
signed_nn_send(myinfo,myinfo->ctx,myinfo->persistent_priv,myinfo->pubsock,dexp,size); |
|
|
|
//printf("REP.%08x -> dexbus and pub, t.%d lag.%d\n",dexp->crc32,dexp->timestamp,(int32_t)(time(NULL)-dexp->timestamp));
|
|
|
|
dex_packet(myinfo,dexp,size); |
|
|
|
} else printf("failed dexpacketcheck\n"); |
|
|
|