|
@ -153,7 +153,7 @@ int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *typ |
|
|
else if ( fanout > BASILISK_MAXFANOUT ) |
|
|
else if ( fanout > BASILISK_MAXFANOUT ) |
|
|
fanout = BASILISK_MAXFANOUT; |
|
|
fanout = BASILISK_MAXFANOUT; |
|
|
if ( type == 0 ) |
|
|
if ( type == 0 ) |
|
|
type = "BTCD"; |
|
|
type = "INF"; |
|
|
if ( strlen(type) > 3 ) |
|
|
if ( strlen(type) > 3 ) |
|
|
{ |
|
|
{ |
|
|
printf("basilisk_sendcmd illegal type(%s)\n",type); |
|
|
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 ) |
|
|
if ( coin->peers == 0 ) |
|
|
continue; |
|
|
continue; |
|
|
|
|
|
//if ( basilisk_notarycmd(type) != 0 && strcmp(coin->symbol,"NOTARY") != 0 )
|
|
|
|
|
|
// continue;
|
|
|
if ( coin->FULLNODE == 0 && coin->VALIDATENODE == 0 ) |
|
|
if ( coin->FULLNODE == 0 && coin->VALIDATENODE == 0 ) |
|
|
cmd[0] = 's'; |
|
|
cmd[0] = 's'; |
|
|
else 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; |
|
|
s = 0; |
|
|
valid = (addr->supernet != 0); |
|
|
valid = (addr->supernet != 0); |
|
|
if ( basilisk_notarycmd(type) != 0 && myinfo->IAMNOTARY != 0 ) |
|
|
if ( basilisk_notarycmd(type) != 0 ) |
|
|
{ |
|
|
{ |
|
|
valid = 0; |
|
|
valid = 0; |
|
|
OS_randombytes((void *)&r2,sizeof(r2)); |
|
|
/*OS_randombytes((void *)&r2,sizeof(r2));
|
|
|
if ( (r2 % myinfo->NOTARY.NUMRELAYS) >= sqrt(myinfo->NOTARY.NUMRELAYS) ) |
|
|
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; |
|
|
continue; |
|
|
} |
|
|
}*/ |
|
|
for (s=0; s<myinfo->NOTARY.NUMRELAYS; s++) |
|
|
for (s=0; s<myinfo->NOTARY.NUMRELAYS; s++) |
|
|
if ( addr->ipbits != myinfo->myaddr.myipbits && myinfo->NOTARY.RELAYS[s].ipbits == addr->ipbits ) |
|
|
if ( addr->ipbits != myinfo->myaddr.myipbits && myinfo->NOTARY.RELAYS[s].ipbits == addr->ipbits ) |
|
|
break; |
|
|
break; |
|
|
if ( s == myinfo->NOTARY.NUMRELAYS ) |
|
|
if ( s == myinfo->NOTARY.NUMRELAYS ) |
|
|
{ |
|
|
{ |
|
|
//printf("skip non-relay.(%s)\n",addr->ipaddr);
|
|
|
printf("skip non-relay.(%s)\n",addr->ipaddr); |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
valid = 1; |
|
|
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) ) |
|
|
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");
|
|
|
//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 ) |
|
|
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; |
|
|
return; |
|
|
} else if ( basilisk_notarycmd(CMD) != 0 ) |
|
|
} else if ( basilisk_notarycmd(CMD) != 0 ) |
|
|
return; |
|
|
return; |
|
|
symbol = "BTCD"; |
|
|
symbol = "NOTARY"; |
|
|
if ( senderipbits == 0 ) |
|
|
if ( senderipbits == 0 ) |
|
|
expand_ipbits(remoteaddr,myinfo->myaddr.myipbits); |
|
|
expand_ipbits(remoteaddr,myinfo->myaddr.myipbits); |
|
|
else expand_ipbits(remoteaddr,senderipbits); |
|
|
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; |
|
|
data += jsonlen, datalen -= jsonlen; |
|
|
else data = 0, datalen = 0; |
|
|
else data = 0, datalen = 0; |
|
|
if ( coin == 0 ) |
|
|
if ( coin == 0 ) |
|
|
coin = iguana_coinfind("BTCD"); |
|
|
coin = iguana_coinfind(symbol); |
|
|
if ( coin != 0 ) |
|
|
if ( coin != 0 ) |
|
|
{ |
|
|
{ |
|
|
symbol = coin->symbol; |
|
|
symbol = coin->symbol; |
|
|