mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
Dash related fixes for per-utxo DB
This commit is contained in:
parent
92bb65894b
commit
9ad56fe18a
@ -598,8 +598,8 @@ bool CInstantSend::ResolveConflicts(const CTxLockCandidate& txLockCandidate)
|
||||
}
|
||||
// Not in block yet, make sure all its inputs are still unspent
|
||||
BOOST_FOREACH(const CTxIn& txin, txLockCandidate.txLockRequest.vin) {
|
||||
CCoins coins;
|
||||
if(!GetUTXOCoins(txin.prevout, coins)) {
|
||||
Coin coin;
|
||||
if(!GetUTXOCoin(txin.prevout, coin)) {
|
||||
// Not in UTXO anymore? A conflicting tx was mined while we were waiting for votes.
|
||||
LogPrintf("CInstantSend::ResolveConflicts -- ERROR: Failed to find UTXO %s, can't complete Transaction Lock\n", txin.prevout.ToStringShort());
|
||||
return false;
|
||||
@ -935,14 +935,14 @@ bool CTxLockRequest::IsValid() const
|
||||
|
||||
BOOST_FOREACH(const CTxIn& txin, vin) {
|
||||
|
||||
CCoins coins;
|
||||
Coin coin;
|
||||
|
||||
if(!GetUTXOCoins(txin.prevout, coins)) {
|
||||
if(!GetUTXOCoin(txin.prevout, coin)) {
|
||||
LogPrint("instantsend", "CTxLockRequest::IsValid -- Failed to find UTXO %s\n", txin.prevout.ToStringShort());
|
||||
return false;
|
||||
}
|
||||
|
||||
int nTxAge = chainActive.Height() - coins.nHeight + 1;
|
||||
int nTxAge = chainActive.Height() - coin.nHeight + 1;
|
||||
// 1 less than the "send IX" gui requires, in case of a block propagating the network at the time
|
||||
int nConfirmationsRequired = INSTANTSEND_CONFIRMATIONS_REQUIRED - 1;
|
||||
|
||||
@ -952,7 +952,7 @@ bool CTxLockRequest::IsValid() const
|
||||
return false;
|
||||
}
|
||||
|
||||
nValueIn += coins.vout[txin.prevout.n].nValue;
|
||||
nValueIn += coin.out.nValue;
|
||||
}
|
||||
|
||||
if(nValueIn > sporkManager.GetSporkValue(SPORK_5_INSTANTSEND_MAX_VALUE)*COIN) {
|
||||
@ -991,13 +991,13 @@ bool CTxLockVote::IsValid(CNode* pnode, CConnman& connman) const
|
||||
return false;
|
||||
}
|
||||
|
||||
CCoins coins;
|
||||
if(!GetUTXOCoins(outpoint, coins)) {
|
||||
Coin coin;
|
||||
if(!GetUTXOCoin(outpoint, coin)) {
|
||||
LogPrint("instantsend", "CTxLockVote::IsValid -- Failed to find UTXO %s\n", outpoint.ToStringShort());
|
||||
return false;
|
||||
}
|
||||
|
||||
int nLockInputHeight = coins.nHeight + 4;
|
||||
int nLockInputHeight = coin.nHeight + 4;
|
||||
|
||||
int nRank;
|
||||
if(!mnodeman.GetMasternodeRank(outpointMasternode, nRank, nLockInputHeight, MIN_INSTANTSEND_PROTO_VERSION)) {
|
||||
|
@ -123,16 +123,16 @@ CMasternode::CollateralStatus CMasternode::CheckCollateral(const COutPoint& outp
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
|
||||
CCoins coins;
|
||||
if(!GetUTXOCoins(outpoint, coins)) {
|
||||
Coin coin;
|
||||
if(!GetUTXOCoin(outpoint, coin)) {
|
||||
return COLLATERAL_UTXO_NOT_FOUND;
|
||||
}
|
||||
|
||||
if(coins.vout[outpoint.n].nValue != 1000 * COIN) {
|
||||
if(coin.out.nValue != 1000 * COIN) {
|
||||
return COLLATERAL_INVALID_AMOUNT;
|
||||
}
|
||||
|
||||
nHeightRet = coins.nHeight;
|
||||
nHeightRet = coin.nHeight;
|
||||
return COLLATERAL_OK;
|
||||
}
|
||||
|
||||
|
@ -193,9 +193,9 @@ void CPrivateSendServer::ProcessMessage(CNode* pfrom, std::string& strCommand, C
|
||||
|
||||
LogPrint("privatesend", "DSVIN -- txin=%s\n", txin.ToString());
|
||||
|
||||
CCoins coins;
|
||||
if(GetUTXOCoins(txin.prevout, coins)) {
|
||||
nValueIn += coins.vout[txin.prevout.n].nValue;
|
||||
Coin coin;
|
||||
if(GetUTXOCoin(txin.prevout, coin)) {
|
||||
nValueIn += coin.out.nValue;
|
||||
} else {
|
||||
LogPrintf("DSVIN -- missing input! tx=%s", tx.ToString());
|
||||
PushStatus(pfrom, STATUS_REJECTED, ERR_MISSING_TX, connman);
|
||||
|
@ -189,12 +189,12 @@ bool CPrivateSend::IsCollateralValid(const CTransaction& txCollateral)
|
||||
}
|
||||
|
||||
BOOST_FOREACH(const CTxIn txin, txCollateral.vin) {
|
||||
CCoins coins;
|
||||
if(!GetUTXOCoins(txin.prevout, coins)) {
|
||||
Coin coin;
|
||||
if(!GetUTXOCoin(txin.prevout, coin)) {
|
||||
LogPrint("privatesend", "CPrivateSend::IsCollateralValid -- Unknown inputs in collateral transaction, txCollateral=%s", txCollateral.ToString());
|
||||
return false;
|
||||
}
|
||||
nValueIn += coins.vout[txin.prevout.n].nValue;
|
||||
nValueIn += coin.out.nValue;
|
||||
}
|
||||
|
||||
//collateral transactions are required to pay out a small fee to the miners
|
||||
|
@ -443,19 +443,21 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& in
|
||||
return nSigOps;
|
||||
}
|
||||
|
||||
bool GetUTXOCoins(const COutPoint& outpoint, CCoins& coins)
|
||||
bool GetUTXOCoin(const COutPoint& outpoint, Coin& coin)
|
||||
{
|
||||
LOCK(cs_main);
|
||||
return !(!pcoinsTip->GetCoins(outpoint.hash, coins) ||
|
||||
(unsigned int)outpoint.n>=coins.vout.size() ||
|
||||
coins.vout[outpoint.n].IsNull());
|
||||
if (!pcoinsTip->GetCoin(outpoint, coin))
|
||||
return false;
|
||||
if (coin.IsSpent())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
int GetUTXOHeight(const COutPoint& outpoint)
|
||||
{
|
||||
// -1 means UTXO is yet unknown or already spent
|
||||
CCoins coins;
|
||||
return GetUTXOCoins(outpoint, coins) ? coins.nHeight : -1;
|
||||
Coin coin;
|
||||
return GetUTXOCoin(outpoint, coin) ? coin.nHeight : -1;
|
||||
}
|
||||
|
||||
int GetUTXOConfirmations(const COutPoint& outpoint)
|
||||
|
@ -300,7 +300,7 @@ void PruneAndFlush();
|
||||
bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,
|
||||
bool* pfMissingInputs, bool fOverrideMempoolLimit=false, bool fRejectAbsurdFee=false, bool fDryRun=false);
|
||||
|
||||
bool GetUTXOCoins(const COutPoint& outpoint, CCoins& coins);
|
||||
bool GetUTXOCoin(const COutPoint& outpoint, Coin& coin);
|
||||
int GetUTXOHeight(const COutPoint& outpoint);
|
||||
int GetUTXOConfirmations(const COutPoint& outpoint);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user