Browse Source

test

etomic
jl777 8 years ago
parent
commit
ce446adfb6
  1. 17
      iguana/dpow/dpow_network.c
  2. 7
      iguana/iguana_mofn.c
  3. 2
      includes/iguana_funcs.h

17
iguana/dpow/dpow_network.c

@ -100,7 +100,7 @@ void dex_init(struct supernet_info *myinfo)
portable_mutex_init(&myinfo->dexmutex); 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; 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 ) 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); free(sigpacket);
iguana_fixsecp(myinfo);
printf("error signing nnpacket\n"); printf("error signing nnpacket\n");
} }
return(-1); return(-1);
@ -1710,7 +1711,7 @@ void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_blo
pfd.events = NN_POLLOUT; pfd.events = NN_POLLOUT;
if ( nn_poll(&pfd,1,100) > 0 ) 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; break;
} }
usleep(1000); usleep(1000);
@ -1844,7 +1845,7 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
if ( dex_packetcheck(myinfo,dexp,size) == 0 ) if ( dex_packetcheck(myinfo,dexp,size) == 0 )
{ {
//printf("FROM BUS.%08x -> pub\n",dexp->crc32); //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); dex_packet(myinfo,dexp,size);
} }
//printf("GOT DEX bus PACKET.%d\n",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)); //printf("REP got %d crc.%08x\n",size,calc_crc32(0,(void *)dexp,size));
if ( (retstr= dex_response(&broadcastflag,myinfo,dexp)) != 0 ) 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); //printf("send back[%ld]\n",strlen(retstr)+1);
free(retstr); free(retstr);
if ( broadcastflag != 0 ) if ( broadcastflag != 0 )
{ {
printf("BROADCAST dexp request.[%d]\n",size); 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 else
@ -1874,13 +1875,13 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
if ( (m= myinfo->numdpowipbits) > 0 ) if ( (m= myinfo->numdpowipbits) > 0 )
{ {
r = myinfo->dpowipbits[rand() % m]; 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); //printf("REP.%08x <- rand ip m.%d %x\n",dexp->crc32,m,r);
} else printf("illegal state without dpowipbits?\n"); } else printf("illegal state without dpowipbits?\n");
if ( dex_packetcheck(myinfo,dexp,size) == 0 ) if ( dex_packetcheck(myinfo,dexp,size) == 0 )
{ {
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);
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);
//printf("REP.%08x -> dexbus and pub, t.%d lag.%d\n",dexp->crc32,dexp->timestamp,(int32_t)(time(NULL)-dexp->timestamp)); //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); dex_packet(myinfo,dexp,size);
} else printf("failed dexpacketcheck\n"); } else printf("failed dexpacketcheck\n");

7
iguana/iguana_mofn.c

@ -238,6 +238,13 @@ int32_t gfshare_test(struct supernet_info *myinfo,int32_t M,int32_t N,int32_t da
return ok!=1; return ok!=1;
} }
void iguana_fixsecp(struct supernet_info *myinfo)
{
myinfo->ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY);
secp256k1_pedersen_context_initialize(myinfo->ctx);
secp256k1_rangeproof_context_initialize(myinfo->ctx);
}
void libgfshare_init(struct supernet_info *myinfo,uint8_t _logs[256],uint8_t _exps[510]) void libgfshare_init(struct supernet_info *myinfo,uint8_t _logs[256],uint8_t _exps[510])
{ {
uint32_t i,x = 1; uint32_t i,x = 1;

2
includes/iguana_funcs.h

@ -637,6 +637,8 @@ void gfshare_ctx_decextract(uint8_t *logs,uint8_t *exps,gfshare_ctx * /* ctx */,
void libgfshare_init(struct supernet_info *myinfo,uint8_t _logs[256],uint8_t _exps[510]); void libgfshare_init(struct supernet_info *myinfo,uint8_t _logs[256],uint8_t _exps[510]);
int32_t init_sharenrs(uint8_t sharenrs[255],uint8_t *orig,int32_t m,int32_t n); int32_t init_sharenrs(uint8_t sharenrs[255],uint8_t *orig,int32_t m,int32_t n);
void iguana_schnorr(struct supernet_info *myinfo); void iguana_schnorr(struct supernet_info *myinfo);
void iguana_fixsecp(struct supernet_info *myinfo);
#include "../includes/iguana_api.h" #include "../includes/iguana_api.h"

Loading…
Cancel
Save