Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
20e6870efa
  1. 5
      iguana/iguana777.c
  2. 2
      iguana/iguana_accept.c
  3. 8
      iguana/iguana_msg.c
  4. 6
      iguana/iguana_peers.c
  5. 2
      iguana/main.c

5
iguana/iguana777.c

@ -674,6 +674,8 @@ void iguana_coinloop(void *arg)
if ( coin->peers.numranked < (7*coin->MAXPEERS/8) && now > coin->lastpossible ) if ( coin->peers.numranked < (7*coin->MAXPEERS/8) && now > coin->lastpossible )
{ {
//fprintf(stderr,"possible\n"); //fprintf(stderr,"possible\n");
if ( coin->peers.numranked > 0 && (now % 60) == 0 )
iguana_send_ping(coin,coin->peers.ranked[rand() % coin->peers.numranked]);
coin->lastpossible = iguana_possible_peer(coin,0); // tries to connect to new peers coin->lastpossible = iguana_possible_peer(coin,0); // tries to connect to new peers
} }
} }
@ -681,7 +683,8 @@ void iguana_coinloop(void *arg)
{ {
if ( coin->peers.numranked < ((7*coin->MAXPEERS)>>3) && now > coin->lastpossible ) if ( coin->peers.numranked < ((7*coin->MAXPEERS)>>3) && now > coin->lastpossible )
{ {
//fprintf(stderr,"possible\n"); if ( coin->peers.numranked > 0 && (now % 60) == 0 )
iguana_send_ping(coin,coin->peers.ranked[rand() % coin->peers.numranked]);
coin->lastpossible = iguana_possible_peer(coin,0); // tries to connect to new peers coin->lastpossible = iguana_possible_peer(coin,0); // tries to connect to new peers
} }
} }

2
iguana/iguana_accept.c

@ -234,5 +234,7 @@ int32_t iguana_peeraddrrequest(struct iguana_info *coin,struct iguana_peer *addr
} }
iguana_rwvarint(1,&space[sizeof(H)],&x); iguana_rwvarint(1,&space[sizeof(H)],&x);
printf("addrrequest: sendlen.%d x.%d\n",sendlen,(int32_t)x); printf("addrrequest: sendlen.%d x.%d\n",sendlen,(int32_t)x);
if ( x == 0 )
return(-1);
return(sendlen); return(sendlen);
} }

8
iguana/iguana_msg.c

