Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
93d3c10c89
  1. 14
      iguana/SuperNET.c
  2. 4
      iguana/SuperNET.h
  3. 14
      iguana/SuperNET_category.c
  4. 2
      iguana/SuperNET_hexmsg.c

14
iguana/SuperNET.c

@ -464,7 +464,7 @@ char *SuperNET_DHTsend(struct supernet_info *myinfo,uint32_t destipbits,bits256
if ( plaintext != 0 )
jaddnum(json,"plaintext",plaintext!=0);
jsonstr = jprint(json,1);
if ( SuperNET_hexmsguniq(myinfo,destpub,hexmsg,1) < 0 )
if ( SuperNET_hexmsgfind(myinfo,destpub,hexmsg,1) < 0 )
{
char str[65]; printf("duplicate hex.(%s) for %s\n",hexmsg,bits256_str(str,destpub));
return(clonestr("{\"error\":\"duplicate packet rejected\"}"));
@ -565,16 +565,16 @@ char *SuperNET_JSON(struct supernet_info *myinfo,cJSON *json,char *remoteaddr)
if ( hexmsg != 0 )
{
//printf("check.(%s)\n",hexmsg);
if ( SuperNET_hexmsguniq(myinfo,destpub,hexmsg,0) >= 0 )
if ( SuperNET_hexmsgfind(myinfo,destpub,hexmsg,0) < 0 )
{
SuperNET_hexmsgadd(myinfo,destpub,hexmsg,tai_now());
forwardstr = SuperNET_forward(myinfo,hexmsg,destipbits,destpub,maxdelay,juint(json,"broadcast"),juint(json,"plaintext")!=0);
}
}
}
if ( (destflag & SUPERNET_ISMINE) && (agent= jstr(json,"agent")) != 0 && (method= jstr(json,"method")) != 0 )
if ( (destflag & SUPERNET_ISMINE) != 0 && (agent= jstr(json,"agent")) != 0 && (method= jstr(json,"method")) != 0 )
{
if ( SuperNET_hexmsguniq(myinfo,destpub,hexmsg,0) >= 0 )
if ( hexmsg != 0 && SuperNET_hexmsgfind(myinfo,destpub,hexmsg,0) < 0 )
SuperNET_hexmsgadd(myinfo,destpub,hexmsg,tai_now());
if ( (retstr= SuperNET_processJSON(myinfo,json,remoteaddr)) != 0 )
{
@ -669,8 +669,6 @@ char *SuperNET_p2p(struct iguana_info *coin,struct iguana_peer *addr,int32_t *de
//printf("p2pret.(%s)\n",retstr);
*delaymillisp = SuperNET_delaymillis(myinfo,maxdelay);
senderpub = jbits256(json,"mypub");
//if ( memcmp(senderpub.bytes,addr->pubkey.bytes,sizeof(senderpub)) != 0 )
// addr->pubkey = senderpub;
addr->othervalid = (int32_t)jdouble(json,"ov");
addr->pubkey = senderpub;
free_json(json);
@ -1007,13 +1005,13 @@ THREE_STRINGS(SuperNET,announce,category,subcategory,message)
{
bits256 categoryhash;
vcalc_sha256(0,categoryhash.bytes,(uint8_t *)category,(int32_t)strlen(category));
return(SuperNET_categorymulticast(myinfo,0,categoryhash,subcategory,message,juint(json,"maxdelay"),juint(json,"plaintext")));
return(SuperNET_categorymulticast(myinfo,0,categoryhash,subcategory,message,juint(json,"maxdelay"),juint(json,"broadcast"),juint(json,"plaintext")));
}
THREE_STRINGS(SuperNET,survey,category,subcategory,message)
{
bits256 categoryhash;
vcalc_sha256(0,categoryhash.bytes,(uint8_t *)category,(int32_t)strlen(category));
return(SuperNET_categorymulticast(myinfo,1,categoryhash,subcategory,message,juint(json,"maxdelay"),juint(json,"plaintext")));
return(SuperNET_categorymulticast(myinfo,1,categoryhash,subcategory,message,juint(json,"maxdelay"),juint(json,"broadcast"),juint(json,"plaintext")));
}
#include "../includes/iguana_apiundefs.h"

4
iguana/SuperNET.h

@ -127,9 +127,9 @@ int32_t SuperNET_decrypt(bits256 *senderpubp,uint64_t *senderbitsp,uint32_t *tim
int32_t SuperNET_str2hex(uint8_t *hex,char *str);
void SuperNET_hex2str(char *str,uint8_t *hex,int32_t len);
void SuperNET_hexmsgadd(struct supernet_info *myinfo,bits256 destpub,char *hexmsg,struct tai now);
int32_t SuperNET_hexmsguniq(struct supernet_info *myinfo,bits256 dest,char *hexmsg,int32_t addflag);
int32_t SuperNET_hexmsgfind(struct supernet_info *myinfo,bits256 dest,char *hexmsg,int32_t addflag);
char *SuperNET_categorymulticast(struct supernet_info *myinfo,int32_t surveyflag,bits256 categoryhash,char *subcategory,char *message,int32_t maxdelay,int32_t plaintext);
char *SuperNET_categorymulticast(struct supernet_info *myinfo,int32_t surveyflag,bits256 categoryhash,char *subcategory,char *message,int32_t maxdelay,int32_t broadcastflag,int32_t plaintext);
#endif

14
iguana/SuperNET_category.c

@ -32,9 +32,18 @@ int32_t category_maxdelay(struct supernet_info *myinfo,bits256 categoryhash,int3
return(maxdelay);
}
char *SuperNET_categorymulticast(struct supernet_info *myinfo,int32_t surveyflag,bits256 categoryhash,char *subcategory,char *message,int32_t maxdelay,int32_t plaintext)
int32_t category_broadcast(struct supernet_info *myinfo,bits256 categoryhash,int32_t broadcastflag)
{
char *hexmsg,*retstr; int32_t len,broadcastflag=1;
if ( broadcastflag < 1 )
broadcastflag = 1;
else if ( broadcastflag > SUPERNET_MAXHOPS )
broadcastflag = SUPERNET_MAXHOPS;
return(broadcastflag);
}
char *SuperNET_categorymulticast(struct supernet_info *myinfo,int32_t surveyflag,bits256 categoryhash,char *subcategory,char *message,int32_t maxdelay,int32_t broadcastflag,int32_t plaintext)
{
char *hexmsg,*retstr; int32_t len;
len = (int32_t)strlen(message);
if ( is_hexstr(message,len) == 0 )
{
@ -42,6 +51,7 @@ char *SuperNET_categorymulticast(struct supernet_info *myinfo,int32_t surveyflag
init_hexbytes_noT(hexmsg,(uint8_t *)message,len+1);
} else hexmsg = message;
plaintext = category_plaintext(myinfo,categoryhash,plaintext);
broadcastflag = category_broadcast(myinfo,categoryhash,broadcastflag);
maxdelay = category_maxdelay(myinfo,categoryhash,maxdelay);
retstr = SuperNET_DHTsend(myinfo,0,categoryhash,hexmsg,maxdelay,broadcastflag,plaintext);
if ( hexmsg != message)

2
iguana/SuperNET_hexmsg.c

@ -15,7 +15,7 @@
#include "iguana777.h"
int32_t SuperNET_hexmsguniq(struct supernet_info *myinfo,bits256 dest,char *hexmsg,int32_t addflag)
int32_t SuperNET_hexmsgfind(struct supernet_info *myinfo,bits256 dest,char *hexmsg,int32_t addflag)
{
static int lastpurge; static uint64_t Packetcache[1024];
bits256 packethash; int32_t i,datalen;

Loading…
Cancel
Save