Lockflag
This commit is contained in:
@@ -170,7 +170,7 @@ static int32_t ignorevin;
|
||||
bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock);
|
||||
int32_t is_hexstr(char *str,int32_t n);
|
||||
bool myAddtomempool(CTransaction &tx, CValidationState *pstate = NULL, bool fSkipExpiry = false);
|
||||
int32_t CCgettxout(uint256 txid,int32_t vout,int32_t mempoolflag);
|
||||
int32_t CCgettxout(uint256 txid,int32_t vout,int32_t mempoolflag,int32_t lockflag);
|
||||
bool myIsutxo_spentinmempool(uint256 &spenttxid,int32_t &spentvini,uint256 txid,int32_t vout);
|
||||
bool mytxid_inmempool(uint256 txid);
|
||||
int32_t myIsutxo_spent(uint256 &spenttxid,uint256 txid,int32_t vout);
|
||||
|
||||
@@ -347,17 +347,28 @@ int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout)
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t CCgettxout(uint256 txid,int32_t vout,int32_t mempoolflag)
|
||||
int32_t CCgettxout(uint256 txid,int32_t vout,int32_t mempoolflag,int32_t lockflag)
|
||||
{
|
||||
CCoins coins;
|
||||
if ( mempoolflag != 0 )
|
||||
{
|
||||
LOCK(mempool.cs);
|
||||
CCoinsViewMemPool view(pcoinsTip, mempool);
|
||||
if (!view.GetCoins(txid, coins))
|
||||
return(-1);
|
||||
if ( myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) != 0 )
|
||||
return(-1);
|
||||
if ( lockflag != 0 )
|
||||
{
|
||||
LOCK(mempool.cs);
|
||||
CCoinsViewMemPool view(pcoinsTip, mempool);
|
||||
if (!view.GetCoins(txid, coins))
|
||||
return(-1);
|
||||
if ( myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) != 0 )
|
||||
return(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
CCoinsViewMemPool view(pcoinsTip, mempool);
|
||||
if (!view.GetCoins(txid, coins))
|
||||
return(-1);
|
||||
if ( myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) != 0 )
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -167,7 +167,7 @@ int32_t MarmaraGetbatontxid(std::vector<uint256> &creditloop,uint256 &batontxid,
|
||||
creditloop.push_back(txid);
|
||||
//fprintf(stderr,"%d: %s\n",n,txid.GetHex().c_str());
|
||||
n++;
|
||||
if ( (value= CCgettxout(spenttxid,vout,1)) == 10000 )
|
||||
if ( (value= CCgettxout(spenttxid,vout,1,1)) == 10000 )
|
||||
{
|
||||
batontxid = spenttxid;
|
||||
//fprintf(stderr,"got baton %s %.8f\n",batontxid.GetHex().c_str(),(double)value/COIN);
|
||||
|
||||
@@ -295,7 +295,7 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa
|
||||
txid = tx.GetHash();
|
||||
//fprintf(stderr,"set txid %s %llu\n",txid.GetHex().c_str(),(long long)CCgettxout(txid,0,1));
|
||||
}
|
||||
if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) == txfee && (unspentv0 == 0 || CCgettxout(txid,0,1) == txfee) )
|
||||
if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) == txfee && (unspentv0 == 0 || CCgettxout(txid,0,1,0) == txfee) )
|
||||
{
|
||||
if ( rogue_newgameopreturndecode(buyin,maxplayers,tx.vout[numvouts-1].scriptPubKey) == 'G' )
|
||||
{
|
||||
@@ -343,7 +343,7 @@ UniValue rogue_playerobj(std::vector<uint8_t> playerdata,uint256 playertxid,uint
|
||||
}
|
||||
txid = playertxid;
|
||||
vout = 1;
|
||||
while ( CCgettxout(txid,vout,1) < 0 )
|
||||
while ( CCgettxout(txid,vout,1,0) < 0 )
|
||||
{
|
||||
spenttxid = zeroid;
|
||||
spentvini = -1;
|
||||
@@ -462,7 +462,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,uint
|
||||
int32_t rogue_playerdataspend(CMutableTransaction &mtx,uint256 playertxid,int32_t vout,uint256 origplayergame)
|
||||
{
|
||||
int64_t txfee = 10000; CTransaction tx; uint256 hashBlock;
|
||||
if ( CCgettxout(playertxid,vout,1) == 1 ) // not sure if this is enough validation
|
||||
if ( CCgettxout(playertxid,vout,1,0) == 1 ) // not sure if this is enough validation
|
||||
{
|
||||
mtx.vin.push_back(CTxIn(playertxid,vout,CScript()));
|
||||
return(0);
|
||||
@@ -472,7 +472,7 @@ int32_t rogue_playerdataspend(CMutableTransaction &mtx,uint256 playertxid,int32_
|
||||
vout = 0;
|
||||
if ( myGetTransaction(playertxid,tx,hashBlock) != 0 && tx.vout[vout].nValue == 1 && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 )
|
||||
{
|
||||
if ( CCgettxout(playertxid,vout,1) == 1 ) // not sure if this is enough validation
|
||||
if ( CCgettxout(playertxid,vout,1,0) == 1 ) // not sure if this is enough validation
|
||||
{
|
||||
mtx.vin.push_back(CTxIn(playertxid,vout,CScript()));
|
||||
return(0);
|
||||
@@ -520,16 +520,21 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke
|
||||
txid = matchtx.GetHash();
|
||||
fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str());
|
||||
n = 0;
|
||||
while ( CCgettxout(txid,0,1) < 0 )
|
||||
while ( CCgettxout(txid,0,1,0) < 0 )
|
||||
{
|
||||
spenttxid = zeroid;
|
||||
spentvini = -1;
|
||||
fprintf(stderr,"check myIsutxo_spent\n");
|
||||
if ( (spentvini= myIsutxo_spent(spenttxid,txid,0)) >= 0 )
|
||||
txid = spenttxid;
|
||||
else if ( myIsutxo_spentinmempool(spenttxid,spentvini,txid,0) == 0 || spenttxid == zeroid )
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"mempool tracking error %s/v0\n",txid.ToString().c_str());
|
||||
return(-2);
|
||||
fprintf(stderr,"check myIsutxo_spentinmempool\n");
|
||||
if ( myIsutxo_spentinmempool(spenttxid,spentvini,txid,0) == 0 || spenttxid == zeroid )
|
||||
{
|
||||
fprintf(stderr,"mempool tracking error %s/v0\n",txid.ToString().c_str());
|
||||
return(-2);
|
||||
}
|
||||
}
|
||||
txid = spenttxid;
|
||||
fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini);
|
||||
@@ -590,16 +595,16 @@ int32_t rogue_playersalive(int32_t &openslots,int32_t &numplayers,uint256 gametx
|
||||
registration_open = 1;
|
||||
for (i=0; i<maxplayers; i++)
|
||||
{
|
||||
if ( CCgettxout(gametxid,1+i,1) < 0 )
|
||||
if ( CCgettxout(gametxid,1+i,1,0) < 0 )
|
||||
{
|
||||
numplayers++;
|
||||
if ( CCgettxout(gametxid,1+maxplayers+i,1) == txfee )
|
||||
if ( CCgettxout(gametxid,1+maxplayers+i,1,0) == txfee )
|
||||
{
|
||||
txid = gametxid;
|
||||
vout = 1+i;
|
||||
//fprintf(stderr,"scan forward active.%s spenttxid.%s\n",gametxid.GetHex().c_str(),txid.GetHex().c_str());
|
||||
n = 0;
|
||||
while ( CCgettxout(txid,vout,1) < 0 )
|
||||
while ( CCgettxout(txid,vout,1,0) < 0 )
|
||||
{
|
||||
spenttxid = zeroid;
|
||||
spentvini = -1;
|
||||
@@ -680,7 +685,7 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet
|
||||
obj.push_back(Pair("slot",(int64_t)vout-1));
|
||||
if ( (retval= rogue_findbaton(cp,playertxid,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,destaddr,numplayers,symbol,pname)) == 0 )
|
||||
{
|
||||
if ( CCgettxout(gametxid,maxplayers+vout,1) == 10000 )
|
||||
if ( CCgettxout(gametxid,maxplayers+vout,1,0) == 10000 )
|
||||
{
|
||||
if ( myGetTransaction(batontxid,batontx,hashBlock) != 0 && batontx.vout.size() > 1 )
|
||||
{
|
||||
@@ -710,7 +715,7 @@ int64_t rogue_registrationbaton(CMutableTransaction &mtx,uint256 gametxid,CTrans
|
||||
for (j=0; j<maxplayers; j++)
|
||||
{
|
||||
vout = ((r + j) % maxplayers) + 1;
|
||||
if ( CCgettxout(gametxid,vout,1) == ROGUE_REGISTRATIONSIZE )
|
||||
if ( CCgettxout(gametxid,vout,1,0) == ROGUE_REGISTRATIONSIZE )
|
||||
{
|
||||
mtx.vin.push_back(CTxIn(gametxid,vout,CScript()));
|
||||
return(ROGUE_REGISTRATIONSIZE);
|
||||
@@ -1301,7 +1306,7 @@ UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
|
||||
result.push_back(Pair("seed",(int64_t)seed));
|
||||
for (i=0; i<maxplayers; i++)
|
||||
{
|
||||
if ( CCgettxout(txid,i+1,1) < 0 )
|
||||
if ( CCgettxout(txid,i+1,1,0) < 0 )
|
||||
{
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
rogue_gameplayerinfo(cp,obj,txid,tx,i+1,maxplayers,myrogueaddr);
|
||||
@@ -1401,7 +1406,7 @@ UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
|
||||
{
|
||||
if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0) == 0 )
|
||||
{
|
||||
if ( CCgettxout(txid,vout,1) < 0 )
|
||||
if ( CCgettxout(txid,vout,1,0) < 0 )
|
||||
b.push_back(gametxid.GetHex());
|
||||
else a.push_back(gametxid.GetHex());
|
||||
}
|
||||
|
||||
@@ -2859,7 +2859,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params
|
||||
decode_hex((uint8_t *)&txid,32,txidstr);
|
||||
txid = revuint256(txid);
|
||||
result.push_back(Pair("txid",txid.GetHex()));
|
||||
if ( CCgettxout(txid,0,1) < 0 )
|
||||
if ( CCgettxout(txid,0,1,0) < 0 )
|
||||
result.push_back(Pair("error","already solved"));
|
||||
else if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user