Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
a60208618b
  1. 1
      iguana/iguana777.h
  2. 3
      iguana/iguana_msg.c
  3. 11
      iguana/iguana_peers.c

1
iguana/iguana777.h

@ -660,5 +660,6 @@ struct iguana_info *iguana_coinfind(const char *symbol);
struct iguana_info *iguana_coinadd(const char *symbol); struct iguana_info *iguana_coinadd(const char *symbol);
struct iguana_ramchain *iguana_bundleload(struct iguana_info *coin,struct iguana_bundle *bp); struct iguana_ramchain *iguana_bundleload(struct iguana_info *coin,struct iguana_bundle *bp);
int32_t iguana_sendblockreq(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_bundle *bp,int32_t bundlei,bits256 hash2,int32_t iamthreadsafe); int32_t iguana_sendblockreq(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_bundle *bp,int32_t bundlei,bits256 hash2,int32_t iamthreadsafe);
int32_t iguana_send_supernet(struct iguana_info *coin,struct iguana_peer *addr,char *jsonstr);
#endif #endif

3
iguana/iguana_msg.c

@ -130,6 +130,7 @@ int32_t iguana_send_supernet(struct iguana_info *coin,struct iguana_peer *addr,c
if ( (len= (int32_t)strlen(jsonstr)) < sizeof(serialized)-sizeof(struct iguana_msghdr) ) if ( (len= (int32_t)strlen(jsonstr)) < sizeof(serialized)-sizeof(struct iguana_msghdr) )
{ {
memcpy(&serialized[sizeof(struct iguana_msghdr)],jsonstr,len+1); memcpy(&serialized[sizeof(struct iguana_msghdr)],jsonstr,len+1);
printf("SEND.(%s) -> (%s)\n",jsonstr,addr->ipaddr);
return(iguana_queue_send(coin,addr,serialized,"SuperNET",len+1,0,1)); return(iguana_queue_send(coin,addr,serialized,"SuperNET",len+1,0,1));
} }
else return(-1); else return(-1);
@ -218,6 +219,8 @@ int32_t iguana_send_ping(struct iguana_info *coin,struct iguana_peer *addr)
} }
printf("pingnonce.%llx\n",(long long)nonce); printf("pingnonce.%llx\n",(long long)nonce);
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 )
iguana_send_supernet(coin,addr,"{\"agent\":\"SuperNET\",\"method\":\"getpeers\"}");
return(iguana_queue_send(coin,addr,serialized,"ping",len,0,0)); return(iguana_queue_send(coin,addr,serialized,"ping",len,0,0));
} }

11
iguana/iguana_peers.c

@ -561,7 +561,7 @@ void iguana_startconnection(void *arg)
printf("avoid self-loopback\n"); printf("avoid self-loopback\n");
return; return;
} }
printf("startconnection.(%s) pending.%u usock.%d addrind.%d\n",addr->ipaddr,addr->pending,addr->usock,addr->addrind); //printf("startconnection.(%s) pending.%u usock.%d addrind.%d\n",addr->ipaddr,addr->pending,addr->usock,addr->addrind);
addr->pending = (uint32_t)time(NULL); addr->pending = (uint32_t)time(NULL);
if ( addr->usock < 0 ) if ( addr->usock < 0 )
addr->usock = iguana_socket(0,addr->ipaddr,coin->chain->portp2p); addr->usock = iguana_socket(0,addr->ipaddr,coin->chain->portp2p);
@ -569,7 +569,7 @@ void iguana_startconnection(void *arg)
{ {
strcpy(ipaddr,addr->ipaddr); strcpy(ipaddr,addr->ipaddr);
iguana_iAkill(coin,addr,1); iguana_iAkill(coin,addr,1);
printf("refused PEER KILLED. for %s:%d usock.%d\n",addr->ipaddr,coin->chain->portp2p,addr->usock); //printf("refused PEER KILLED. for %s:%d usock.%d\n",addr->ipaddr,coin->chain->portp2p,addr->usock);
} }
else else
{ {
@ -643,7 +643,7 @@ void *iguana_iAddriterator(struct iguana_info *coin,struct iguana_iAddr *iA)
addr->pending = (uint32_t)time(NULL); addr->pending = (uint32_t)time(NULL);
if ( iguana_rwiAddrind(coin,1,iA,iA->hh.itemind) > 0 ) if ( iguana_rwiAddrind(coin,1,iA,iA->hh.itemind) > 0 )
{ {
printf("iA.%p iguana_startconnection.(%s) status.%d pending.%d\n",iA,addr->ipaddr,iA->status,addr->pending); //printf("iA.%p iguana_startconnection.(%s) status.%d pending.%d\n",iA,addr->ipaddr,iA->status,addr->pending);
iguana_launch(coin,"connection",iguana_startconnection,addr,IGUANA_CONNTHREAD); iguana_launch(coin,"connection",iguana_startconnection,addr,IGUANA_CONNTHREAD);
} else printf("error rwiAddrind.%d\n",iA->hh.itemind); } else printf("error rwiAddrind.%d\n",iA->hh.itemind);
} }
@ -726,7 +726,7 @@ int32_t iguana_pollsendQ(struct iguana_info *coin,struct iguana_peer *addr)
struct iguana_packet *packet; struct iguana_packet *packet;
if ( (packet= queue_dequeue(&addr->sendQ,0)) != 0 ) if ( (packet= queue_dequeue(&addr->sendQ,0)) != 0 )
{ {
//printf("%s: send.(%s) usock.%d dead.%u ready.%u\n",addr->ipaddr,packet->serialized+4,addr->usock,addr->dead,addr->ready); printf("%s: send.(%s) usock.%d dead.%u ready.%u\n",addr->ipaddr,packet->serialized+4,addr->usock,addr->dead,addr->ready);
if ( strcmp((char *)&packet->serialized[4],"getdata") == 0 ) if ( strcmp((char *)&packet->serialized[4],"getdata") == 0 )
{ {
printf("unexpected getdata for %s\n",addr->ipaddr); printf("unexpected getdata for %s\n",addr->ipaddr);
@ -891,7 +891,8 @@ void iguana_dedicatedloop(struct iguana_info *coin,struct iguana_peer *addr)
//printf("send version myservices.%llu\n",(long long)coin->myservices); //printf("send version myservices.%llu\n",(long long)coin->myservices);
iguana_send_version(coin,addr,coin->myservices); iguana_send_version(coin,addr,coin->myservices);
iguana_queue_send(coin,addr,serialized,"getaddr",0,0,0); iguana_queue_send(coin,addr,serialized,"getaddr",0,0,0);
//printf("after send version\n"); iguana_send_supernet(coin,addr,"{\"agent\":\"SuperNET\",\"method\":\"getpeers\"}");
//printf("after send version\n");
run = 0; run = 0;
while ( addr->usock >= 0 && addr->dead == 0 && coin->peers.shuttingdown == 0 ) while ( addr->usock >= 0 && addr->dead == 0 && coin->peers.shuttingdown == 0 )
{ {

Loading…
Cancel
Save