Browse Source

test

release/v0.1
jl777 8 years ago
parent
commit
34ebd02a79
  1. 8
      basilisk/basilisk.c
  2. 6
      basilisk/basilisk_MSG.c
  3. 10
      basilisk/basilisk_bitcoin.c
  4. 7
      iguana/iguana777.h
  5. 1
      iguana/iguana_msg.c

8
basilisk/basilisk.c

@ -202,8 +202,10 @@ int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *typ
if ( addr->usock >= 0 )
{
s = 0;
valid = (addr->supernet != 0);
if ( NUMRELAYS > 0 && basilisk_specialcmd(type) != 0 )
{
valid = 0;
OS_randombytes((void *)&r2,sizeof(r2));
if ( (r2 % NUMRELAYS) >= sqrt(NUMRELAYS) )
{
@ -218,8 +220,8 @@ int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *typ
//printf("skip non-relay.(%s)\n",addr->ipaddr);
continue;
}
//printf("send to other relay.(%s)\n",addr->ipaddr);
valid = 1;
//printf("send to other relay.(%s)\n",addr->ipaddr);
}
for (s=0; s<n; s++)
if ( alreadysent[s] == addr->ipbits )
@ -229,7 +231,7 @@ int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *typ
}
if ( s == n && valid == 1 && (destipaddr == 0 || strcmp(addr->ipaddr,destipaddr) == 0) )
{
printf("n.%d/fanout.%d i.%d l.%d [%s].tag%d send %s.(%s) [%x] datalen.%d addr->supernet.%u basilisk.%u to (%s).%d destip.%s\n",n,fanout,i,l,cmd,*(uint32_t *)data,type,(char *)&data[4],*(int32_t *)&data[datalen-4],datalen,addr->supernet,addr->basilisk,addr->ipaddr,addr->A.port,destipaddr!=0?destipaddr:"broadcast");
printf("n.%d/fanout.%d i.%d l.%d [%s].tag%u send %s.(%s) [%x] datalen.%d addr->supernet.%u basilisk.%u to (%s).%d destip.%s\n",n,fanout,i,l,cmd,*(uint32_t *)data,type,(char *)&data[4],*(int32_t *)&data[datalen-4],datalen,addr->supernet,addr->basilisk,addr->ipaddr,addr->A.port,destipaddr!=0?destipaddr:"broadcast");
if ( encryptflag != 0 && bits256_nonz(addr->pubkey) != 0 )
{
void *ptr; uint8_t *cipher,space[8192]; int32_t cipherlen; bits256 privkey;
@ -899,7 +901,7 @@ HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr)
coin = iguana_coinfind(symbol);
}
if ( jobj(vals,"fanout") == 0 )
jaddnum(vals,"fanout",(int32_t)sqrt(NUMRELAYS)+1);
jaddnum(vals,"fanout",MAX(5,(int32_t)sqrt(NUMRELAYS)+1));
if ( jobj(vals,"numrequired") == 0 )
jaddnum(vals,"numrequired",sqrt(NUMRELAYS));
if ( coin != 0 )

6
basilisk/basilisk_MSG.c

@ -189,7 +189,7 @@ HASH_ARRAY_STRING(basilisk,sendmessage,hash,vals,hexstr)
free(retstr);
}
if ( vals != 0 && juint(vals,"fanout") == 0 )
jaddnum(vals,"fanout",(int32_t)sqrt(NUMRELAYS)+2);
jaddnum(vals,"fanout",MAX(5,(int32_t)sqrt(NUMRELAYS)+2));
return(basilisk_standardservice("OUT",myinfo,0,hash,vals,hexstr,0));
}
#include "../includes/iguana_apiundefs.h"
@ -203,7 +203,7 @@ int32_t basilisk_channelsend(struct supernet_info *myinfo,bits256 hash,uint32_t
jaddnum(valsobj,"channel",channel);
if ( msgid == 0 )
msgid = (uint32_t)time(NULL);
jaddnum(valsobj,"fanout",(int32_t)sqrt(NUMRELAYS)+2);
jaddnum(valsobj,"fanout",MAX(5,(int32_t)sqrt(NUMRELAYS)+2));
jaddnum(valsobj,"msgid",msgid);
jaddnum(valsobj,"duration",duration);
jaddbits256(valsobj,"sender",myinfo->myaddr.persistent);
@ -252,7 +252,7 @@ cJSON *basilisk_channelget(struct supernet_info *myinfo,bits256 hash,uint32_t ch
jaddnum(valsobj,"msgid",msgid);
jaddnum(valsobj,"width",width);
jaddnum(valsobj,"timeout",2500);
jaddnum(valsobj,"fanout",(int32_t)sqrt(NUMRELAYS)+1);
jaddnum(valsobj,"fanout",MAX(5,(int32_t)sqrt(NUMRELAYS)+1));
jaddnum(valsobj,"minresults",1);
if ( (retstr= basilisk_getmessage(myinfo,0,0,0,hash,valsobj,0)) != 0 )
{

10
basilisk/basilisk_bitcoin.c

@ -423,7 +423,7 @@ void *basilisk_bitcoinvalue(struct basilisk_item *Lptr,struct supernet_info *myi
void *basilisk_getinfo(struct basilisk_item *Lptr,struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,int32_t timeoutmillis,cJSON *valsobj)
{
struct basilisk_item *ptr; cJSON *infojson; int32_t numsent;
struct basilisk_item *ptr; cJSON *infojson; int32_t numsent,fanout;
if ( RELAYID >= 0 )
return(0);
if ( coin->VALIDATENODE != 0 || coin->FULLNODE != 0 )
@ -432,7 +432,9 @@ void *basilisk_getinfo(struct basilisk_item *Lptr,struct supernet_info *myinfo,s
Lptr->retstr = jprint(infojson,1);
return(Lptr);
}
ptr = basilisk_issueremote(myinfo,0,&numsent,"INF",coin->symbol,1,valsobj,juint(valsobj,"fanout"),juint(valsobj,"minresults"),basilisktag,timeoutmillis,0,0,0,0,BASILISK_DEFAULTDIFF);
if ( (fanout= juint(valsobj,"fanout")) < 5 )
fanout = 5;
ptr = basilisk_issueremote(myinfo,0,&numsent,"INF",coin->symbol,1,valsobj,fanout,juint(valsobj,"minresults"),basilisktag,timeoutmillis,0,0,0,0,BASILISK_DEFAULTDIFF);
return(ptr);
}
@ -816,7 +818,7 @@ HASH_ARRAY_STRING(basilisk,value,hash,vals,hexstr)
coin = iguana_coinfind(symbol);
}
if ( jobj(vals,"fanout") == 0 )
jaddnum(vals,"fanout",(int32_t)sqrt(NUMRELAYS)+1);
jaddnum(vals,"fanout",MAX(5,(int32_t)sqrt(NUMRELAYS)+1));
if ( coin != 0 )
{
if ( (basilisktag= juint(vals,"basilisktag")) == 0 )
@ -844,7 +846,7 @@ HASH_ARRAY_STRING(basilisk,rawtx,hash,vals,hexstr)
if ( jobj(vals,"numrequired") == 0 )
jaddnum(vals,"numrequired",NUMRELAYS);
if ( jobj(vals,"fanout") == 0 )
jaddnum(vals,"fanout",(int32_t)sqrt(NUMRELAYS));
jaddnum(vals,"fanout",MAX(5,(int32_t)sqrt(NUMRELAYS)+1));
if ( coin != 0 )
{
//if ( juint(vals,"burn") == 0 )

7
iguana/iguana777.h

@ -97,4 +97,11 @@ struct supernet_info
#include "../includes/iguana_globals.h"
#include "../gecko/gecko.h"
#ifndef MAX
#define MAX(a,b) ((a) >= (b) ? (a) : (b))
#endif
#ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
#endif

1
iguana/iguana_msg.c

@ -336,6 +336,7 @@ void iguana_gotversion(struct supernet_info *myinfo,struct iguana_info *coin,str
addr->dead = 1;
} //else coin->longestchain = vers->nStartingHeight;
}
iguana_send_version(coin,addr,coin->myservices);
iguana_queue_send(addr,0,serialized,"getaddr",0);
}

Loading…
Cancel
Save