@ -217,7 +217,7 @@ void iguana_gotverack(struct iguana_info *coin,struct iguana_peer *addr)
uint8_t serialized[sizeof(struct iguana_msghdr)]; uint8_t serialized[sizeof(struct iguana_msghdr)];
if ( addr != 0 ) if ( addr != 0 )
{ {
//printf("gotverack from %s\n",addr->ipaddr); printf("gotverack from %s\n",addr->ipaddr);
addr->A.nTime = (uint32_t)time(NULL); addr->A.nTime = (uint32_t)time(NULL);
iguana_queue_send(coin,addr,0,serialized,"getaddr",0,0,0); iguana_queue_send(coin,addr,0,serialized,"getaddr",0,0,0);
if ( addr->supernet != 0 ) if ( addr->supernet != 0 )
@ -237,7 +237,7 @@ void iguana_gotaddr(struct iguana_info *coin,struct iguana_peer *addr,struct igu
if ( port != 0 ) if ( port != 0 )
sprintf(ipport,"%s:%d",ipaddr,port); sprintf(ipport,"%s:%d",ipaddr,port);
iguana_possible_peer(coin,ipport); iguana_possible_peer(coin,ipport);
//printf("gotaddr.(%s:%d)\n",ipaddr,port); printf("gotaddr.(%s:%d) from (%s)\n",ipaddr,port,addr->ipaddr);
} }
void iguana_gotping(struct iguana_info *coin,struct iguana_peer *addr,uint64_t nonce,uint8_t *data) void iguana_gotping(struct iguana_info *coin,struct iguana_peer *addr,uint64_t nonce,uint8_t *data)
@ -264,7 +264,7 @@ int32_t iguana_send_ping(struct iguana_info *coin,struct iguana_peer *addr)
addr->pingnonce = ((nonce & 0xffffffff) << 32) | ((uint32_t)addr->ipbits & 0xffffffff); addr->pingnonce = ((nonce & 0xffffffff) << 32) | ((uint32_t)addr->ipbits & 0xffffffff);
addr->pingtime = (uint32_t)time(NULL); addr->pingtime = (uint32_t)time(NULL);
} }
//printf("pingnonce.%llx\n",(long long)nonce); printf("pingnonce.%llx from (%s)\n",(long long)nonce,addr->ipaddr);
len = iguana_rwnum(1,&serialized[sizeof(struct iguana_msghdr)],sizeof(uint64_t),&nonce); len = iguana_rwnum(1,&serialized[sizeof(struct iguana_msghdr)],sizeof(uint64_t),&nonce);
if ( addr->supernet != 0 ) if ( addr->supernet != 0 )
iguana_send_supernet(coin,addr,SUPERNET_GETPEERSTR,0); iguana_send_supernet(coin,addr,SUPERNET_GETPEERSTR,0);
@ -540,7 +540,7 @@ int32_t iguana_msgparser(struct iguana_info *coin,struct iguana_peer *addr,struc
strcpy(addr->lastcommand,H->command); strcpy(addr->lastcommand,H->command);
} }
retval = 0; retval = 0;
//printf("iguana_msgparser %s parse.(%s)\n",addr->ipaddr,H->command); printf("iguana_msgparser from (%s) parse.(%s) len.%d\n",addr->ipaddr,H->command,recvlen);
if ( strncmp(H->command,"SuperNET",strlen("SuperNET")) == 0 ) if ( strncmp(H->command,"SuperNET",strlen("SuperNET")) == 0 )
{ {
addr->supernet = 1; addr->supernet = 1;

6
iguana/iguana_peers.c

@ -463,7 +463,7 @@ int32_t iguana_queue_send(struct iguana_info *coin,struct iguana_peer *addr,int3
packet->embargo.millis += delay; packet->embargo.millis += delay;
} }
memcpy(packet->serialized,serialized,datalen); memcpy(packet->serialized,serialized,datalen);
//printf("%p queue send.(%s) %d to (%s)\n",packet,serialized+4,datalen,addr->ipaddr); printf("%p queue send.(%s) %d to (%s)\n",packet,serialized+4,datalen,addr->ipaddr);
queue_enqueue("sendQ",&addr->sendQ,&packet->DL,0); queue_enqueue("sendQ",&addr->sendQ,&packet->DL,0);
return(datalen); return(datalen);
} }
@ -757,12 +757,12 @@ void *iguana_iAddriterator(struct iguana_info *coin,struct iguana_iAddr *iA)
uint32_t iguana_possible_peer(struct iguana_info *coin,char *ipaddr) uint32_t iguana_possible_peer(struct iguana_info *coin,char *ipaddr)
{ {
char checkaddr[64]; uint64_t ipbits; uint32_t now = (uint32_t)time(NULL); int32_t i,n; struct iguana_iAddr *iA; char checkaddr[64]; uint64_t ipbits; uint32_t now = (uint32_t)time(NULL); int32_t i,n; struct iguana_iAddr *iA;
if ( ipaddr != 0 ) if ( ipaddr != 0 && ipaddr[0] != 0 )
{ {
for (i=n=0; i<coin->MAXPEERS; i++) for (i=n=0; i<coin->MAXPEERS; i++)
if ( strcmp(ipaddr,coin->peers.active[i].ipaddr) == 0 ) if ( strcmp(ipaddr,coin->peers.active[i].ipaddr) == 0 )
{ {
printf("%s possible peer.%s already there\n",coin->symbol,ipaddr); printf("%s possible peer.(%s) %x already there\n",coin->symbol,ipaddr,(uint32_t)coin->peers.active[i].ipbits);
return(0); return(0);
} }
queue_enqueue("possibleQ",&coin->possibleQ,queueitem(ipaddr),1); queue_enqueue("possibleQ",&coin->possibleQ,queueitem(ipaddr),1);

2
iguana/main.c

@ -1142,7 +1142,7 @@ void iguana_appletests(struct supernet_info *myinfo)
exit(-1); exit(-1);
} }
sleep(1);*/ sleep(1);*/
if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"prefetchlag\":13,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":500,\"endpend\":500,\"services\":129,\"maxpeers\":64,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":4,\"poll\":1}"),0,myinfo->rpcport)) != 0 ) if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"prefetchlag\":13,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":500,\"endpend\":500,\"services\":128,\"maxpeers\":64,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":4,\"poll\":1}"),0,myinfo->rpcport)) != 0 )
{ {
free(str); free(str);
if ( 0 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":1024,\"maxpeers\":256,\"newcoin\":\"BTCD\",\"active\":1}"),0,myinfo->rpcport)) != 0 ) if ( 0 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":1024,\"maxpeers\":256,\"newcoin\":\"BTCD\",\"active\":1}"),0,myinfo->rpcport)) != 0 )

Loading…
Cancel
Save