Browse Source

test

release/v0.1
jl777 8 years ago
parent
commit
aa30d7cf71
  1. 8
      basilisk/basilisk.c
  2. 15
      iguana/iguana_accept.c
  3. 7
      iguana/iguana_msg.c
  4. 2
      iguana/iguana_peers.c

8
basilisk/basilisk.c

@ -292,7 +292,7 @@ void basilisk_sendback(struct supernet_info *myinfo,char *origCMD,char *symbol,c
jaddbits256(valsobj,"chaintip",virt->blocks.hwmchain.RO.hash2); jaddbits256(valsobj,"chaintip",virt->blocks.hwmchain.RO.hash2);
} }
data = basilisk_jsondata(sizeof(struct iguana_msghdr),&allocptr,space,sizeof(space),&datalen,symbol,valsobj,basilisktag); data = basilisk_jsondata(sizeof(struct iguana_msghdr),&allocptr,space,sizeof(space),&datalen,symbol,valsobj,basilisktag);
//printf("sendback.%d -> %s\n",datalen,remoteaddr); printf("sendback.%d -> %s\n",datalen,remoteaddr);
basilisk_sendcmd(myinfo,remoteaddr,"RET",&basilisktag,encryptflag,delaymillis,data,datalen,0,0); basilisk_sendcmd(myinfo,remoteaddr,"RET",&basilisktag,encryptflag,delaymillis,data,datalen,0,0);
if ( allocptr != 0 ) if ( allocptr != 0 )
free(allocptr); free(allocptr);
@ -544,7 +544,7 @@ void basilisk_result(struct supernet_info *myinfo,char *remoteaddr,uint32_t basi
{ {
retstr = jprint(vals,0); retstr = jprint(vals,0);
safecopy(CMD,jstr(vals,"origcmd"),sizeof(CMD)); safecopy(CMD,jstr(vals,"origcmd"),sizeof(CMD));
if ( 0 && strcmp("RID",CMD) != 0 ) //if ( 0 && strcmp("RID",CMD) != 0 )
printf("(%s) -> Q.%u results vals.(%s)\n",CMD,basilisktag,retstr); printf("(%s) -> Q.%u results vals.(%s)\n",CMD,basilisktag,retstr);
if ( strcmp(CMD,"GET") == 0 ) if ( strcmp(CMD,"GET") == 0 )
basilisk_geckoresult(myinfo,remoteaddr,retstr,data,datalen); basilisk_geckoresult(myinfo,remoteaddr,retstr,data,datalen);
@ -711,7 +711,7 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende
printf("services %s\n",type); printf("services %s\n",type);
if ( (retstr= (*basilisk_services[i][1])(myinfo,type,addr,remoteaddr,basilisktag,valsobj,data,datalen,hash,from_basilisk)) != 0 ) if ( (retstr= (*basilisk_services[i][1])(myinfo,type,addr,remoteaddr,basilisktag,valsobj,data,datalen,hash,from_basilisk)) != 0 )
{ {
//printf("from_basilisk.%d ret.(%s)\n",from_basilisk,retstr); printf("from_basilisk.%d ret.(%s)\n",from_basilisk,retstr);
//if ( from_basilisk != 0 || strcmp(CMD,"GET") == 0 ) //if ( from_basilisk != 0 || strcmp(CMD,"GET") == 0 )
basilisk_sendback(myinfo,CMD,symbol,remoteaddr,basilisktag,retstr); basilisk_sendback(myinfo,CMD,symbol,remoteaddr,basilisktag,retstr);
if ( retstr != 0 ) if ( retstr != 0 )
@ -756,7 +756,7 @@ void basilisk_p2p(void *_myinfo,void *_addr,char *senderip,uint8_t *data,int32_t
len += iguana_rwnum(0,data,sizeof(basilisktag),&basilisktag); len += iguana_rwnum(0,data,sizeof(basilisktag),&basilisktag);
//int32_t i; for (i=0; i<datalen-len; i++) //int32_t i; for (i=0; i<datalen-len; i++)
// printf("%02x",data[len+i]); // printf("%02x",data[len+i]);
if ( 0 && RELAYID >= 0 ) //if ( 0 && RELAYID >= 0 )
printf(" ->received.%d basilisk_p2p.(%s) from %s tag.%d\n",datalen,type,senderip!=0?senderip:"?",basilisktag); printf(" ->received.%d basilisk_p2p.(%s) from %s tag.%d\n",datalen,type,senderip!=0?senderip:"?",basilisktag);
basilisk_msgprocess(myinfo,_addr,ipbits,type,basilisktag,&data[len],datalen - len); basilisk_msgprocess(myinfo,_addr,ipbits,type,basilisktag,&data[len],datalen - len);
} }

15
iguana/iguana_accept.c

@ -101,15 +101,18 @@ void iguana_acceptloop(void *args)
printf("incoming %s (%s:%u)\n",coin->symbol,ipaddr,cli_addr.sin_port); printf("incoming %s (%s:%u)\n",coin->symbol,ipaddr,cli_addr.sin_port);
for (i=flag=0; i<IGUANA_MAXPEERS; i++) for (i=flag=0; i<IGUANA_MAXPEERS; i++)
{ {
if ( coin->peers->active[i].ipbits == (uint32_t)ipbits && coin->peers->active[i].usock >= 0 ) addr = &coin->peers->active[i];
if ( addr->ipbits == (uint32_t)ipbits && addr->usock >= 0 )
{ {
//printf("found existing %s peer.(%s) in slot[%d]\n",coin->symbol,ipaddr,i); //printf("found existing %s peer.(%s) in slot[%d]\n",coin->symbol,ipaddr,i);
close(coin->peers->active[i].usock); close(addr->usock);
coin->peers->active[i].dead = 0; addr->dead = 0;
coin->peers->active[i].usock = sock; addr->usock = sock;
coin->peers->active[i].A.port = cli_addr.sin_port; addr->A.port = cli_addr.sin_port;
coin->peers->active[i].ready = (uint32_t)time(NULL); addr->ready = (uint32_t)time(NULL);
flag = 1; flag = 1;
iguana_send_version(coin,addr,coin->myservices);
//instantdex_peerhas_clear(coin,&coin->peers->active[i]); //instantdex_peerhas_clear(coin,&coin->peers->active[i]);
//iguana_iAkill(coin,&coin->peers->active[i],0); //iguana_iAkill(coin,&coin->peers->active[i],0);
//sleep(1); //sleep(1);

7
iguana/iguana_msg.c

@ -315,7 +315,9 @@ void iguana_gotversion(struct supernet_info *myinfo,struct iguana_info *coin,str
if ( strncmp(vers->strSubVer,"/iguana",strlen("/iguana")) == 0 ) if ( strncmp(vers->strSubVer,"/iguana",strlen("/iguana")) == 0 )
addr->supernet = 1, addr->basilisk = 0; addr->supernet = 1, addr->basilisk = 0;
else if ( strncmp(vers->strSubVer,"/basilisk",strlen("/basilisk")) == 0 ) else if ( strncmp(vers->strSubVer,"/basilisk",strlen("/basilisk")) == 0 )
{
addr->basilisk = 1, addr->supernet = 0; addr->basilisk = 1, addr->supernet = 0;
}
//if ( (vers->nServices & NODE_NETWORK) != 0 ) //if ( (vers->nServices & NODE_NETWORK) != 0 )
{ {
addr->protover = (vers->nVersion < PROTOCOL_VERSION) ? vers->nVersion : PROTOCOL_VERSION; addr->protover = (vers->nVersion < PROTOCOL_VERSION) ? vers->nVersion : PROTOCOL_VERSION;
@ -393,7 +395,8 @@ void iguana_gotverack(struct supernet_info *myinfo,struct iguana_info *coin,stru
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); if ( addr->supernet != 0 || addr->basilisk != 0 )
printf(">>>>>>>>>> supernet.%d basilisk.%d gotverack from %s\n",addr->supernet,addr->basilisk,addr->ipaddr);
addr->A.nTime = (uint32_t)time(NULL); addr->A.nTime = (uint32_t)time(NULL);
iguana_queue_send(addr,0,serialized,"getaddr",0); iguana_queue_send(addr,0,serialized,"getaddr",0);
iguana_supernet_ping(myinfo,coin,addr); iguana_supernet_ping(myinfo,coin,addr);
@ -887,7 +890,7 @@ int32_t iguana_msgparser(struct supernet_info *myinfo,struct iguana_info *coin,s
} }
if ( addr != 0 ) if ( addr != 0 )
{ {
if ( addr->msgcounts.verack == 0 ) if ( 0 && addr->msgcounts.verack == 0 )
printf("iguana_msgparser verack.%d from (%s) parse.(%s) len.%d\n",addr->msgcounts.verack,addr->ipaddr,H->command,recvlen); printf("iguana_msgparser verack.%d from (%s) parse.(%s) len.%d\n",addr->msgcounts.verack,addr->ipaddr,H->command,recvlen);
//iguana_peerblockrequest(coin,addr->blockspace,IGUANA_MAXPACKETSIZE,addr,iguana_blockhash(coin,100),0); //iguana_peerblockrequest(coin,addr->blockspace,IGUANA_MAXPACKETSIZE,addr,iguana_blockhash(coin,100),0);
addr->lastcontact = (uint32_t)time(NULL); addr->lastcontact = (uint32_t)time(NULL);

2
iguana/iguana_peers.c

@ -1211,7 +1211,7 @@ void iguana_dedicatedloop(struct supernet_info *myinfo,struct iguana_info *coin,
else else
{ {
sleep(1 + (rand() % 3)); sleep(1 + (rand() % 3));
printf("greeting send version myservices.%llu to (%s)\n",(long long)coin->myservices,addr->ipaddr); //printf("greeting send version myservices.%llu to (%s)\n",(long long)coin->myservices,addr->ipaddr);
iguana_send_version(coin,addr,coin->myservices); iguana_send_version(coin,addr,coin->myservices);
} }
//sleep(1+(rand()%5)); //sleep(1+(rand()%5));

Loading…
Cancel
Save