Check bettxid in mempool
This commit is contained in:
@@ -95,6 +95,7 @@ int32_t is_hexstr(char *str,int32_t n);
|
||||
bool myAddtomempool(CTransaction &tx);
|
||||
//uint64_t myGettxout(uint256 hash,int32_t n);
|
||||
bool myIsutxo_spentinmempool(uint256 txid,int32_t vout);
|
||||
bool mytxid_inmempool(uint256 txid);
|
||||
int32_t myIsutxo_spent(uint256 &spenttxid,uint256 txid,int32_t vout);
|
||||
int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex);
|
||||
int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp);
|
||||
|
||||
@@ -169,14 +169,24 @@ bool mySenddicetransaction(std::string res,uint256 entropyused,uint256 bettxid,C
|
||||
|
||||
void *dicefinish(void *_ptr)
|
||||
{
|
||||
char str[65],str2[65],name[32]; std::string res; int32_t result; struct dicefinish_info *ptr; uint256 entropyused;
|
||||
char str[65],str2[65],name[32]; std::string res; int32_t i,result; struct dicefinish_info *ptr; uint256 entropyused;
|
||||
ptr = (struct dicefinish_info *)_ptr;
|
||||
usleep(1000000 + (rand() % 3000000)); // wait for bettxid to be in mempool
|
||||
unstringbits(name,ptr->sbits);
|
||||
fprintf(stderr,"dicefinish.%d %s funding.%s bet.%s\n",ptr->iswin,name,uint256_str(str,ptr->fundingtxid),uint256_str(str2,ptr->bettxid));
|
||||
res = DiceBetFinish(entropyused,&result,0,name,ptr->fundingtxid,ptr->bettxid,ptr->iswin);
|
||||
if ( result > 0 )
|
||||
mySenddicetransaction(res,entropyused,ptr->bettxid,ptr->betTx);
|
||||
usleep((rand() % 100000) + 10000);
|
||||
for (i=0; i<600; i++)
|
||||
{
|
||||
usleep(100000);
|
||||
if ( mytxid_inmempool(ptr->bettxid) != 0 ) // wait for bettxid to be in mempool
|
||||
{
|
||||
fprintf(stderr,"i.%d dicefinish.%d %s funding.%s bet.%s\n",i,ptr->iswin,name,uint256_str(str,ptr->fundingtxid),uint256_str(str2,ptr->bettxid));
|
||||
res = DiceBetFinish(entropyused,&result,0,name,ptr->fundingtxid,ptr->bettxid,ptr->iswin);
|
||||
if ( result > 0 )
|
||||
mySenddicetransaction(res,entropyused,ptr->bettxid,ptr->betTx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( i == 100 )
|
||||
fprintf(stderr,"dicefinish.%d %s bet.%s didnt arrive in mempool\n",ptr->iswin,name,uint256_str(str,ptr->bettxid));
|
||||
free(ptr);
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -378,6 +378,18 @@ bool myIsutxo_spentinmempool(uint256 txid,int32_t vout)
|
||||
return(false);
|
||||
}
|
||||
|
||||
bool mytxid_inmempool(uint256 txid)
|
||||
{
|
||||
BOOST_FOREACH(const CTxMemPoolEntry &e,mempool.mapTx)
|
||||
{
|
||||
const CTransaction &tx = e.GetTx();
|
||||
const uint256 &hash = tx.GetHash();
|
||||
if ( txid == hash )
|
||||
return(true);
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
UniValue mempoolToJSON(bool fVerbose = false)
|
||||
{
|
||||
if (fVerbose)
|
||||
|
||||
Reference in New Issue
Block a user