jl777 8 years ago
parent
commit
471ff46cc7
  1. 20
      basilisk/basilisk.c
  2. 2
      basilisk/basilisk_MSG.c
  3. 2
      iguana/iguana_msg.c
  4. 2
      iguana/iguana_peers.c
  5. 12
      iguana/iguana_wallet.c
  6. 2
      iguana/tests/addnotarys

20
basilisk/basilisk.c

@ -153,7 +153,7 @@ int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *typ
else if ( fanout > BASILISK_MAXFANOUT )
fanout = BASILISK_MAXFANOUT;
if ( type == 0 )
type = "BTCD";
type = "INF";
if ( strlen(type) > 3 )
{
printf("basilisk_sendcmd illegal type(%s)\n",type);
@ -213,6 +213,8 @@ int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *typ
{
if ( coin->peers == 0 )
continue;
//if ( basilisk_notarycmd(type) != 0 && strcmp(coin->symbol,"NOTARY") != 0 )
// continue;
if ( coin->FULLNODE == 0 && coin->VALIDATENODE == 0 )
cmd[0] = 's';
else cmd[0] = 'S';
@ -228,21 +230,21 @@ int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *typ
{
s = 0;
valid = (addr->supernet != 0);
if ( basilisk_notarycmd(type) != 0 && myinfo->IAMNOTARY != 0 )
if ( basilisk_notarycmd(type) != 0 )
{
valid = 0;
OS_randombytes((void *)&r2,sizeof(r2));
/*OS_randombytes((void *)&r2,sizeof(r2));
if ( (r2 % myinfo->NOTARY.NUMRELAYS) >= sqrt(myinfo->NOTARY.NUMRELAYS) )
{
//printf("fanout.%d s.%d n.%d skip %s\n",fanout,s,n,addr->ipaddr);
printf("fanout.%d s.%d n.%d skip %s\n",fanout,s,n,addr->ipaddr);
continue;
}
}*/
for (s=0; s<myinfo->NOTARY.NUMRELAYS; s++)
if ( addr->ipbits != myinfo->myaddr.myipbits && myinfo->NOTARY.RELAYS[s].ipbits == addr->ipbits )
break;
if ( s == myinfo->NOTARY.NUMRELAYS )
{
//printf("skip non-relay.(%s)\n",addr->ipaddr);
printf("skip non-relay.(%s)\n",addr->ipaddr);
continue;
}
valid = 1;
@ -256,7 +258,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) )
{
//fprintf(stderr,"(%s) ",addr->ipaddr);
fprintf(stderr,"(%s).%u ",addr->ipaddr,coin->chain->portp2p);
//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 )
{
@ -676,7 +678,7 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende
return;
} else if ( basilisk_notarycmd(CMD) != 0 )
return;
symbol = "BTCD";
symbol = "NOTARY";
if ( senderipbits == 0 )
expand_ipbits(remoteaddr,myinfo->myaddr.myipbits);
else expand_ipbits(remoteaddr,senderipbits);
@ -723,7 +725,7 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende
data += jsonlen, datalen -= jsonlen;
else data = 0, datalen = 0;
if ( coin == 0 )
coin = iguana_coinfind("BTCD");
coin = iguana_coinfind(symbol);
if ( coin != 0 )
{
symbol = coin->symbol;

2
basilisk/basilisk_MSG.c

@ -207,7 +207,7 @@ int32_t basilisk_channelsend(struct supernet_info *myinfo,bits256 hash,uint32_t
jaddnum(valsobj,"msgid",msgid);
jaddnum(valsobj,"duration",duration);
jaddbits256(valsobj,"sender",myinfo->myaddr.persistent);
//char str[65]; printf("sendmessage.[%d] channel.%u msgid.%x -> %s numrelays.%d:%d\n",datalen,channel,msgid,bits256_str(str,hash),NUMRELAYS,juint(valsobj,"fanout"));
char str[65]; printf("sendmessage.[%d] channel.%u msgid.%x -> %s numrelays.%d:%d\n",datalen,channel,msgid,bits256_str(str,hash),myinfo->NOTARY.NUMRELAYS,juint(valsobj,"fanout"));
if ( (retstr= basilisk_sendmessage(myinfo,0,0,0,hash,valsobj,hexstr)) != 0 )
free(retstr);
free_json(valsobj);

2
iguana/iguana_msg.c

@ -1010,7 +1010,7 @@ int32_t iguana_msgparser(struct supernet_info *myinfo,struct iguana_info *coin,s
{
struct iguana_msgzblock zmsg; struct iguana_msgblock *msg = (void *)&zmsg; struct iguana_zblock *zblocks; uint32_t tmp,n=0;
len = 0;
if ( addr != 0 && recvlen >= sizeof(bits256) && strcmp("BTCD",coin->symbol) != 0 )
if ( addr != 0 && recvlen >= sizeof(bits256) && strcmp("NOTARY",coin->symbol) != 0 )
{
if ( ishost == 0 )
{

2
iguana/iguana_peers.c

@ -584,7 +584,7 @@ int32_t iguana_recv(char *ipaddr,int32_t usock,uint8_t *recvbuf,int32_t len)
remains -= recvlen;
//int32_t i; for (i=0; i<recvlen; i++)
// printf("%02x",recvbuf[i]);
//printf("got %d remains.%d of total.%d from (%s)\n",recvlen,remains,len,ipaddr);
printf("got %d remains.%d of total.%d from (%s)\n",recvlen,remains,len,ipaddr);
recvbuf = &recvbuf[recvlen];
} else usleep(10000);
}

12
iguana/iguana_wallet.c

@ -1140,7 +1140,7 @@ cJSON *iguana_getinfo(struct supernet_info *myinfo,struct iguana_info *coin)
ZERO_ARGS(bitcoinrpc,getinfo)
{
struct basilisk_item Lptr,*ptr; int32_t i,j,m,n,longest; cJSON *valsobj,*getinfoobj=0,*array,*item,*fullnodes;
struct basilisk_item Lptr,*ptr; int32_t incr,i,j,m,n,longest; cJSON *valsobj,*getinfoobj=0,*array,*item,*fullnodes;
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
if ( coin->FULLNODE != 0 || coin->VALIDATENODE != 0 )
@ -1173,8 +1173,18 @@ ZERO_ARGS(bitcoinrpc,getinfo)
printf("set RTheight.%d 1st %d\n",coin->RTheight,coin->firstRTheight);
}
if ( (fullnodes= jarray(&m,item,"supernet")) != 0 )
{
incr = 1;
if ( strcmp(coin->symbol,"NOTARY") == 0 )
{
for (j=0; j<m; j++)
basilisk_addrelay_info(myinfo,0,(uint32_t)calc_ipbits(jstri(fullnodes,j)),GENESIS_PUBKEY);
incr = sqrt(m);
if ( incr < 1 )
incr = 1, j = 0;
else j = (myinfo->myaddr.pubkey.uints[0] % incr);
} else j = 0;
for (; j<m; j+=incr)
{
//fprintf(stderr,"[%s] ",jstri(fullnodes,j));
iguana_launchpeer(coin,jstri(fullnodes,j),1);

2
iguana/tests/addnotarys

@ -7,3 +7,5 @@ curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"ad
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.242\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.243\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.244\"}"
sleep 3
./getinfoN

Loading…
Cancel
Save