From e0e3f61f15afd8000783c5b4cca49466b139b948 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Nov 2018 22:19:19 -1100 Subject: [PATCH] Streamline --- src/cc/dice.cpp | 79 +++++++++++++++++++------------------------------ 1 file changed, 31 insertions(+), 48 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 6d4ea7e90..840f893bd 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1150,12 +1150,6 @@ std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t *resultp, winlosetimeout = 0; } } - if ( AddNormalinputs(mtx,mypk,2*txfee,1) == 0 ) // must be a single vin!! - { - CCerror = "no txfee inputs for win/lose"; - fprintf(stderr,"%s\n", CCerror.c_str() ); - return(""); - } if ( GetTransaction(bettxid,betTx,hashBlock,false) != 0 && GetTransaction(betTx.vin[0].prevout.hash,entropyTx,hashBlock,false) != 0 ) { entropytxid = betTx.vin[0].prevout.hash; @@ -1165,7 +1159,7 @@ std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t *resultp, CSpentIndexValue value2; if ( GetSpentIndex(key,value) != 0 || GetSpentIndex(key2,value2) != 0 ) { - //CCerror = "bettxid already spent"; + CCerror = "bettxid already spent"; fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } @@ -1178,6 +1172,12 @@ std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t *resultp, fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } + if ( AddNormalinputs(mtx,mypk,2*txfee,1) == 0 ) // must be a single vin!! + { + CCerror = "no txfee inputs for win/lose"; + fprintf(stderr,"%s\n", CCerror.c_str() ); + return(""); + } if ( winlosetimeout != 0 ) // dealernode { entropyused = hentropyproof; @@ -1295,54 +1295,37 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx { txid = it->first.txhash; vout = (int32_t)it->first.index; + if ( vout != 0 ) + continue; sum += it->second.satoshis; - if ( GetTransaction(txid,betTx,hashBlock,false) != 0 && betTx.vout.size() >= 3 && betTx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && GetTransaction(betTx.vin[0].prevout.hash,entropyTx,hashBlock,false) != 0 ) + if ( GetTransaction(txid,betTx,hashBlock,false) != 0 && betTx.vout.size() >= 4 && betTx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && GetTransaction(betTx.vin[0].prevout.hash,entropyTx,hashBlock,false) != 0 ) { if ( DecodeDiceOpRet(txid,betTx.vout[betTx.vout.size()-1].scriptPubKey,sbits,fundingtxid,hash,proof) == 'B' ) { - duplicate = 0; - /*for (i=0; i= 100 ) - break; - }*/ - res = DiceBetFinish(funcid,entropyused,&result,txfee,planstr,fundingtxid,txid,scriptPubKey == fundingPubKey); - if ( result > 0 ) - { - mySenddicetransaction(res,entropyused,txid,betTx,funcid); - n++; - fprintf(stderr,"send "); - if ( n >= 1000 ) - break; - } //else error = res; + fprintf(stderr,"status bettxid.%s already spent in mempool\n",txid.GetHex().c_str()); + continue; } - fprintf(stderr,"%d: %s/v%d (%c %.8f) %.8f\n",n,txid.GetHex().c_str(),vout,funcid,(double)it->second.satoshis/COIN,(double)sum/COIN); + /*following didnt work: + bettorentropy = DiceGetEntropy(betTx,'B'); + if ( (iswin= DiceIsWinner(hentropyproof,txid,betTx,entropyTx,bettorentropy,sbits,minbet,maxbet,maxodds,timeoutblocks,fundingtxid)) != 0 ) + { + DiceQueue(iswin,sbits,fundingtxid,txid); + if ( ++n >= 100 ) + break; + }*/ + res = DiceBetFinish(funcid,entropyused,&result,txfee,planstr,fundingtxid,txid,scriptPubKey == fundingPubKey); + if ( result > 0 ) + { + mySenddicetransaction(res,entropyused,txid,betTx,funcid); + n++; + fprintf(stderr,"send "); + if ( n >= 100 ) + break; + } //else error = res; } + fprintf(stderr,"%d: %s/v%d (%c %.8f) %.8f\n",n,txid.GetHex().c_str(),vout,funcid,(double)it->second.satoshis/COIN,(double)sum/COIN); } } if ( scriptPubKey == fundingPubKey )