mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +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
|
// Not in block yet, make sure all its inputs are still unspent
|
||||||
BOOST_FOREACH(const CTxIn& txin, txLockCandidate.txLockRequest.vin) {
|
BOOST_FOREACH(const CTxIn& txin, txLockCandidate.txLockRequest.vin) {
|
||||||
CCoins coins;
|
Coin coin;
|
||||||
if(!GetUTXOCoins(txin.prevout, coins)) {
|
if(!GetUTXOCoin(txin.prevout, coin)) {
|
||||||
// Not in UTXO anymore? A conflicting tx was mined while we were waiting for votes.
|
// 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());
|
LogPrintf("CInstantSend::ResolveConflicts -- ERROR: Failed to find UTXO %s, can't complete Transaction Lock\n", txin.prevout.ToStringShort());
|
||||||
return false;
|
return false;
|
||||||
@ -935,14 +935,14 @@ bool CTxLockRequest::IsValid() const
|
|||||||
|
|
||||||
BOOST_FOREACH(const CTxIn& txin, vin) {
|
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());
|
LogPrint("instantsend", "CTxLockRequest::IsValid -- Failed to find UTXO %s\n", txin.prevout.ToStringShort());
|
||||||
return false;
|
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
|
// 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;
|
int nConfirmationsRequired = INSTANTSEND_CONFIRMATIONS_REQUIRED - 1;
|
||||||
|
|
||||||
@ -952,7 +952,7 @@ bool CTxLockRequest::IsValid() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nValueIn += coins.vout[txin.prevout.n].nValue;
|
nValueIn += coin.out.nValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(nValueIn > sporkManager.GetSporkValue(SPORK_5_INSTANTSEND_MAX_VALUE)*COIN) {
|
if(nValueIn > sporkManager.GetSporkValue(SPORK_5_INSTANTSEND_MAX_VALUE)*COIN) {
|
||||||
@ -991,13 +991,13 @@ bool CTxLockVote::IsValid(CNode* pnode, CConnman& connman) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCoins coins;
|
Coin coin;
|
||||||
if(!GetUTXOCoins(outpoint, coins)) {
|
if(!GetUTXOCoin(outpoint, coin)) {
|
||||||
LogPrint("instantsend", "CTxLockVote::IsValid -- Failed to find UTXO %s\n", outpoint.ToStringShort());
|
LogPrint("instantsend", "CTxLockVote::IsValid -- Failed to find UTXO %s\n", outpoint.ToStringShort());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nLockInputHeight = coins.nHeight + 4;
|
int nLockInputHeight = coin.nHeight + 4;
|
||||||
|
|
||||||
int nRank;
|
int nRank;
|
||||||
if(!mnodeman.GetMasternodeRank(outpointMasternode, nRank, nLockInputHeight, MIN_INSTANTSEND_PROTO_VERSION)) {
|
if(!mnodeman.GetMasternodeRank(outpointMasternode, nRank, nLockInputHeight, MIN_INSTANTSEND_PROTO_VERSION)) {
|
||||||
|
@ -123,16 +123,16 @@ CMasternode::CollateralStatus CMasternode::CheckCollateral(const COutPoint& outp
|
|||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
|
|
||||||
CCoins coins;
|
Coin coin;
|
||||||
if(!GetUTXOCoins(outpoint, coins)) {
|
if(!GetUTXOCoin(outpoint, coin)) {
|
||||||
return COLLATERAL_UTXO_NOT_FOUND;
|
return COLLATERAL_UTXO_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(coins.vout[outpoint.n].nValue != 1000 * COIN) {
|
if(coin.out.nValue != 1000 * COIN) {
|
||||||
return COLLATERAL_INVALID_AMOUNT;
|
return COLLATERAL_INVALID_AMOUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
nHeightRet = coins.nHeight;
|
nHeightRet = coin.nHeight;
|
||||||
return COLLATERAL_OK;
|
return COLLATERAL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,9 +193,9 @@ void CPrivateSendServer::ProcessMessage(CNode* pfrom, std::string& strCommand, C
|
|||||||
|
|
||||||
LogPrint("privatesend", "DSVIN -- txin=%s\n", txin.ToString());
|
LogPrint("privatesend", "DSVIN -- txin=%s\n", txin.ToString());
|
||||||
|
|
||||||
CCoins coins;
|
Coin coin;
|
||||||
if(GetUTXOCoins(txin.prevout, coins)) {
|
if(GetUTXOCoin(txin.prevout, coin)) {
|
||||||
nValueIn += coins.vout[txin.prevout.n].nValue;
|
nValueIn += coin.out.nValue;
|
||||||
} else {
|
} else {
|
||||||
LogPrintf("DSVIN -- missing input! tx=%s", tx.ToString());
|
LogPrintf("DSVIN -- missing input! tx=%s", tx.ToString());
|
||||||
PushStatus(pfrom, STATUS_REJECTED, ERR_MISSING_TX, connman);
|
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) {
|
BOOST_FOREACH(const CTxIn txin, txCollateral.vin) {
|
||||||
CCoins coins;
|
Coin coin;
|
||||||
if(!GetUTXOCoins(txin.prevout, coins)) {
|
if(!GetUTXOCoin(txin.prevout, coin)) {
|
||||||
LogPrint("privatesend", "CPrivateSend::IsCollateralValid -- Unknown inputs in collateral transaction, txCollateral=%s", txCollateral.ToString());
|
LogPrint("privatesend", "CPrivateSend::IsCollateralValid -- Unknown inputs in collateral transaction, txCollateral=%s", txCollateral.ToString());
|
||||||
return false;
|
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
|
//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;
|
return nSigOps;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetUTXOCoins(const COutPoint& outpoint, CCoins& coins)
|
bool GetUTXOCoin(const COutPoint& outpoint, Coin& coin)
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
return !(!pcoinsTip->GetCoins(outpoint.hash, coins) ||
|
if (!pcoinsTip->GetCoin(outpoint, coin))
|
||||||
(unsigned int)outpoint.n>=coins.vout.size() ||
|
return false;
|
||||||
coins.vout[outpoint.n].IsNull());
|
if (coin.IsSpent())
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetUTXOHeight(const COutPoint& outpoint)
|
int GetUTXOHeight(const COutPoint& outpoint)
|
||||||
{
|
{
|
||||||
// -1 means UTXO is yet unknown or already spent
|
// -1 means UTXO is yet unknown or already spent
|
||||||
CCoins coins;
|
Coin coin;
|
||||||
return GetUTXOCoins(outpoint, coins) ? coins.nHeight : -1;
|
return GetUTXOCoin(outpoint, coin) ? coin.nHeight : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetUTXOConfirmations(const COutPoint& outpoint)
|
int GetUTXOConfirmations(const COutPoint& outpoint)
|
||||||
|
@ -300,7 +300,7 @@ void PruneAndFlush();
|
|||||||
bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,
|
bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,
|
||||||
bool* pfMissingInputs, bool fOverrideMempoolLimit=false, bool fRejectAbsurdFee=false, bool fDryRun=false);
|
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 GetUTXOHeight(const COutPoint& outpoint);
|
||||||
int GetUTXOConfirmations(const COutPoint& outpoint);
|
int GetUTXOConfirmations(const COutPoint& outpoint);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user