mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-02-02 10:14:31 +00:00
Merge #10178: Remove CValidationInterface::UpdatedTransaction
9fececb Remove CValidationInterface::UpdatedTransaction (Matt Corallo) d89f8ad Make DisconnectBlock and ConnectBlock static in validation.cpp (Matt Corallo) Tree-SHA512: 146597b538c09c1e8071f4f88ffeba0645c6816f86030b142174bd298cc18ae09a400e6ca8de04d091e37b635f99f4c05982c09e6729691eb8ca6b8439ab97ca
This commit is contained in:
commit
2584925077
@ -1524,7 +1524,11 @@ bool ApplyTxInUndo(const CTxInUndo& undo, CCoinsViewCache& view, const COutPoint
|
|||||||
return fClean;
|
return fClean;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DisconnectBlock(const CBlock& block, CValidationState& state, const CBlockIndex* pindex, CCoinsViewCache& view, bool* pfClean)
|
/** Undo the effects of this block (with given index) on the UTXO set represented by coins.
|
||||||
|
* In case pfClean is provided, operation will try to be tolerant about errors, and *pfClean
|
||||||
|
* will be true if no problems were found. Otherwise, the return value will be false in case
|
||||||
|
* of problems. Note that in any case, coins may be modified. */
|
||||||
|
static bool DisconnectBlock(const CBlock& block, CValidationState& state, const CBlockIndex* pindex, CCoinsViewCache& view, bool* pfClean = NULL)
|
||||||
{
|
{
|
||||||
assert(pindex->GetBlockHash() == view.GetBestBlock());
|
assert(pindex->GetBlockHash() == view.GetBestBlock());
|
||||||
|
|
||||||
@ -1677,8 +1681,11 @@ static int64_t nTimeIndex = 0;
|
|||||||
static int64_t nTimeCallbacks = 0;
|
static int64_t nTimeCallbacks = 0;
|
||||||
static int64_t nTimeTotal = 0;
|
static int64_t nTimeTotal = 0;
|
||||||
|
|
||||||
bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex,
|
/** Apply the effects of this block (with given index) on the UTXO set represented by coins.
|
||||||
CCoinsViewCache& view, const CChainParams& chainparams, bool fJustCheck)
|
* Validity checks that depend on the UTXO set are also done; ConnectBlock()
|
||||||
|
* can fail if those validity checks fail (among other reasons). */
|
||||||
|
static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex,
|
||||||
|
CCoinsViewCache& view, const CChainParams& chainparams, bool fJustCheck = false)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
assert(pindex);
|
assert(pindex);
|
||||||
@ -1917,12 +1924,6 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||||||
int64_t nTime5 = GetTimeMicros(); nTimeIndex += nTime5 - nTime4;
|
int64_t nTime5 = GetTimeMicros(); nTimeIndex += nTime5 - nTime4;
|
||||||
LogPrint(BCLog::BENCH, " - Index writing: %.2fms [%.2fs]\n", 0.001 * (nTime5 - nTime4), nTimeIndex * 0.000001);
|
LogPrint(BCLog::BENCH, " - Index writing: %.2fms [%.2fs]\n", 0.001 * (nTime5 - nTime4), nTimeIndex * 0.000001);
|
||||||
|
|
||||||
// Watch for changes to the previous coinbase transaction.
|
|
||||||
static uint256 hashPrevBestCoinBase;
|
|
||||||
GetMainSignals().UpdatedTransaction(hashPrevBestCoinBase);
|
|
||||||
hashPrevBestCoinBase = block.vtx[0]->GetHash();
|
|
||||||
|
|
||||||
|
|
||||||
int64_t nTime6 = GetTimeMicros(); nTimeCallbacks += nTime6 - nTime5;
|
int64_t nTime6 = GetTimeMicros(); nTimeCallbacks += nTime6 - nTime5;
|
||||||
LogPrint(BCLog::BENCH, " - Callbacks: %.2fms [%.2fs]\n", 0.001 * (nTime6 - nTime5), nTimeCallbacks * 0.000001);
|
LogPrint(BCLog::BENCH, " - Callbacks: %.2fms [%.2fs]\n", 0.001 * (nTime6 - nTime5), nTimeCallbacks * 0.000001);
|
||||||
|
|
||||||
|
@ -483,18 +483,6 @@ bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::P
|
|||||||
bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& state, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev, int64_t nAdjustedTime);
|
bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& state, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev, int64_t nAdjustedTime);
|
||||||
bool ContextualCheckBlock(const CBlock& block, CValidationState& state, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev);
|
bool ContextualCheckBlock(const CBlock& block, CValidationState& state, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev);
|
||||||
|
|
||||||
/** Apply the effects of this block (with given index) on the UTXO set represented by coins.
|
|
||||||
* Validity checks that depend on the UTXO set are also done; ConnectBlock()
|
|
||||||
* can fail if those validity checks fail (among other reasons). */
|
|
||||||
bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& coins,
|
|
||||||
const CChainParams& chainparams, bool fJustCheck = false);
|
|
||||||
|
|
||||||
/** Undo the effects of this block (with given index) on the UTXO set represented by coins.
|
|
||||||
* In case pfClean is provided, operation will try to be tolerant about errors, and *pfClean
|
|
||||||
* will be true if no problems were found. Otherwise, the return value will be false in case
|
|
||||||
* of problems. Note that in any case, coins may be modified. */
|
|
||||||
bool DisconnectBlock(const CBlock& block, CValidationState& state, const CBlockIndex* pindex, CCoinsViewCache& coins, bool* pfClean = NULL);
|
|
||||||
|
|
||||||
/** Check a block is completely valid from start to finish (only works on top of our current best block, with cs_main held) */
|
/** Check a block is completely valid from start to finish (only works on top of our current best block, with cs_main held) */
|
||||||
bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams, const CBlock& block, CBlockIndex* pindexPrev, bool fCheckPOW = true, bool fCheckMerkleRoot = true);
|
bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams, const CBlock& block, CBlockIndex* pindexPrev, bool fCheckPOW = true, bool fCheckMerkleRoot = true);
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ void RegisterValidationInterface(CValidationInterface* pwalletIn) {
|
|||||||
g_signals.TransactionAddedToMempool.connect(boost::bind(&CValidationInterface::TransactionAddedToMempool, pwalletIn, _1));
|
g_signals.TransactionAddedToMempool.connect(boost::bind(&CValidationInterface::TransactionAddedToMempool, pwalletIn, _1));
|
||||||
g_signals.BlockConnected.connect(boost::bind(&CValidationInterface::BlockConnected, pwalletIn, _1, _2, _3));
|
g_signals.BlockConnected.connect(boost::bind(&CValidationInterface::BlockConnected, pwalletIn, _1, _2, _3));
|
||||||
g_signals.BlockDisconnected.connect(boost::bind(&CValidationInterface::BlockDisconnected, pwalletIn, _1));
|
g_signals.BlockDisconnected.connect(boost::bind(&CValidationInterface::BlockDisconnected, pwalletIn, _1));
|
||||||
g_signals.UpdatedTransaction.connect(boost::bind(&CValidationInterface::UpdatedTransaction, pwalletIn, _1));
|
|
||||||
g_signals.SetBestChain.connect(boost::bind(&CValidationInterface::SetBestChain, pwalletIn, _1));
|
g_signals.SetBestChain.connect(boost::bind(&CValidationInterface::SetBestChain, pwalletIn, _1));
|
||||||
g_signals.Inventory.connect(boost::bind(&CValidationInterface::Inventory, pwalletIn, _1));
|
g_signals.Inventory.connect(boost::bind(&CValidationInterface::Inventory, pwalletIn, _1));
|
||||||
g_signals.Broadcast.connect(boost::bind(&CValidationInterface::ResendWalletTransactions, pwalletIn, _1, _2));
|
g_signals.Broadcast.connect(boost::bind(&CValidationInterface::ResendWalletTransactions, pwalletIn, _1, _2));
|
||||||
@ -32,7 +31,6 @@ void UnregisterValidationInterface(CValidationInterface* pwalletIn) {
|
|||||||
g_signals.Broadcast.disconnect(boost::bind(&CValidationInterface::ResendWalletTransactions, pwalletIn, _1, _2));
|
g_signals.Broadcast.disconnect(boost::bind(&CValidationInterface::ResendWalletTransactions, pwalletIn, _1, _2));
|
||||||
g_signals.Inventory.disconnect(boost::bind(&CValidationInterface::Inventory, pwalletIn, _1));
|
g_signals.Inventory.disconnect(boost::bind(&CValidationInterface::Inventory, pwalletIn, _1));
|
||||||
g_signals.SetBestChain.disconnect(boost::bind(&CValidationInterface::SetBestChain, pwalletIn, _1));
|
g_signals.SetBestChain.disconnect(boost::bind(&CValidationInterface::SetBestChain, pwalletIn, _1));
|
||||||
g_signals.UpdatedTransaction.disconnect(boost::bind(&CValidationInterface::UpdatedTransaction, pwalletIn, _1));
|
|
||||||
g_signals.TransactionAddedToMempool.disconnect(boost::bind(&CValidationInterface::TransactionAddedToMempool, pwalletIn, _1));
|
g_signals.TransactionAddedToMempool.disconnect(boost::bind(&CValidationInterface::TransactionAddedToMempool, pwalletIn, _1));
|
||||||
g_signals.BlockConnected.disconnect(boost::bind(&CValidationInterface::BlockConnected, pwalletIn, _1, _2, _3));
|
g_signals.BlockConnected.disconnect(boost::bind(&CValidationInterface::BlockConnected, pwalletIn, _1, _2, _3));
|
||||||
g_signals.BlockDisconnected.disconnect(boost::bind(&CValidationInterface::BlockDisconnected, pwalletIn, _1));
|
g_signals.BlockDisconnected.disconnect(boost::bind(&CValidationInterface::BlockDisconnected, pwalletIn, _1));
|
||||||
@ -46,7 +44,6 @@ void UnregisterAllValidationInterfaces() {
|
|||||||
g_signals.Broadcast.disconnect_all_slots();
|
g_signals.Broadcast.disconnect_all_slots();
|
||||||
g_signals.Inventory.disconnect_all_slots();
|
g_signals.Inventory.disconnect_all_slots();
|
||||||
g_signals.SetBestChain.disconnect_all_slots();
|
g_signals.SetBestChain.disconnect_all_slots();
|
||||||
g_signals.UpdatedTransaction.disconnect_all_slots();
|
|
||||||
g_signals.TransactionAddedToMempool.disconnect_all_slots();
|
g_signals.TransactionAddedToMempool.disconnect_all_slots();
|
||||||
g_signals.BlockConnected.disconnect_all_slots();
|
g_signals.BlockConnected.disconnect_all_slots();
|
||||||
g_signals.BlockDisconnected.disconnect_all_slots();
|
g_signals.BlockDisconnected.disconnect_all_slots();
|
||||||
|
@ -37,7 +37,6 @@ protected:
|
|||||||
virtual void BlockConnected(const std::shared_ptr<const CBlock> &block, const CBlockIndex *pindex, const std::vector<CTransactionRef> &txnConflicted) {}
|
virtual void BlockConnected(const std::shared_ptr<const CBlock> &block, const CBlockIndex *pindex, const std::vector<CTransactionRef> &txnConflicted) {}
|
||||||
virtual void BlockDisconnected(const std::shared_ptr<const CBlock> &block) {}
|
virtual void BlockDisconnected(const std::shared_ptr<const CBlock> &block) {}
|
||||||
virtual void SetBestChain(const CBlockLocator &locator) {}
|
virtual void SetBestChain(const CBlockLocator &locator) {}
|
||||||
virtual void UpdatedTransaction(const uint256 &hash) {}
|
|
||||||
virtual void Inventory(const uint256 &hash) {}
|
virtual void Inventory(const uint256 &hash) {}
|
||||||
virtual void ResendWalletTransactions(int64_t nBestBlockTime, CConnman* connman) {}
|
virtual void ResendWalletTransactions(int64_t nBestBlockTime, CConnman* connman) {}
|
||||||
virtual void BlockChecked(const CBlock&, const CValidationState&) {}
|
virtual void BlockChecked(const CBlock&, const CValidationState&) {}
|
||||||
@ -60,8 +59,6 @@ struct CMainSignals {
|
|||||||
boost::signals2::signal<void (const std::shared_ptr<const CBlock> &, const CBlockIndex *pindex, const std::vector<CTransactionRef> &)> BlockConnected;
|
boost::signals2::signal<void (const std::shared_ptr<const CBlock> &, const CBlockIndex *pindex, const std::vector<CTransactionRef> &)> BlockConnected;
|
||||||
/** Notifies listeners of a block being disconnected */
|
/** Notifies listeners of a block being disconnected */
|
||||||
boost::signals2::signal<void (const std::shared_ptr<const CBlock> &)> BlockDisconnected;
|
boost::signals2::signal<void (const std::shared_ptr<const CBlock> &)> BlockDisconnected;
|
||||||
/** Notifies listeners of an updated transaction without new data (for now: a coinbase potentially becoming visible). */
|
|
||||||
boost::signals2::signal<void (const uint256 &)> UpdatedTransaction;
|
|
||||||
/** Notifies listeners of a new active block chain. */
|
/** Notifies listeners of a new active block chain. */
|
||||||
boost::signals2::signal<void (const CBlockLocator &)> SetBestChain;
|
boost::signals2::signal<void (const CBlockLocator &)> SetBestChain;
|
||||||
/** Notifies listeners about an inventory item being seen on the network. */
|
/** Notifies listeners about an inventory item being seen on the network. */
|
||||||
|
@ -1155,6 +1155,33 @@ void CWallet::BlockConnected(const std::shared_ptr<const CBlock>& pblock, const
|
|||||||
for (size_t i = 0; i < pblock->vtx.size(); i++) {
|
for (size_t i = 0; i < pblock->vtx.size(); i++) {
|
||||||
SyncTransaction(pblock->vtx[i], pindex, i);
|
SyncTransaction(pblock->vtx[i], pindex, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The GUI expects a NotifyTransactionChanged when a coinbase tx
|
||||||
|
// which is in our wallet moves from in-the-best-block to
|
||||||
|
// 2-confirmations (as it only displays them at that time).
|
||||||
|
// We do that here.
|
||||||
|
if (hashPrevBestCoinbase.IsNull()) {
|
||||||
|
// Immediately after restart we have no idea what the coinbase
|
||||||
|
// transaction from the previous block is.
|
||||||
|
// For correctness we scan over the entire wallet, looking for
|
||||||
|
// the previous block's coinbase, just in case it is ours, so
|
||||||
|
// that we can notify the UI that it should now be displayed.
|
||||||
|
if (pindex->pprev) {
|
||||||
|
for (const std::pair<uint256, CWalletTx>& p : mapWallet) {
|
||||||
|
if (p.second.IsCoinBase() && p.second.hashBlock == pindex->pprev->GetBlockHash()) {
|
||||||
|
NotifyTransactionChanged(this, p.first, CT_UPDATED);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::map<uint256, CWalletTx>::const_iterator mi = mapWallet.find(hashPrevBestCoinbase);
|
||||||
|
if (mi != mapWallet.end()) {
|
||||||
|
NotifyTransactionChanged(this, hashPrevBestCoinbase, CT_UPDATED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hashPrevBestCoinbase = pblock->vtx[0]->GetHash();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWallet::BlockDisconnected(const std::shared_ptr<const CBlock>& pblock) {
|
void CWallet::BlockDisconnected(const std::shared_ptr<const CBlock>& pblock) {
|
||||||
@ -3383,17 +3410,6 @@ void CWallet::GetAllReserveKeys(std::set<CKeyID>& setAddress) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWallet::UpdatedTransaction(const uint256 &hashTx)
|
|
||||||
{
|
|
||||||
{
|
|
||||||
LOCK(cs_wallet);
|
|
||||||
// Only notify UI if this transaction is in this wallet
|
|
||||||
std::map<uint256, CWalletTx>::const_iterator mi = mapWallet.find(hashTx);
|
|
||||||
if (mi != mapWallet.end())
|
|
||||||
NotifyTransactionChanged(this, hashTx, CT_UPDATED);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CWallet::GetScriptForMining(std::shared_ptr<CReserveScript> &script)
|
void CWallet::GetScriptForMining(std::shared_ptr<CReserveScript> &script)
|
||||||
{
|
{
|
||||||
std::shared_ptr<CReserveKey> rKey = std::make_shared<CReserveKey>(this);
|
std::shared_ptr<CReserveKey> rKey = std::make_shared<CReserveKey>(this);
|
||||||
|
@ -713,6 +713,10 @@ private:
|
|||||||
*/
|
*/
|
||||||
bool AddWatchOnly(const CScript& dest) override;
|
bool AddWatchOnly(const CScript& dest) override;
|
||||||
|
|
||||||
|
// Used to NotifyTransactionChanged of the previous block's coinbase when
|
||||||
|
// the next block comes in
|
||||||
|
uint256 hashPrevBestCoinbase;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*
|
/*
|
||||||
* Main wallet lock.
|
* Main wallet lock.
|
||||||
@ -978,8 +982,6 @@ public:
|
|||||||
|
|
||||||
bool DelAddressBook(const CTxDestination& address);
|
bool DelAddressBook(const CTxDestination& address);
|
||||||
|
|
||||||
void UpdatedTransaction(const uint256 &hashTx) override;
|
|
||||||
|
|
||||||
void Inventory(const uint256 &hash) override
|
void Inventory(const uint256 &hash) override
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user