From 3cb67e67ef2e1e1ad2104e945c5bc432c29f42ec Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 25 Jan 2016 00:51:09 -0300 Subject: [PATCH] test --- iguana/SuperNET.c | 2 +- iguana/pangea_api.c | 16 ++++++++++------ iguana/pangea_hand.c | 21 ++++++++++++++------- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/iguana/SuperNET.c b/iguana/SuperNET.c index e055a14f2..b465e4065 100644 --- a/iguana/SuperNET.c +++ b/iguana/SuperNET.c @@ -770,7 +770,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 ( 0 && jstr(json,"method") != 0 && strcmp(jstr(json,"method"),"getpeers") != 0 ) + if ( 1 && 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); diff --git a/iguana/pangea_api.c b/iguana/pangea_api.c index d015df1bd..e88369b20 100755 --- a/iguana/pangea_api.c +++ b/iguana/pangea_api.c @@ -64,7 +64,7 @@ int32_t pangea_validate(struct pangea_msghdr *pm,bits256 privkey,bits256 pubkey) int32_t pangea_rwdata(int32_t rwflag,uint8_t *serialized,int32_t datalen,uint8_t *endianedp) { - int32_t i,n,len = 0; uint64_t x; bits256 X; cJSON *json; + int32_t i,n,len = 0; uint64_t x; bits256 X,*pubkeys; cJSON *json; if ( rwflag == 0 && serialized[datalen-1] == 0 ) json = cJSON_Parse((char *)serialized); else if ( rwflag == 1 && endianedp[datalen-1] == 0 ) @@ -89,13 +89,17 @@ int32_t pangea_rwdata(int32_t rwflag,uint8_t *serialized,int32_t datalen,uint8_t else if ( datalen >= sizeof(bits256) && (datalen % sizeof(bits256)) == 0 ) { n = (int32_t)(datalen / sizeof(bits256)); + pubkeys = (void *)serialized; for (i=0; itablehash.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,remoteaddr); diff --git a/iguana/pangea_hand.c b/iguana/pangea_hand.c index 51bd16a6e..981ace826 100755 --- a/iguana/pangea_hand.c +++ b/iguana/pangea_hand.c @@ -174,7 +174,7 @@ int32_t pangea_newdeck(struct supernet_info *myinfo,struct table_info *tp) void pangea_newhand(PANGEA_HANDARGS) { - int32_t i,handid,numcards,n,ind; struct hand_info *hand; bits256 *pubkeys; + int32_t i,handid,numcards,n,ind; struct hand_info *hand; bits256 *pubkeys; char str[65],str2[65]; hand = &tp->hand; numcards = tp->G.numcards; if ( data == 0 || datalen != (numcards + 1 + tp->G.numactive) * sizeof(bits256) ) @@ -185,6 +185,8 @@ void pangea_newhand(PANGEA_HANDARGS) pubkeys = (bits256 *)data; n = pm->turni; tp->myind = -1; + tp->priv.mypriv = myinfo->persistent_priv, tp->priv.mypub = myinfo->myaddr.persistent; + tp->G.M = (tp->G.numactive >> 1) + 1; for (i=0; iactive[i] = &tp->G.P[ind]; if ( i == 0 ) hand->button = ind; - if ( tp->G.P[ind].nxt64bits == myinfo->myaddr.nxt64bits ) + if ( bits256_cmp(tp->G.P[ind].playerpub,myinfo->myaddr.persistent)) tp->priv.myind = i; + printf("player.%d (%s) vs persistent.(%s) myind.%d\n",i,bits256_str(str,tp->G.P[ind].playerpub),bits256_str(str2,myinfo->myaddr.persistent),tp->priv.myind ); } - tp->priv.mypriv = myinfo->privkey, tp->priv.mypub = myinfo->myaddr.pubkey; - tp->G.M = (tp->G.numactive >> 1) + 1; hand->startdecktime = pm->sig.timestamp; - memcpy(hand->cardpubs,pubkeys,numcards * sizeof(bits256)); + memcpy(hand->cardpubs,pubkeys,(numcards +1 + tp->G.numactive) * sizeof(bits256)); PNACL_message("player.%d NEWHAND.%llx received numhands.%d button.%d cardi.%d | N %d numactive.%d\n",tp->myind,(long long)hand->cardpubs[numcards].txid,tp->numhands,hand->button,hand->cardi,tp->G.N,n); + printf("check.%s\n",bits256_str(str,hand->cardpubs[numcards])); hand->checkprod = cards777_pubkeys(hand->cardpubs,numcards,hand->cardpubs[numcards]); + printf("B check.%s\n",bits256_str(str,hand->checkprod)); + printf("P0.%s\n",bits256_str(str,hand->cardpubs[numcards+1])); + printf("P1.%s\n",bits256_str(str,hand->cardpubs[numcards+2])); if ( bits256_cmp(hand->checkprod,hand->cardpubs[numcards]) != 0 ) { - printf("checkprod mismatch myind.%d\n",tp->myind); + for (i=0; iG.numcards; i++) + printf("%d: %s\n",i,bits256_str(str,hand->cardpubs[i])); + printf("checkprod mismatch myind.%d %s\n",tp->myind,bits256_str(str,hand->cardpubs[i])); return; } tp->G.numactive = n; @@ -377,7 +384,7 @@ void pangea_card(PANGEA_HANDARGS) pangea_rwaudit(1,(void *)data,tp->priv.audits,cardi,destplayer,N); pangea_rwaudit(0,audit,tp->priv.audits,cardi,destplayer,N); //PNACL_message("card.%d destplayer.%d [%llx]\n",cardi,destplayer,(long long)audit[0].txid); - if ( (card= cards777_checkcard(&cardpriv,cardi,tp->myind,destplayer,myinfo->privkey,hand->cardpubs,tp->G.numcards,audit[0])) >= 0 ) + if ( (card= cards777_checkcard(&cardpriv,cardi,tp->myind,destplayer,myinfo->persistent_priv,hand->cardpubs,tp->G.numcards,audit[0])) >= 0 ) { destplayer = tp->myind; if ( Debuglevel > 2 )