From 2ac06413e1621f967bc7c0a8800d1cda782173b1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 1 Aug 2018 04:39:42 -1100 Subject: [PATCH] Iterate relay until in mempool --- src/cc/dice.cpp | 17 ++++++++++++----- src/main.cpp | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 685ddd9fc..5c62a0240 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -15,7 +15,7 @@ #include "CCdice.h" -// timeout, validate, verify win/loss can be used for entropy +// timeout /* in order to implement a dice game, we need a source of entropy, reasonably fast completion time and a way to manage the utxos. @@ -122,13 +122,20 @@ void *dicefinish(void *_ptr) res = DiceWinLoseTimeout(&result,0,name,ptr->fundingtxid,ptr->bettxid,ptr->iswin); if ( result != 0 && res.empty() == 0 && res.size() > 64 && is_hexstr((char *)res.c_str(),0) > 64 ) { - LOCK(cs_main); + //LOCK(cs_main); if ( DecodeHexTx(tx,res) != 0 ) { txid = tx.GetHash(); - myAddtomempool(tx); - RelayTransaction(tx); fprintf(stderr,"%s\nresult.(%s)\n",res.c_str(),uint256_str(str,txid)); + for (i=0; i<10; i++) + { + if ( myAddtomempool(tx) == 0 ) + { + RelayTransaction(tx); + fprintf(stderr,"Relay transaction\n"); + sleep(1); + } else break; + } } } } @@ -645,7 +652,7 @@ uint64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbi fprintf(stderr," (%c) entropy vin.%d fundingPubKey mismatch %s\n",funcid,tx.vin[0].prevout.n,uint256_str(str,tx.vin[0].prevout.hash)); continue; } - } else fprintf(stderr,"not E or is funding\n"); + } //else fprintf(stderr,"not E or is funding\n"); entropytxid = txid; entropyval = tx.vout[0].nValue; first = 1; diff --git a/src/main.cpp b/src/main.cpp index 5dc9ad4a7..2ec680009 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1608,7 +1608,7 @@ bool myAddtomempool(CTransaction &tx) CValidationState state; CTransaction Ltx; bool fMissingInputs,fOverrideFees = false; if ( mempool.lookup(tx.GetHash(),Ltx) == 0 ) return(AcceptToMemoryPool(mempool, state, tx, false, &fMissingInputs, !fOverrideFees)); - else return(false); + else return(true); } bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock)