refactor: Rename Chain::Notifications methods to be consistent with other interfaces methods

This also simplifies #10102 removing overrides needed to deal with inconsistent
case convention
This commit is contained in:
Russell Yanofsky
2020-02-26 16:05:49 -05:00
parent 1c2ab1a6d2
commit 6ceb21909c
4 changed files with 29 additions and 29 deletions

View File

@@ -166,25 +166,25 @@ public:
} }
void TransactionAddedToMempool(const CTransactionRef& tx) override void TransactionAddedToMempool(const CTransactionRef& tx) override
{ {
m_notifications->TransactionAddedToMempool(tx); m_notifications->transactionAddedToMempool(tx);
} }
void TransactionRemovedFromMempool(const CTransactionRef& tx) override void TransactionRemovedFromMempool(const CTransactionRef& tx) override
{ {
m_notifications->TransactionRemovedFromMempool(tx); m_notifications->transactionRemovedFromMempool(tx);
} }
void BlockConnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* index) override void BlockConnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* index) override
{ {
m_notifications->BlockConnected(*block, index->nHeight); m_notifications->blockConnected(*block, index->nHeight);
} }
void BlockDisconnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* index) override void BlockDisconnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* index) override
{ {
m_notifications->BlockDisconnected(*block, index->nHeight); m_notifications->blockDisconnected(*block, index->nHeight);
} }
void UpdatedBlockTip(const CBlockIndex* index, const CBlockIndex* fork_index, bool is_ibd) override void UpdatedBlockTip(const CBlockIndex* index, const CBlockIndex* fork_index, bool is_ibd) override
{ {
m_notifications->UpdatedBlockTip(); m_notifications->updatedBlockTip();
} }
void ChainStateFlushed(const CBlockLocator& locator) override { m_notifications->ChainStateFlushed(locator); } void ChainStateFlushed(const CBlockLocator& locator) override { m_notifications->chainStateFlushed(locator); }
Chain& m_chain; Chain& m_chain;
Chain::Notifications* m_notifications; Chain::Notifications* m_notifications;
}; };
@@ -366,7 +366,7 @@ public:
{ {
LOCK2(::cs_main, ::mempool.cs); LOCK2(::cs_main, ::mempool.cs);
for (const CTxMemPoolEntry& entry : ::mempool.mapTx) { for (const CTxMemPoolEntry& entry : ::mempool.mapTx) {
notifications.TransactionAddedToMempool(entry.GetSharedTx()); notifications.transactionAddedToMempool(entry.GetSharedTx());
} }
} }
NodeContext& m_node; NodeContext& m_node;

View File

@@ -217,12 +217,12 @@ public:
{ {
public: public:
virtual ~Notifications() {} virtual ~Notifications() {}
virtual void TransactionAddedToMempool(const CTransactionRef& tx) {} virtual void transactionAddedToMempool(const CTransactionRef& tx) {}
virtual void TransactionRemovedFromMempool(const CTransactionRef& ptx) {} virtual void transactionRemovedFromMempool(const CTransactionRef& ptx) {}
virtual void BlockConnected(const CBlock& block, int height) {} virtual void blockConnected(const CBlock& block, int height) {}
virtual void BlockDisconnected(const CBlock& block, int height) {} virtual void blockDisconnected(const CBlock& block, int height) {}
virtual void UpdatedBlockTip() {} virtual void updatedBlockTip() {}
virtual void ChainStateFlushed(const CBlockLocator& locator) {} virtual void chainStateFlushed(const CBlockLocator& locator) {}
}; };
//! Register handler for notifications. //! Register handler for notifications.
@@ -245,7 +245,7 @@ public:
//! Current RPC serialization flags. //! Current RPC serialization flags.
virtual int rpcSerializationFlags() = 0; virtual int rpcSerializationFlags() = 0;
//! Synchronously send TransactionAddedToMempool notifications about all //! Synchronously send transactionAddedToMempool notifications about all
//! current mempool transactions to the specified handler and return after //! current mempool transactions to the specified handler and return after
//! the last one is sent. These notifications aren't coordinated with async //! the last one is sent. These notifications aren't coordinated with async
//! notifications sent by handleNotifications, so out of date async //! notifications sent by handleNotifications, so out of date async

View File

