Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
be4a739422
  1. 2
      iguana/SuperNET.c
  2. 28
      iguana/iguana_instantdex.c
  3. 2
      iguana/iguana_msg.c
  4. 2
      iguana/main.c

2
iguana/SuperNET.c

@ -475,7 +475,7 @@ int32_t iguana_send_supernet(struct iguana_info *coin,struct iguana_peer *addr,c
iguana_setkeys(myinfo,addr,&privkey,&pubkey,&destpub,&nextprivkey,&nextpubkey,&nextdestpub);
if ( juint(json,"plaintext") == 0 && juint(json,"broadcast") == 0 && memcmp(destpub.bytes,GENESIS_PUBKEY.bytes,sizeof(pubkey)) == 0 )
{
printf("reject broadcasting non-plaintext! (%s)\n",jsonstr); getchar();
printf("reject broadcasting non-plaintext! (%s)\n",jsonstr); //getchar();
free_json(json);
return(-1);
}

28
iguana/iguana_instantdex.c

@ -320,8 +320,7 @@ bits256 instantdex_rwoffer(int32_t rwflag,int32_t *lenp,uint8_t *serialized,stru
char *instantdex_sendcmd(struct supernet_info *myinfo,struct instantdex_offer *offer,cJSON *argjson,char *cmdstr,bits256 desthash,int32_t hops,void *extraser,int32_t extralen)
{
char *reqstr,*hexstr,*retstr; struct instantdex_msghdr *msg; bits256 orderhash;
int32_t i,olen,slen,datalen; uint8_t serialized[sizeof(*offer) + 2]; uint64_t nxt64bits;
char *reqstr,*retstr; struct instantdex_msghdr *msg; bits256 orderhash; struct iguana_info *coin; struct iguana_peer *addr; int32_t i,j,r,olen,slen,datalen,max; uint8_t serialized[sizeof(*offer) + sizeof(struct iguana_msghdr) + 4096]; uint64_t nxt64bits;
category_subscribe(myinfo,myinfo->instantdex_category,GENESIS_PUBKEY);
jaddstr(argjson,"cmd",cmdstr);
jaddstr(argjson,"agent","SuperNET");
@ -359,11 +358,26 @@ char *instantdex_sendcmd(struct supernet_info *myinfo,struct instantdex_offer *o
if ( instantdex_msgcreate(myinfo,msg,datalen) != 0 )
{
printf(">>>>>>>>>>>> instantdex send.(%s) datalen.%d allocsize.%d crc.%x\n",cmdstr,datalen,msg->sig.allocsize,calc_crc32(0,(void *)((long)msg + 8),datalen-8));
hexstr = malloc(msg->sig.allocsize*2 + 1);
init_hexbytes_noT(hexstr,(uint8_t *)msg,msg->sig.allocsize);
retstr = SuperNET_categorymulticast(myinfo,0,myinfo->instantdex_category,desthash,hexstr,0,hops,1,argjson,0);
free_json(argjson), free(hexstr), free(msg);
return(retstr);
//hexstr = malloc(msg->sig.allocsize*2 + 1);
//init_hexbytes_noT(hexstr,(uint8_t *)msg,msg->sig.allocsize);
//retstr = SuperNET_categorymulticast(myinfo,0,myinfo->instantdex_category,desthash,hexstr,0,hops,1,argjson,0);
memcpy(&serialized[sizeof(struct iguana_msghdr)],(uint8_t *)msg,msg->sig.allocsize);
if ( (coin= iguana_coinfind("BTCD")) != 0 && (max= coin->peers.numranked) > 0 )
{
r = (rand() % max);
for (i=0; i<max; i++)
{
j = (i + r) % max;
if ( (addr= coin->peers.ranked[j]) != 0 && addr->supernet != 0 && addr->usock >= 0 )
{
iguana_queue_send(coin,addr,0,serialized,"InstantDEX",msg->sig.allocsize,0,0);
if ( --hops <= 0 )
break;
}
}
}
free(msg); //free(hexstr),
return(jprint(argjson,1));
}
else
{

2
iguana/iguana_msg.c

@ -600,7 +600,7 @@ int32_t iguana_msgparser(struct iguana_info *coin,struct iguana_peer *addr,struc
else if ( strcmp(H->command,"InstantDEX") == 0 )
{
init_hexbytes_noT(addr->TXDATA.ptr,data,recvlen);
printf("peer InstantDEX message\n");
printf("peer InstantDEX message datalen.%d\n",recvlen);
SuperNET_hexmsgadd(myinfo,myinfo->instantdex_category,GENESIS_PUBKEY,addr->TXDATA.ptr,tai_now(),addr->ipaddr);
return(0);
}

2
iguana/main.c

@ -237,7 +237,7 @@ int32_t iguana_jsonQ()
{
if ( ptr->expired != 0 )
{
if ( ptr->retjsonstrp != 0 && *ptr->retjsonstrp != 0 )
if ( ptr->retjsonstrp != 0 && *ptr->retjsonstrp != 0 && *ptr->retjsonstrp[0] != 0 )
free(*ptr->retjsonstrp); // *ptr->retjsonstrp = clonestr("{\"error\":\"request timeout\"}");
printf("garbage collection: expired.(%s)\n",ptr->jsonstr);
myfree(ptr,ptr->allocsize);

Loading…
Cancel
Save