Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
7aeb752ceb
  1. 6
      basilisk/basilisk_DEX.c
  2. 64
      basilisk/basilisk_swap.c
  3. 2
      iguana/iguana_peers.c
  4. 2
      iguana/main.c

6
basilisk/basilisk_DEX.c

@ -197,7 +197,7 @@ int32_t basilisk_ping_processDEX(struct supernet_info *myinfo,uint32_t senderipb
if ( relay->numrequests < relay->maxrequests )
{
memcpy(serialized,&data[len],clen);
printf("ping processDEX\n");
//printf("ping processDEX\n");
n = basilisk_rwDEXquote(0,serialized,&R);
if ( n != clen )
printf("n.%d clen.%d\n",n,clen);
@ -206,7 +206,7 @@ int32_t basilisk_ping_processDEX(struct supernet_info *myinfo,uint32_t senderipb
if ( crc == R.requestid )
{
relay->requests[relay->numrequests++] = R;
printf("[(%s %.8f) -> (%s %.8f) r.%u q.%u] ",R.src,dstr(R.srcamount),R.dest,dstr(R.destamount),R.requestid,R.quoteid);
//printf("[(%s %.8f) -> (%s %.8f) r.%u q.%u] ",R.src,dstr(R.srcamount),R.dest,dstr(R.destamount),R.requestid,R.quoteid);
} else printf("crc.%u error vs %u\n",crc,R.requestid);
} else printf("relay num.%d >= max.%d\n",relay->numrequests,relay->maxrequests);
} else len += clen;
@ -247,7 +247,7 @@ int32_t basilisk_ping_genDEX(struct supernet_info *myinfo,uint8_t *data,int32_t
{
DL_DELETE(myinfo->DEX_quotes,item);
free(item);
} else printf("now.%u vs timestamp.%u, lag.%d\n",now,timestamp,now-timestamp);
} //else printf("now.%u vs timestamp.%u, lag.%d\n",now,timestamp,now-timestamp);
}
portable_mutex_unlock(&myinfo->DEX_mutex);
sn = i;

64
basilisk/basilisk_swap.c

