From d4df6f6db4ba88b9c63bbe51cef36e7fb858f9ff Mon Sep 17 00:00:00 2001 From: fdov Date: Sun, 19 Dec 2021 19:01:38 +0100 Subject: [PATCH] Adjustments for Ravencoin --- src/rpc/assets.cpp | 4 ++-- src/rpc/rawtransaction.cpp | 8 ++++---- src/txmempool.cpp | 2 +- src/validation.cpp | 1 - 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/rpc/assets.cpp b/src/rpc/assets.cpp index 3e025af8ef..6b81a2c4dd 100644 --- a/src/rpc/assets.cpp +++ b/src/rpc/assets.cpp @@ -39,7 +39,7 @@ void CheckRestrictedAssetTransferInputs(const CWalletTx& transaction, const std::string& asset_name) { // Do a validity check before commiting the transaction if (IsAssetNameAnRestricted(asset_name)) { - if (pcoinsTip && passets) { + if (pcoinsTip.get() && passets) { for (auto input : transaction.tx->vin) { const COutPoint &prevout = input.prevout; const Coin &coin = pcoinsTip->AccessCoin(prevout); @@ -1802,7 +1802,7 @@ UniValue getcacheinfo(const JSONRPCRequest& request) if (!currentActiveAssetCache) throw JSONRPCError(RPC_VERIFY_ERROR, "asset cache is null"); - if (!pcoinsTip) + if (!pcoinsTip.get()) throw JSONRPCError(RPC_VERIFY_ERROR, "coins tip cache is null"); if (!passetsCache) diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index e0d672a22d..24d51bd26a 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -271,7 +271,7 @@ UniValue gettxoutproof(const JSONRPCRequest& request) } else { // Loop through txids and try to find which block they're in. Exit loop once a block is found. for (const auto& tx : setTxids) { - const Coin& coin = AccessByTxid(*pcoinsTip, tx); + const Coin& coin = AccessByTxid(pcoinsTip.get(), tx); if (!coin.IsSpent()) { pblockindex = chainActive[coin.nHeight]; break; @@ -1753,7 +1753,7 @@ UniValue combinerawtransaction(const JSONRPCRequest& request) { LOCK(cs_main); LOCK(mempool.cs); - CCoinsViewCache &viewChain = *pcoinsTip; + CCoinsViewCache viewChain(pcoinsTip.get()); CCoinsViewMemPool viewMempool(&viewChain, mempool); view.SetBackend(viewMempool); // temporarily switch cache backend to db+mempool view @@ -1874,7 +1874,7 @@ UniValue signrawtransaction(const JSONRPCRequest& request) CCoinsViewCache view(&viewDummy); { LOCK(mempool.cs); - CCoinsViewCache &viewChain = *pcoinsTip; + CCoinsViewCache viewChain(pcoinsTip.get()); CCoinsViewMemPool viewMempool(&viewChain, mempool); view.SetBackend(viewMempool); // temporarily switch cache backend to db+mempool view @@ -2083,7 +2083,7 @@ UniValue sendrawtransaction(const JSONRPCRequest& request) if (!request.params[1].isNull() && request.params[1].get_bool()) nMaxRawTxFee = 0; - CCoinsViewCache &view = *pcoinsTip; + CCoinsViewCache view(pcoinsTip.get()); bool fHaveChain = false; for (size_t o = 0; !fHaveChain && o < tx->vout.size(); o++) { const Coin& existingCoin = view.AccessCoin(COutPoint(hashTx, o)); diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 87754c0ffd..c2e1009d6c 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -984,7 +984,7 @@ void CTxMemPool::removeForBlock(const std::vector& vtx, unsigne if (i != mapTx.end()) { CValidationState state; std::vector> vReissueAssets; - if (!setAlreadyRemoving.count(hash) && !Consensus::CheckTxAssets(i->GetTx(), state, pcoinsTip, passets, false, vReissueAssets)) { + if (!setAlreadyRemoving.count(hash) && !Consensus::CheckTxAssets(i->GetTx(), state, pcoinsTip.get(), passets, false, vReissueAssets)) { entries.push_back(&*i); trans.emplace_back(i->GetTx()); setAlreadyRemoving.insert(hash); diff --git a/src/validation.cpp b/src/validation.cpp index 2844c6d421..c2e18e9ce2 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3316,7 +3316,6 @@ bool static ConnectTip(CValidationState& state, const CChainParams& chainparams, /** RVN END */ { - CCoinsViewCache view(pcoinsTip); /** RVN START */ // Create the empty asset cache, that will be sent into the connect block // All new data will be added to the cache, and will be flushed back into passets after a successful