@@ -344,7 +344,7 @@ bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase,
return false; return false;
} }
void CWallet::ChainStateFlushed(const CBlockLocator& loc) void CWallet::chainStateFlushed(const CBlockLocator& loc)
{ {
WalletBatch batch(*database); WalletBatch batch(*database);
batch.WriteBestBlock(loc); batch.WriteBestBlock(loc);
@@ -1089,7 +1089,7 @@ void CWallet::SyncTransaction(const CTransactionRef& ptx, CWalletTx::Confirmatio
MarkInputsDirty(ptx); MarkInputsDirty(ptx);
} }
void CWallet::TransactionAddedToMempool(const CTransactionRef& ptx) { void CWallet::transactionAddedToMempool(const CTransactionRef& ptx) {
auto locked_chain = chain().lock(); auto locked_chain = chain().lock();
LOCK(cs_wallet); LOCK(cs_wallet);
CWalletTx::Confirmation confirm(CWalletTx::Status::UNCONFIRMED, /* block_height */ 0, {}, /* nIndex */ 0); CWalletTx::Confirmation confirm(CWalletTx::Status::UNCONFIRMED, /* block_height */ 0, {}, /* nIndex */ 0);
@@ -1101,7 +1101,7 @@ void CWallet::TransactionAddedToMempool(const CTransactionRef& ptx) {
} }
} }
void CWallet::TransactionRemovedFromMempool(const CTransactionRef &ptx) { void CWallet::transactionRemovedFromMempool(const CTransactionRef &ptx) {
LOCK(cs_wallet); LOCK(cs_wallet);
auto it = mapWallet.find(ptx->GetHash()); auto it = mapWallet.find(ptx->GetHash());
if (it != mapWallet.end()) { if (it != mapWallet.end()) {
@@ -1109,7 +1109,7 @@ void CWallet::TransactionRemovedFromMempool(const CTransactionRef &ptx) {
} }
} }
void CWallet::BlockConnected(const CBlock& block, int height) void CWallet::blockConnected(const CBlock& block, int height)
{ {
const uint256& block_hash = block.GetHash(); const uint256& block_hash = block.GetHash();
auto locked_chain = chain().lock(); auto locked_chain = chain().lock();
@@ -1120,11 +1120,11 @@ void CWallet::BlockConnected(const CBlock& block, int height)
for (size_t index = 0; index < block.vtx.size(); index++) { for (size_t index = 0; index < block.vtx.size(); index++) {
CWalletTx::Confirmation confirm(CWalletTx::Status::CONFIRMED, height, block_hash, index); CWalletTx::Confirmation confirm(CWalletTx::Status::CONFIRMED, height, block_hash, index);
SyncTransaction(block.vtx[index], confirm); SyncTransaction(block.vtx[index], confirm);
TransactionRemovedFromMempool(block.vtx[index]); transactionRemovedFromMempool(block.vtx[index]);
} }
} }
void CWallet::BlockDisconnected(const CBlock& block, int height) void CWallet::blockDisconnected(const CBlock& block, int height)
{ {
auto locked_chain = chain().lock(); auto locked_chain = chain().lock();
LOCK(cs_wallet); LOCK(cs_wallet);
@@ -1141,7 +1141,7 @@ void CWallet::BlockDisconnected(const CBlock& block, int height)
} }
} }
void CWallet::UpdatedBlockTip() void CWallet::updatedBlockTip()
{ {
m_best_block_time = GetTime(); m_best_block_time = GetTime();
} }
@@ -3875,7 +3875,7 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain,
} }
auto locked_chain = chain.lock(); auto locked_chain = chain.lock();
walletInstance->ChainStateFlushed(locked_chain->getTipLocator()); walletInstance->chainStateFlushed(locked_chain->getTipLocator());
} else if (wallet_creation_flags & WALLET_FLAG_DISABLE_PRIVATE_KEYS) { } else if (wallet_creation_flags & WALLET_FLAG_DISABLE_PRIVATE_KEYS) {
// Make it impossible to disable private keys after creation // Make it impossible to disable private keys after creation
error = strprintf(_("Error loading %s: Private keys can only be disabled during creation").translated, walletFile); error = strprintf(_("Error loading %s: Private keys can only be disabled during creation").translated, walletFile);
@@ -4056,7 +4056,7 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain,
return nullptr; return nullptr;
} }
} }
walletInstance->ChainStateFlushed(locked_chain->getTipLocator()); walletInstance->chainStateFlushed(locked_chain->getTipLocator());
walletInstance->database->IncrementUpdateCounter(); walletInstance->database->IncrementUpdateCounter();
// Restore wallet transaction metadata after -zapwallettxes=1 // Restore wallet transaction metadata after -zapwallettxes=1

View File

@@ -875,10 +875,10 @@ public:
void MarkDirty(); void MarkDirty();
bool AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose=true); bool AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose=true);
void LoadToWallet(CWalletTx& wtxIn) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); void LoadToWallet(CWalletTx& wtxIn) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
void TransactionAddedToMempool(const CTransactionRef& tx) override; void transactionAddedToMempool(const CTransactionRef& tx) override;
void BlockConnected(const CBlock& block, int height) override; void blockConnected(const CBlock& block, int height) override;
void BlockDisconnected(const CBlock& block, int height) override; void blockDisconnected(const CBlock& block, int height) override;
void UpdatedBlockTip() override; void updatedBlockTip() override;
int64_t RescanFromTime(int64_t startTime, const WalletRescanReserver& reserver, bool update); int64_t RescanFromTime(int64_t startTime, const WalletRescanReserver& reserver, bool update);
struct ScanResult { struct ScanResult {
@@ -897,7 +897,7 @@ public:
uint256 last_failed_block; uint256 last_failed_block;
}; };
ScanResult ScanForWalletTransactions(const uint256& first_block, const uint256& last_block, const WalletRescanReserver& reserver, bool fUpdate); ScanResult ScanForWalletTransactions(const uint256& first_block, const uint256& last_block, const WalletRescanReserver& reserver, bool fUpdate);
void TransactionRemovedFromMempool(const CTransactionRef &ptx) override; void transactionRemovedFromMempool(const CTransactionRef &ptx) override;
void ReacceptWalletTransactions() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); void ReacceptWalletTransactions() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
void ResendWalletTransactions(); void ResendWalletTransactions();
struct Balance { struct Balance {
@@ -1033,7 +1033,7 @@ public:
bool IsAllFromMe(const CTransaction& tx, const isminefilter& filter) const; bool IsAllFromMe(const CTransaction& tx, const isminefilter& filter) const;
CAmount GetCredit(const CTransaction& tx, const isminefilter& filter) const; CAmount GetCredit(const CTransaction& tx, const isminefilter& filter) const;
CAmount GetChange(const CTransaction& tx) const; CAmount GetChange(const CTransaction& tx) const;
void ChainStateFlushed(const CBlockLocator& loc) override; void chainStateFlushed(const CBlockLocator& loc) override;
DBErrors LoadWallet(bool& fFirstRunRet); DBErrors LoadWallet(bool& fFirstRunRet);
DBErrors ZapWalletTx(std::vector<CWalletTx>& vWtx); DBErrors ZapWalletTx(std::vector<CWalletTx>& vWtx);