Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
04be398bf7
  1. 2
      iguana/exchanges777.h
  2. 2
      iguana/iguana_bundles.c
  3. 25
      iguana/iguana_instantdex.c
  4. 2
      iguana/iguana_tx.c
  5. 6
      iguana/swaps/iguana_BTCswap.c

2
iguana/exchanges777.h

@ -138,7 +138,7 @@ struct bitcoin_swapinfo
bits256 myorderhash,otherorderhash,mypubkey,othertrader;
uint64_t otherdeck[INSTANTDEX_DECKSIZE][2],deck[INSTANTDEX_DECKSIZE][2];
uint64_t altsatoshis,BTCsatoshis,insurance,altpremium,matched64;
int32_t isinitiator,choosei,otherchoosei,cutverified,otherverifiedcut;
int32_t isinitiator,choosei,otherchoosei,cutverified,otherverifiedcut,numpubs;
struct bitcoin_statetx *deposit,*payment,*altpayment,*myfee,*otherfee;
char expectedcmdstr[16],status[16],waitfortx[16];
struct instantdex_stateinfo *state; uint32_t expiration,dead,reftime;

2
iguana/iguana_bundles.c

@ -1411,7 +1411,7 @@ void iguana_bundlestats(struct iguana_info *coin,char *str,int32_t lag)
if ( logfp == 0 )
logfp = fopen("debug.log","wb");
if ( logfp != 0 )
printf("%s bQ.%d %d:%02d:%02d stuck.%d max.%d\n",str,queue_size(&bundlesQ),(int32_t)difft.x/3600,(int32_t)(difft.x/60)%60,(int32_t)difft.x%60,coin->stucktime!=0?(uint32_t)time(NULL) - coin->stucktime:0,coin->maxstuck);
fprintf(logfp,"%s bQ.%d %d:%02d:%02d stuck.%d max.%d\n",str,queue_size(&bundlesQ),(int32_t)difft.x/3600,(int32_t)(difft.x/60)%60,(int32_t)difft.x%60,coin->stucktime!=0?(uint32_t)time(NULL) - coin->stucktime:0,coin->maxstuck);
strcpy(coin->lastdispstr,str);
//if ( (rand() % 100) == 0 )
// myallocated(0,0);

25
iguana/iguana_instantdex.c

