Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
ede8752828
  1. 2
      iguana/iguana777.h
  2. 18
      iguana/iguana_msg.c

2
iguana/iguana777.h

@ -355,7 +355,7 @@ struct iguana_peer
char ipaddr[64],lastcommand[16],coinstr[16],symbol[16];
uint64_t pingnonce,totalsent,totalrecv; double pingtime,sendmillis,pingsum,getdatamillis;
uint32_t lastcontact,sendtime,ready,startsend,startrecv,pending,ipbits,lastgotaddr,lastblockrecv,pendtime,lastflush,lastpoll;
int32_t dead,addrind,usock,lastheight,protover,relayflag,numpackets,numpings,ipv6,height,rank,pendhdrs,pendblocks,recvhdrs,lastlefti;
int32_t supernet,dead,addrind,usock,lastheight,protover,relayflag,numpackets,numpings,ipv6,height,rank,pendhdrs,pendblocks,recvhdrs,lastlefti;
double recvblocks,recvtotal;
int64_t allocated,freed;
struct msgcounts msgcounts;

18
iguana/iguana_msg.c

@ -124,6 +124,17 @@ int32_t iguana_rwblockhash(int32_t rwflag,uint8_t *serialized,uint32_t *nVersion
return(len);
}*/
int32_t iguana_send_supernet(struct iguana_info *coin,struct iguana_peer *addr,char *jsonstr)
{
int32_t len; uint8_t serialized[8192];
if ( (len= (int32_t)strlen(jsonstr)) < sizeof(serialized)-sizeof(struct iguana_msghdr) )
{
memcpy(&serialized[sizeof(struct iguana_msghdr)],jsonstr,len+1);
return(iguana_queue_send(coin,addr,serialized,"SuperNET",len+1,0,1));
}
else return(-1);
}
void iguana_gotversion(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_msgversion *vers)
{
uint8_t serialized[sizeof(struct iguana_msghdr)];
@ -139,7 +150,12 @@ void iguana_gotversion(struct iguana_info *coin,struct iguana_peer *addr,struct
iguana_gotdata(coin,addr,addr->height);
iguana_queue_send(coin,addr,serialized,"verack",0,0,0);
//iguana_send_ping(coin,addr);
} else printf("nServices.%llx nonce.%llu invalid version message from.(%s)\n",(long long)vers->nServices,(long long)vers->nonce,addr->ipaddr);
} else printf("nServices.%lld nonce.%llu invalid version message from.(%s)\n",(long long)vers->nServices,(long long)vers->nonce,addr->ipaddr);
if ( (vers->nServices & (1<<7)) == (1<<7) )
{
addr->supernet = 1;
iguana_send_supernet(coin,addr,"{\"agent\":\"SuperNET\",\"method\":\"hello\"}");
}
if ( vers->nStartingHeight > coin->longestchain )
coin->longestchain = vers->nStartingHeight;
iguana_queue_send(coin,addr,serialized,"getaddr",0,0,0);

Loading…
Cancel
Save