Filter out invalid games

This commit is contained in:
jl777
2019-02-12 10:20:24 -11:00
parent b86fa74a48
commit f41d60a399

View File

@@ -1052,7 +1052,7 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
{ {
UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); uint256 txid,hashBlock,gametxid,tokenid,playertxid; int32_t vout,numvouts; CPubKey roguepk,mypk; char coinaddr[64]; CTransaction tx; UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); uint256 txid,hashBlock,gametxid,tokenid,playertxid; int32_t vout,maxplayers,gameheight,numvouts; CPubKey roguepk,mypk; char coinaddr[64]; CTransaction tx,gametx; int64_t buyin;
std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex; std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex;
//std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs; //std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs;
roguepk = GetUnspendable(cp,0); roguepk = GetUnspendable(cp,0);
@@ -1072,6 +1072,8 @@ UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 )
{ {
if ( rogue_registeropretdecode(gametxid,tokenid,playertxid,tx.vout[numvouts-1].scriptPubKey) == 'R' ) if ( rogue_registeropretdecode(gametxid,tokenid,playertxid,tx.vout[numvouts-1].scriptPubKey) == 'R' )
{
if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 )
{ {
if ( CCgettxout(txid,vout,1) < 0 ) if ( CCgettxout(txid,vout,1) < 0 )
b.push_back(gametxid.GetHex()); b.push_back(gametxid.GetHex());
@@ -1080,6 +1082,7 @@ UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
} }
} }
} }
}
result.push_back(Pair("pastgames",b)); result.push_back(Pair("pastgames",b));
result.push_back(Pair("games",a)); result.push_back(Pair("games",a));
result.push_back(Pair("numgames",a.size()+b.size())); result.push_back(Pair("numgames",a.size()+b.size()));