Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
fb8576a4f6
  1. 11
      basilisk/basilisk_ping.c

11
basilisk/basilisk_ping.c

@ -269,8 +269,8 @@ int32_t basilisk_ping_gen(struct supernet_info *myinfo,uint8_t *data,int32_t max
void basilisk_ping_send(struct supernet_info *myinfo,struct iguana_info *btcd) void basilisk_ping_send(struct supernet_info *myinfo,struct iguana_info *btcd)
{ {
struct iguana_peer *addr; char ipaddr[64]; struct basilisk_relay *rp; int32_t i,j,incr,datalen=0; struct iguana_peer *addr; char ipaddr[64]; struct basilisk_relay *rp; uint32_t r; int32_t i,j,incr,datalen=0;
if ( btcd == 0 ) if ( btcd == 0 || myinfo->numrelays <= 0 )
return; return;
if ( myinfo->pingbuf == 0 ) if ( myinfo->pingbuf == 0 )
myinfo->pingbuf = malloc(IGUANA_MAXPACKETSIZE); myinfo->pingbuf = malloc(IGUANA_MAXPACKETSIZE);
@ -278,7 +278,8 @@ void basilisk_ping_send(struct supernet_info *myinfo,struct iguana_info *btcd)
incr = sqrt(myinfo->numrelays) + 1; incr = sqrt(myinfo->numrelays) + 1;
for (j=0; j<incr; j++) for (j=0; j<incr; j++)
{ {
i = (j == 0) ? myinfo->RELAYID : (rand() % myinfo->numrelays); OS_randombytes((void *)&r,sizeof(r));
i = (j == 0) ? myinfo->RELAYID : (r % myinfo->numrelays);
if ( j != 0 && i == myinfo->RELAYID ) if ( j != 0 && i == myinfo->RELAYID )
i = (myinfo->RELAYID + 1) % myinfo->numrelays; i = (myinfo->RELAYID + 1) % myinfo->numrelays;
rp = &myinfo->relays[i]; rp = &myinfo->relays[i];
@ -291,8 +292,8 @@ void basilisk_ping_send(struct supernet_info *myinfo,struct iguana_info *btcd)
if ( iguana_queue_send(addr,0,myinfo->pingbuf,"SuperNETPIN",datalen) <= 0 ) if ( iguana_queue_send(addr,0,myinfo->pingbuf,"SuperNETPIN",datalen) <= 0 )
printf("error sending %d to (%s)\n",datalen,addr->ipaddr); printf("error sending %d to (%s)\n",datalen,addr->ipaddr);
else if ( datalen > 200 ) else if ( datalen > 200 )
printf("+(%s) ",addr->ipaddr); fprintf(stderr,"+(%s).%d ",ipaddr,i);
} //else printf("-(%s) ",ipaddr); } else fprintf(stderr,"-(%s).%d ",ipaddr,i);
} }
//printf("my RELAYID.%d of %d\n",myinfo->RELAYID,myinfo->numrelays); //printf("my RELAYID.%d of %d\n",myinfo->RELAYID,myinfo->numrelays);
} }

Loading…
Cancel
Save