This commit is contained in:
jl777
2018-11-07 09:10:50 -11:00
parent 528ed2ecb6
commit 1a78c11437

View File

@@ -98,7 +98,7 @@ What is needed is for the dealer node to track the entropy tx that was already b
#include "../compat/endian.h" #include "../compat/endian.h"
#define MAX_ENTROPYUSED 128 #define MAX_ENTROPYUSED 1024
extern int32_t KOMODO_INSYNC; extern int32_t KOMODO_INSYNC;
static uint256 bettxids[MAX_ENTROPYUSED],entropytxids[MAX_ENTROPYUSED][2]; // change to hashtable static uint256 bettxids[MAX_ENTROPYUSED],entropytxids[MAX_ENTROPYUSED][2]; // change to hashtable
@@ -154,6 +154,14 @@ bool mySenddicetransaction(std::string res,uint256 entropyused,uint256 bettxid,C
LOCK(cs_main); LOCK(cs_main);
if ( myAddtomempool(tx) != 0 ) if ( myAddtomempool(tx) != 0 )
{ {
for (i=0; i<MAX_ENTROPYUSED; i++)
if ( bettxids[i] == zeroid )
{
bettxids[i] = bettxid;
break;
}
if ( i == MAX_ENTROPYUSED )
bettxids[rand() % MAX_ENTROPYUSED] = bettxid;
RelayTransaction(tx); RelayTransaction(tx);
if ( retval == 0 ) if ( retval == 0 )
{ {
@@ -224,13 +232,13 @@ void DiceQueue(int32_t iswin,uint64_t sbits,uint256 fundingtxid,uint256 bettxid,
return; return;
} }
// check for duplicates here!!! // check for duplicates here!!!
/*for (i=0; i<MAX_ENTROPYUSED; i++) for (i=0; i<MAX_ENTROPYUSED; i++)
if ( bettxids[i] == bettxid ) if ( bettxids[i] == bettxid )
{ {
duplicate = 1; duplicate = 1;
break; break;
} }
if ( duplicate == 0 )*/ if ( duplicate == 0 )
{ {
/*for (i=0; i<MAX_ENTROPYUSED; i++) /*for (i=0; i<MAX_ENTROPYUSED; i++)
if ( bettxids[i] == zeroid ) if ( bettxids[i] == zeroid )
@@ -1156,7 +1164,7 @@ std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t *resultp,
CSpentIndexValue value2; CSpentIndexValue value2;
if ( GetSpentIndex(key,value) != 0 || GetSpentIndex(key2,value2) != 0 ) if ( GetSpentIndex(key,value) != 0 || GetSpentIndex(key2,value2) != 0 )
{ {
CCerror = "bettxid already spent"; //CCerror = "bettxid already spent";
fprintf(stderr,"%s\n", CCerror.c_str() ); fprintf(stderr,"%s\n", CCerror.c_str() );
return(""); return("");
} }
@@ -1291,12 +1299,12 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx
if ( DecodeDiceOpRet(txid,betTx.vout[betTx.vout.size()-1].scriptPubKey,sbits,fundingtxid,hash,proof) == 'B' ) if ( DecodeDiceOpRet(txid,betTx.vout[betTx.vout.size()-1].scriptPubKey,sbits,fundingtxid,hash,proof) == 'B' )
{ {
duplicate = 0; duplicate = 0;
/*for (i=0; i<MAX_ENTROPYUSED; i++) for (i=0; i<MAX_ENTROPYUSED; i++)
if ( bettxids[i] == txid ) if ( bettxids[i] == txid )
{ {
duplicate = 1; duplicate = 1;
break; break;
}*/ }
if ( duplicate == 0 ) if ( duplicate == 0 )
{ {
CSpentIndexKey key(txid, 0); CSpentIndexKey key(txid, 0);
@@ -1324,14 +1332,6 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx
res = DiceBetFinish(funcid,entropyused,&result,txfee,planstr,fundingtxid,txid,scriptPubKey == fundingPubKey); res = DiceBetFinish(funcid,entropyused,&result,txfee,planstr,fundingtxid,txid,scriptPubKey == fundingPubKey);
if ( result > 0 ) if ( result > 0 )
{ {
/*for (i=0; i<MAX_ENTROPYUSED; i++)
if ( bettxids[i] == zeroid )
{
bettxids[i] = txid;
break;
}
if ( i == MAX_ENTROPYUSED )
bettxids[rand() % MAX_ENTROPYUSED] = txid;*/
mySenddicetransaction(res,entropyused,txid,betTx,funcid); mySenddicetransaction(res,entropyused,txid,betTx,funcid);
n++; n++;
if ( n >= 100 ) if ( n >= 100 )