Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
3cb67e67ef
  1. 2
      iguana/SuperNET.c
  2. 16
      iguana/pangea_api.c
  3. 21
      iguana/pangea_hand.c

2
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); //printf("validpub.%d: %x vs %x shared.%llx\n",addr->validpub,checkc,othercheckc,(long long)addr->sharedseed.txid);
} }
maxdelay = juint(json,"maxdelay"); 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); 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 ) if ( (myipaddr= jstr(json,"yourip")) != 0 )
SuperNET_myipaddr(SuperNET_MYINFO(0),coin,addr,myipaddr,ipaddr); SuperNET_myipaddr(SuperNET_MYINFO(0),coin,addr,myipaddr,ipaddr);

16
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 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 ) if ( rwflag == 0 && serialized[datalen-1] == 0 )
json = cJSON_Parse((char *)serialized); json = cJSON_Parse((char *)serialized);
else if ( rwflag == 1 && endianedp[datalen-1] == 0 ) 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 ) else if ( datalen >= sizeof(bits256) && (datalen % sizeof(bits256)) == 0 )
{ {
n = (int32_t)(datalen / sizeof(bits256)); n = (int32_t)(datalen / sizeof(bits256));
pubkeys = (void *)serialized;
for (i=0; i<n; i++) for (i=0; i<n; i++)
{ {
if ( rwflag != 0 ) if ( rwflag != 0 )
memcpy(&X,&endianedp[len],sizeof(bits256)); len += iguana_rwbignum(rwflag,&serialized[len],sizeof(bits256),X.bytes);
len += iguana_rwbignum(1,&serialized[len],sizeof(bits256),&endianedp[len]); else
if ( rwflag == 0 ) {
memcpy(&endianedp[len],&X,sizeof(bits256)); len += iguana_rwbignum(0,pubkeys[i].bytes,sizeof(bits256),X.bytes);
pubkeys[i] = X;
//char str[65]; printf("i.%d len.%d X.%s\n",i,len,bits256_str(str,pubkeys[i]));
}
} }
} }
else else
@ -454,7 +458,7 @@ int32_t pangea_hexmsg(struct supernet_info *myinfo,void *data,int32_t len,char *
flag++; flag++;
iguana_rwbignum(0,pm->tablehash.bytes,sizeof(bits256),tablehash.bytes); iguana_rwbignum(0,pm->tablehash.bytes,sizeof(bits256),tablehash.bytes);
pm->tablehash = tablehash; 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 ) if ( serialized[datalen-1] == 0 && (argjson= cJSON_Parse((char *)pm->serialized)) != 0 )
{ {
pangea_parse(myinfo,pm,argjson,remoteaddr); pangea_parse(myinfo,pm,argjson,remoteaddr);

21
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) 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; hand = &tp->hand;
numcards = tp->G.numcards; numcards = tp->G.numcards;
if ( data == 0 || datalen != (numcards + 1 + tp->G.numactive) * sizeof(bits256) ) if ( data == 0 || datalen != (numcards + 1 + tp->G.numactive) * sizeof(bits256) )
@ -185,6 +185,8 @@ void pangea_newhand(PANGEA_HANDARGS)
pubkeys = (bits256 *)data; pubkeys = (bits256 *)data;
n = pm->turni; n = pm->turni;
tp->myind = -1; 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; i<n; i++) for (i=0; i<n; i++)
{ {
/*if ( (ind= pangea_Pind(tp,pubkeys[numcards + 1 + i])) < 0 ) /*if ( (ind= pangea_Pind(tp,pubkeys[numcards + 1 + i])) < 0 )
@ -201,18 +203,23 @@ void pangea_newhand(PANGEA_HANDARGS)
tp->active[i] = &tp->G.P[ind]; tp->active[i] = &tp->G.P[ind];
if ( i == 0 ) if ( i == 0 )
hand->button = ind; 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; 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; 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); 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]); 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 ) if ( bits256_cmp(hand->checkprod,hand->cardpubs[numcards]) != 0 )
{ {
printf("checkprod mismatch myind.%d\n",tp->myind); for (i=0; i<tp->G.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; return;
} }
tp->G.numactive = n; 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(1,(void *)data,tp->priv.audits,cardi,destplayer,N);
pangea_rwaudit(0,audit,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); //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; destplayer = tp->myind;
if ( Debuglevel > 2 ) if ( Debuglevel > 2 )

Loading…
Cancel
Save