@ -841,7 +841,6 @@ int32_t basilisk_swapdata_deck(struct supernet_info *myinfo,struct basilisk_swap
int32_t basilisk_verify_otherdeck(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t datalen)
{
int32_t i,len = 0;
printf("verify otherdeck\n");
for (i=0; i<sizeof(swap->otherdeck)/sizeof(swap->otherdeck[0][0]); i++)
len += iguana_rwnum(0,&data[len],sizeof(swap->otherdeck[i>>1][i&1]),&swap->otherdeck[i>>1][i&1]);
return(0);
@ -918,9 +917,12 @@ void basilisk_swap01(struct supernet_info *myinfo,struct basilisk_swap *swap,uin
void basilisk_swap02(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen)
{
printf("check for other deck\n");
if ( basilisk_swapget(myinfo,swap,0x02,data,maxlen,basilisk_verify_otherdeck) == 0 )
swap->statebits |= 0x02;
if ( (swap->statebits & 0x02) == 0 )
{
printf("check for other deck\n");
if ( basilisk_swapget(myinfo,swap,0x02,data,maxlen,basilisk_verify_otherdeck) == 0 )
swap->statebits |= 0x02;
}
}
void basilisk_swap04(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen)
@ -1021,36 +1023,23 @@ void basilisk_swaploop(void *_swap)
while ( time(NULL) < swap->expiration )
{
printf("r%u/q%u swapstate.%x\n",swap->req.requestid,swap->req.quoteid,swap->statebits);
if ( swap->iambob != 0 )
if ( (swap->statebits & 0x08) == 0 )
{
if ( (swap->statebits & 0x08) == 0 )
{
basilisk_swap01(myinfo,swap,data,maxlen); // send pubkeys
basilisk_swap08(myinfo,swap,data,maxlen); // wait for choosei
}
else
{
basilisk_swap02(myinfo,swap,data,maxlen); // check for other deck
basilisk_swap04(myinfo,swap,data,maxlen); // send choosei
if ( (swap->statebits & 0x10) == 0 && swap->otherchoosei >= 0 && swap->otherchoosei < INSTANTDEX_DECKSIZE ) // send all but one privkeys
basilisk_swap10(myinfo,swap,data,maxlen);
}
basilisk_swap01(myinfo,swap,data,maxlen); // send pubkeys
basilisk_swap08(myinfo,swap,data,maxlen); // wait for choosei
}
else
if ( (swap->statebits & 0x10) == 0 )
{
if ( (swap->statebits & 0x10) == 0 )
{
basilisk_swap02(myinfo,swap,data,maxlen); // check for other deck
basilisk_swap04(myinfo,swap,data,maxlen); // send choosei
if ( (swap->statebits & 0x10) == 0 && swap->otherchoosei >= 0 && swap->otherchoosei < INSTANTDEX_DECKSIZE ) // send all but one privkeys
basilisk_swap10(myinfo,swap,data,maxlen);
}
else
{
basilisk_swap04(myinfo,swap,data,maxlen); // send choosei
basilisk_swap01(myinfo,swap,data,maxlen); // send pubkeys
basilisk_swap08(myinfo,swap,data,maxlen); // wait for choosei
}
basilisk_swap02(myinfo,swap,data,maxlen); // check for other deck
basilisk_swap04(myinfo,swap,data,maxlen); // send choosei
if ( (swap->statebits & 0x10) == 0 && swap->otherchoosei >= 0 && swap->otherchoosei < INSTANTDEX_DECKSIZE ) // send all but one privkeys
basilisk_swap10(myinfo,swap,data,maxlen);
}
if ( (swap->statebits & 0x1f) != 0x1f )
{
printf("initial setup incomplete state.%x\n",swap->statebits);
sleep(1);
continue;
}
if ( (swap->statebits & 0x20) == 0 ) // wait for all but one privkeys
{
@ -1128,8 +1117,8 @@ void basilisk_swaploop(void *_swap)
}
else // both sides have setup required data and paid txfee
{
if ( swap->sleeptime < 60 )
swap->sleeptime++;
//if ( swap->sleeptime < 60 )
// swap->sleeptime++;
if ( swap->iambob != 0 )
{
if ( (swap->statebits & 0x100) == 0 )
@ -1305,13 +1294,8 @@ void basilisk_swaploop(void *_swap)
}
}
}
if ( 1 || myinfo->RELAYID >= 0 )
sleep(1);
else
{
if ( swap->sleeptime > 0 )
sleep(swap->sleeptime);
}
printf("finished swapstate.%x\n",swap->statebits);
sleep(1);
}
if ( swap->iambob != 0 )
{

2
iguana/iguana_peers.c

@ -715,7 +715,7 @@ void iguana_startconnection(void *arg)
if ( addr->usock < 0 || (coin->peers != 0 && coin->peers->shuttingdown != 0) )
{
strcpy(ipaddr,addr->ipaddr);
printf("%s refused PEER KILLED. slot.%d for %s:%d usock.%d\n",coin->symbol,addr->addrind,ipaddr,coin->chain->portp2p,addr->usock);
//printf("%s refused PEER KILLED. slot.%d for %s:%d usock.%d\n",coin->symbol,addr->addrind,ipaddr,coin->chain->portp2p,addr->usock);
iguana_iAkill(coin,addr,1);
}
else

2
iguana/main.c

@ -501,7 +501,7 @@ void iguana_appletests(struct supernet_info *myinfo)
bitcoin_sharedsecret(myinfo->ctx,hash2,pubkey,33);
printf("secp256k1 elapsed %.3f for %d iterations\n",OS_milliseconds() - startmillis,i);
getchar();**/
if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"protover\":70002,\"RELAY\":1,\"VALIDATE\":0,\"portp2p\":14631,\"rpc\":14632,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":64,\"endpend\":64,\"services\":129,\"maxpeers\":8,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":1,\"poll\":1}"),0,myinfo->rpcport)) != 0 )
if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"protover\":70002,\"RELAY\":0,\"VALIDATE\":0,\"portp2p\":14631,\"rpc\":14632,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":64,\"endpend\":64,\"services\":129,\"maxpeers\":8,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":1,\"poll\":1}"),0,myinfo->rpcport)) != 0 )
{
free(str);
if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"portp2p\":8333,\"RELAY\":0,\"VALIDATE\":0,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":8,\"newcoin\":\"BTC\",\"active\":0,\"numhelpers\":1,\"poll\":100}"),0,myinfo->rpcport)) != 0 )

Loading…
Cancel
Save