@ -892,7 +892,7 @@ struct instantdex_accept *instantdex_acceptable(struct supernet_info *myinfo,str
queue_enqueue("acceptableQ",&exchange->acceptableQ,&PAD.DL,0);
offerdir = instantdex_bidaskdir(&A->offer);
minvol = (A->offer.basevolume64 * minperc * .01);
printf("offerdir.%d (%s/%s) minperc %.3f minvol %.8f vs %.8f\n",offerdir,A->offer.base,A->offer.rel,minperc,dstr(minvol),dstr(A->offer.basevolume64));
printf("instantdex_acceptable offerdir.%d (%s/%s) minperc %.3f minvol %.8f vs %.8f\n",offerdir,A->offer.base,A->offer.rel,minperc,dstr(minvol),dstr(A->offer.basevolume64));
while ( (ap= queue_dequeue(&exchange->acceptableQ,0)) != 0 && ap != &PAD )
{
if ( now > ap->offer.expiration || ap->dead != 0 || A->offer.offer64 == ap->offer.offer64 )
@ -1083,9 +1083,9 @@ char *instantdex_checkoffer(struct supernet_info *myinfo,uint64_t *txidp,struct
*txidp = myap->orderid;
if ( (otherap= instantdex_acceptable(myinfo,exchange,myap,myap->offer.minperc)) == 0 )
{
printf("add.%llu to acceptableQ\n",(long long)myap->orderid);
if ( (retstr= instantdex_sendcmd(myinfo,&myap->offer,argjson,"BTCoffer",GENESIS_PUBKEY,INSTANTDEX_HOPS,0,0,1)) != 0 )
free(retstr);
printf("instantdex_checkoffer add.%llu to acceptableQ\n",(long long)myap->orderid);
//if ( (retstr= instantdex_sendcmd(myinfo,&myap->offer,argjson,"BTCoffer",GENESIS_PUBKEY,INSTANTDEX_HOPS,0,0,1)) != 0 )
// free(retstr);
queue_enqueue("acceptableQ",&exchange->acceptableQ,&myap->DL,0);
return(jprint(instantdex_offerjson(&myap->offer,myap->orderid),1));
}
@ -1094,12 +1094,14 @@ char *instantdex_checkoffer(struct supernet_info *myinfo,uint64_t *txidp,struct
isbob = myap->offer.myside;
swap = bitcoin_swapinit(myinfo,exchange,myap,otherap,1,argjson,isbob != 0 ? "BOB_sentoffer" : "ALICE_sentoffer");
if ( swap != 0 )
{
printf("STATEMACHINEQ.(%llu / %llu)\n",(long long)swap->mine.orderid,(long long)swap->other.orderid);
//queue_enqueue("acceptableQ",&exchange->acceptableQ,&swap->DL,0);
queue_enqueue("statemachineQ",&exchange->statemachineQ,&swap->DL,0);
if ( (newjson= instantdex_parseargjson(myinfo,exchange,swap,argjson,1)) == 0 )
return(clonestr("{\"error\":\"instantdex_checkoffer null newjson\"}"));
return(instantdex_sendcmd(myinfo,&swap->mine.offer,newjson,"BTCoffer",GENESIS_PUBKEY,INSTANTDEX_HOPS,swap->deck,sizeof(swap->deck),1));
//queue_enqueue("acceptableQ",&exchange->acceptableQ,&swap->DL,0);
queue_enqueue("statemachineQ",&exchange->statemachineQ,&swap->DL,0);
if ( (newjson= instantdex_parseargjson(myinfo,exchange,swap,argjson,1)) == 0 )
return(clonestr("{\"error\":\"instantdex_checkoffer null newjson\"}"));
return(instantdex_sendcmd(myinfo,&swap->mine.offer,newjson,"BTCoffer",GENESIS_PUBKEY,INSTANTDEX_HOPS,swap->deck,sizeof(swap->deck),1));
} else printf("error creating statemachine\n");
}
return(retstr);
}
@ -1131,7 +1133,8 @@ char *instantdex_gotoffer(struct supernet_info *myinfo,struct exchange_info *exc
if ( myap->offer.expiration < (time(NULL) + INSTANTDEX_DURATION) || otherap->offer.expiration < (time(NULL) + INSTANTDEX_DURATION) )
return(clonestr("{\"error\":\"instantdex_BTCswap offer too close to expiration\"}"));
isbob = myap->offer.myside;
swap = bitcoin_swapinit(myinfo,exchange,myap,otherap,0,argjson,isbob != 0 ? "BOB_gotoffer" : "ALICE_gotoffer");
if ( (swap= bitcoin_swapinit(myinfo,exchange,myap,otherap,0,argjson,isbob != 0 ? "BOB_gotoffer" : "ALICE_gotoffer")) == 0 )
return(clonestr("{\"error\":\"couldnt allocate statemachine\"}"));
if ( (newjson= instantdex_parseargjson(myinfo,exchange,swap,argjson,1)) == 0 )
{
printf("error parsing argjson\n");
@ -1200,7 +1203,7 @@ char *instantdex_parse(struct supernet_info *myinfo,struct instantdex_msghdr *ms
}
else if ( (swap= instantdex_statemachinefind(myinfo,exchange,A.orderid,1)) != 0 )
{
//printf("found existing state machine %llu\n",(long long)A.orderid);
printf("found existing state machine %llu\n",(long long)A.orderid);
newjson = instantdex_parseargjson(myinfo,exchange,swap,argjson,0);
if ( serdatalen == sizeof(swap->otherdeck) && swap->choosei < 0 && (retstr= instantdex_choosei(swap,newjson,argjson,serdata,serdatalen)) != 0 )
{

2
iguana/iguana_tx.c

@ -156,7 +156,7 @@ struct iguana_txid *iguana_blocktx(struct iguana_info *coin,struct iguana_txid *
return(0);
} // else printf("iguana_blocktx null txidind [%d:%d] i.%d\n",block->hdrsi,block->bundlei,i);
} else printf("iguana_blocktx no bp.[%d]\n",block->hdrsi);
} else printf("blocktx illegal height.%d\n",block->height);
} //else printf("blocktx illegal height.%d\n",block->height);
} else printf("i.%d vs txn_count.%d\n",i,block->RO.txn_count);
return(0);
}

6
iguana/swaps/iguana_BTCswap.c

@ -402,7 +402,7 @@ int32_t instantdex_pubkeyargs(struct supernet_info *myinfo,struct bitcoin_swapin
if ( jobj(newjson,buf) == 0 )
jaddbits256(newjson,buf,pubi);
}
else
else if ( swap->numpubs < INSTANTDEX_DECKSIZE )
{
calc_rmd160_sha256(secret160,swap->privkeys[n].bytes,sizeof(swap->privkeys[n]));
memcpy(&txid,secret160,sizeof(txid));
@ -415,10 +415,12 @@ int32_t instantdex_pubkeyargs(struct supernet_info *myinfo,struct bitcoin_swapin
len += iguana_rwnum(1,(uint8_t *)&swap->deck[m][0],sizeof(txid),&txid);
len += iguana_rwnum(1,(uint8_t *)&swap->deck[m][1],sizeof(pubi.txid),&pubi.txid);
m++;
if ( m > swap->numpubs )
swap->numpubs = m;
}
n++;
}
printf("n.%d m.%d len.%d\n",n,m,len);
printf("n.%d m.%d len.%d numpubs.%d\n",n,m,len,swap->numpubs);
return(n);
}

Loading…
Cancel
Save