Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
a074f7aee4
  1. 4
      crypto777/curve25519.c
  2. 4
      iguana/SuperNET.c
  3. 4
      iguana/SuperNET_hexmsg.c
  4. 2
      iguana/iguana777.h
  5. 17
      iguana/iguana_json.c
  6. 20
      iguana/iguana_peers.c
  7. 19
      iguana/pangea_api.c
  8. 8
      iguana/pangea_json.c
  9. 1
      includes/iguana_apideclares.h

4
crypto777/curve25519.c

@ -1825,8 +1825,8 @@ uint64_t acct777_validate(struct acct777_sig *sig,bits256 privkey,bits256 pubkey
acct777_sign(&checksig,privkey,pubkey,sig->timestamp,serialized,datalen);
if ( memcmp(checksig.sigbits.bytes,sig->sigbits.bytes,sizeof(checksig.sigbits)) != 0 )
{
char *bits256_str();
char str[65],str2[65]; printf("sig compare error using sig->pub from %llu\n>>>>>>>> sig.(%s) vs (%s)",(long long)acct777_nxt64bits(sig->pubkey),bits256_str(str,checksig.sigbits),bits256_str(str2,sig->sigbits));
//char *bits256_str();
//char str[65],str2[65]; printf("sig compare error using sig->pub from %llu\n>>>>>>>> sig.(%s) vs (%s)",(long long)acct777_nxt64bits(sig->pubkey),bits256_str(str,checksig.sigbits),bits256_str(str2,sig->sigbits));
return(0);
}
signerbits = acct777_nxt64bits(sig->pubkey);

4
iguana/SuperNET.c

@ -471,7 +471,7 @@ int32_t iguana_send_supernet(struct iguana_info *coin,struct iguana_peer *addr,c
checkc = SuperNET_checkc(nextprivkey,nextdestpub,&nextpubkey.txid,sizeof(nextpubkey.txid));
if ( (datalen= SuperNET_json2bits(&serialized[sizeof(struct iguana_msghdr)],IGUANA_MAXPACKETSIZE,json,nextpubkey,checkc,(uint32_t)calc_ipbits(myinfo->ipaddr),(uint32_t)calc_ipbits(addr->ipaddr),addr->othervalid)) > 0 )
{
if ( jstr(json,"method") != 0 && strcmp("getpeers",jstr(json,"method")) != 0 )
if ( 0 && jstr(json,"method") != 0 && strcmp("getpeers",jstr(json,"method")) != 0 )
printf("SUPERSEND -> (%s) (%s) delaymillis.%d datalen.%d\n",jprint(SuperNET_bits2json(&serialized[sizeof(struct iguana_msghdr)],datalen),1),addr->ipaddr,delaymillis,datalen);
if ( 0 && memcmp(destpub.bytes,GENESIS_PUBKEY.bytes,sizeof(destpub)) == 0 )
qlen = iguana_queue_send(coin,addr,delaymillis,serialized,"SuperNET",datalen,0,0);
@ -765,7 +765,7 @@ char *SuperNET_p2p(struct iguana_info *coin,struct iguana_peer *addr,int32_t *de
//printf("validpub.%d: %x vs %x shared.%llx\n",addr->validpub,checkc,othercheckc,(long long)addr->sharedseed.txid);
}
maxdelay = juint(json,"maxdelay");
if ( jstr(json,"method") != 0 && strcmp(jstr(json,"method"),"getpeers") != 0 )
if ( 0 && jstr(json,"method") != 0 && strcmp(jstr(json,"method"),"getpeers") != 0 )
printf("GOT >>>>>>>> SUPERNET P2P.(%s) from.%s %s valid.%d:%d\n",jprint(json,0),coin->symbol,addr->ipaddr,addr->validpub,addr->othervalid);
if ( (myipaddr= jstr(json,"yourip")) != 0 )
SuperNET_myipaddr(SuperNET_MYINFO(0),coin,addr,myipaddr,ipaddr);

4
iguana/SuperNET_hexmsg.c

@ -92,7 +92,7 @@ void SuperNET_hexmsgprocess(struct supernet_info *myinfo,cJSON *json,char *hexms
{
(*cat->process_func)(myinfo,buf,len,remoteaddr);
flag = 1;
printf("PROCESSFUNC\n");
//printf("PROCESSFUNC\n");
}
}
if ( flag == 0 )
@ -100,7 +100,7 @@ void SuperNET_hexmsgprocess(struct supernet_info *myinfo,cJSON *json,char *hexms
printf("no processfunc, posthexmsg\n");
category_posthexmsg(myinfo,categoryhash,jbits256(json,"subhash"),hexmsg,tai_now(),remoteaddr);
}
char str[65]; printf("HEXPROCESS.(%s) -> %s\n",hexmsg,bits256_str(str,categoryhash));
//char str[65]; printf("HEXPROCESS.(%s) -> %s\n",hexmsg,bits256_str(str,categoryhash));
if ( buf != _buf )
free(buf);
}

2
iguana/iguana777.h

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

17
iguana/iguana_json.c

@ -522,6 +522,23 @@ TWO_STRINGS(iguana,addnode,activecoin,ipaddr)
} else return(clonestr("{\"error\":\"addnode needs ipaddr\"}"));
}
TWO_STRINGS(iguana,persistent,activecoin,ipaddr)
{
int32_t i;
if ( coin != 0 && ipaddr != 0 )
{
for (i=0; i<IGUANA_MAXPEERS; i++)
{
if ( strcmp(coin->peers.active[i].ipaddr,ipaddr) == 0 )
{
coin->peers.active[i].persistent_peer = juint(json,"interval")+3;
return(clonestr("{\"result\":\"node marked as persistent\"}"));
}
}
return(clonestr("{\"result\":\"node wasnt active\"}"));
} else return(clonestr("{\"error\":\"persistent needs coin and ipaddr\"}"));
}
TWO_STRINGS(iguana,removenode,activecoin,ipaddr)
{
int32_t i;

20
iguana/iguana_peers.c

@ -1019,7 +1019,25 @@ void iguana_dedicatedloop(struct iguana_info *coin,struct iguana_peer *addr)
iguana_send_supernet(coin,addr,SUPERNET_GETPEERSTR,0);
lastping = (uint32_t)time(NULL);
}
if ( coin->isRT != 0 && addr->rank > coin->MAXPEERS && (rand() % 100) == 0 )
if ( addr->persistent_peer != 0 )
{
uint16_t port;
if ( addr->usock < 0 || addr->dead != 0 )
{
if ( addr->usock >= 0 )
closesocket(addr->usock);
addr->usock = -1;
while ( addr->usock < 0 )
{
printf("persistent peer.(%s) disconnected... reconnect\n",addr->ipaddr);
sleep(addr->persistent_peer);
if ( (port= (uint16_t)(addr->ipbits >> 32)) == 0 )
port = coin->chain->portp2p;
addr->usock = iguana_socket(0,addr->ipaddr,port);
}
}
}
else if ( coin->isRT != 0 && addr->rank > coin->MAXPEERS && (rand() % 100) == 0 )
{
printf("isRT and low rank.%d ",addr->rank);
addr->dead = 1;

19
iguana/pangea_api.c

@ -120,10 +120,10 @@ struct pangea_msghdr *pangea_msgcreate(struct supernet_info *myinfo,bits256 tabl
acct777_sign(&pm->sig,myinfo->privkey,otherpubkey,timestamp,serialized,datalen);
if ( pangea_validate(pm,acct777_msgprivkey(serialized,datalen),pm->sig.pubkey) == 0 )
{
int32_t i; char str[65],str2[65];
for (i=0; i<datalen; i++)
printf("%02x",serialized[i]);
printf(">>>>>>>>>>>>>>>> validated [%ld] len.%d (%s + %s)\n",(long)serialized-(long)pm,datalen,bits256_str(str,acct777_msgprivkey(serialized,datalen)),bits256_str(str2,pm->sig.pubkey));
//int32_t i; char str[65],str2[65];
//for (i=0; i<datalen; i++)
// printf("%02x",serialized[i]);
//printf(">>>>>>>>>>>>>>>> validated [%ld] len.%d (%s + %s)\n",(long)serialized-(long)pm,datalen,bits256_str(str,acct777_msgprivkey(serialized,datalen)),bits256_str(str2,pm->sig.pubkey));
memset(buf,0,sizeof(buf));
acct777_rwsig(1,buf,&pm->sig);
memcpy(&pm->sig,buf,sizeof(buf));
@ -314,7 +314,12 @@ void pangea_tableaccept(PANGEA_HANDARGS)
{
iguana_launch(coin,"connection",iguana_startconnection,addr,IGUANA_CONNTHREAD);
printf("launch start connection to (%s)\n",ipaddr);
} else printf("already connected\n");
}
else
{
printf("already connected\n");
addr->persistent_peer = 1;
}
} else printf("no open iguana peer slots, cant connect\n");
if ( tp->G.numactive >= tp->G.minplayers && pangea_tableismine(myinfo,tp) >= 0 )
{
@ -391,14 +396,14 @@ int32_t pangea_hexmsg(struct supernet_info *myinfo,void *data,int32_t len,char *
free_json(argjson);
return(1);
}
printf("pm.%p len.%d serialized.%p datalen.%d crc.%u %s\n",pm,len,serialized,datalen,calc_crc32(0,(void *)pm,len),bits256_str(str,pm->sig.pubkey));
//printf("pm.%p len.%d serialized.%p datalen.%d crc.%u %s\n",pm,len,serialized,datalen,calc_crc32(0,(void *)pm,len),bits256_str(str,pm->sig.pubkey));
//return(0);
if ( pangea_validate(pm,acct777_msgprivkey(serialized,datalen),pm->sig.pubkey) == 0 )
{
flag++;
iguana_rwbignum(0,pm->tablehash.bytes,sizeof(bits256),tablehash.bytes);
pm->tablehash = tablehash;
printf("<<<<<<<<<<<<< sigsize.%ld VALIDATED [%ld] len.%d t%u allocsize.%d (%s) [%d]\n",sizeof(pm->sig),(long)serialized-(long)pm,datalen,pm->sig.timestamp,pm->sig.allocsize,(char *)pm->serialized,serialized[datalen-1]);
//printf("<<<<<<<<<<<<< sigsize.%ld VALIDATED [%ld] len.%d t%u allocsize.%d (%s) [%d]\n",sizeof(pm->sig),(long)serialized-(long)pm,datalen,pm->sig.timestamp,pm->sig.allocsize,(char *)pm->serialized,serialized[datalen-1]);
if ( serialized[datalen-1] == 0 && (argjson= cJSON_Parse((char *)pm->serialized)) != 0 )
{
pangea_parse(myinfo,pm,argjson);

8
iguana/pangea_json.c

@ -59,8 +59,12 @@ void pangea_gamecreate(struct game_info *gp,uint32_t timestamp,bits256 tablehash
gp->hostipbits = calc_ipbits(jstr(json,"myipaddr"));
gp->minbuyin = jdouble(json,"minbuyin") * SATOSHIDEN;
gp->maxbuyin = jdouble(json,"maxbuyin") * SATOSHIDEN;
gp->minplayers = juint(json,"minplayers");
gp->maxplayers = juint(json,"maxplayers");
if ( (gp->minplayers= juint(json,"minplayers")) < 2 )
gp->minplayers = 2;
if ( (gp->maxplayers= juint(json,"maxplayers")) < gp->minplayers )
gp->maxplayers = gp->minplayers;
else if ( gp->maxplayers > CARDS777_MAXPLAYERS )
gp->maxplayers = CARDS777_MAXPLAYERS;
if ( (gp->N= juint(json,"N")) < gp->minplayers )
gp->N = gp->minplayers;
if ( (gp->M= juint(json,"M")) > gp->N )

1
includes/iguana_apideclares.h

@ -68,6 +68,7 @@ STRING_ARG(iguana,addcoin,activecoin);
STRING_ARG(iguana,startcoin,activecoin);
STRING_ARG(iguana,pausecoin,activecoin);
TWO_STRINGS(iguana,addnode,activecoin,ipaddr);
TWO_STRINGS(iguana,persistent,activecoin,ipaddr);
TWO_STRINGS(iguana,removenode,activecoin,ipaddr);
TWO_STRINGS(iguana,oneshot,activecoin,ipaddr);
TWO_STRINGS(iguana,nodestatus,activecoin,ipaddr);

Loading…
Cancel
Save