Skip to content

Commit

Permalink
Remove now unneeded ChainTip signal
Browse files Browse the repository at this point in the history
  • Loading branch information
furszy committed Jan 21, 2021
1 parent f5b0b77 commit 2f85421
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/sapling/saplingscriptpubkeyman.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class SaplingNoteData
* Block height corresponding to the most current witness.
*
* When we first create a SaplingNoteData in SaplingScriptPubKeyMan::FindMySaplingNotes, this is set to
* -1 as a placeholder. The next time CWallet::ChainTip is called, we can
* -1 as a placeholder. The next time CWallet::BlockConnected/CWallet::BlockDisconnected is called, we can
* determine what height the witness cache for this note is valid for (even
* if no witnesses were cached), and so can set the correct value in
* SaplingScriptPubKeyMan::IncrementNoteWitnesses and SaplingScriptPubKeyMan::DecrementNoteWitnesses.
Expand Down
11 changes: 1 addition & 10 deletions src/validationinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ struct ValidationInterfaceConnections {
boost::signals2::scoped_connection SetBestChain;
boost::signals2::scoped_connection Broadcast;
boost::signals2::scoped_connection BlockChecked;
boost::signals2::scoped_connection ChainTip;
};

struct MainSignalsInstance {
// XX42 boost::signals2::signal<void(const uint256&)> EraseTransaction;

/** Notifies listeners of updated block chain tip */
boost::signals2::signal<void (const CBlockIndex *, const CBlockIndex *, bool fInitialDownload)> UpdatedBlockTip;
/** Notifies listeners of a transaction having been added to mempool. */
Expand All @@ -46,9 +45,6 @@ struct MainSignalsInstance {
/** Notifies listeners of a block validation result */
boost::signals2::signal<void (const CBlock&, const CValidationState&)> BlockChecked;

/** Notifies listeners of a change to the tip of the active block chain. */
boost::signals2::signal<void (const CBlockIndex *, const CBlock *, Optional<SaplingMerkleTree>)> ChainTip;

std::unordered_map<CValidationInterface*, ValidationInterfaceConnections> m_connMainSignals;
};

Expand All @@ -70,7 +66,6 @@ void RegisterValidationInterface(CValidationInterface* pwalletIn)
conns.TransactionAddedToMempool = g_signals.m_internals->TransactionAddedToMempool.connect(std::bind(&CValidationInterface::TransactionAddedToMempool, pwalletIn, std::placeholders::_1));
conns.BlockConnected = g_signals.m_internals->BlockConnected.connect(std::bind(&CValidationInterface::BlockConnected, pwalletIn, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
conns.BlockDisconnected = g_signals.m_internals->BlockDisconnected.connect(std::bind(&CValidationInterface::BlockDisconnected, pwalletIn, std::placeholders::_1, std::placeholders::_2));
conns.ChainTip = g_signals.m_internals->ChainTip.connect(std::bind(&CValidationInterface::ChainTip, pwalletIn, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
conns.NotifyTransactionLock = g_signals.m_internals->NotifyTransactionLock.connect(std::bind(&CValidationInterface::NotifyTransactionLock, pwalletIn, std::placeholders::_1));
conns.UpdatedTransaction = g_signals.m_internals->UpdatedTransaction.connect(std::bind(&CValidationInterface::UpdatedTransaction, pwalletIn, std::placeholders::_1));
conns.SetBestChain = g_signals.m_internals->SetBestChain.connect(std::bind(&CValidationInterface::SetBestChain, pwalletIn, std::placeholders::_1));
Expand Down Expand Up @@ -128,7 +123,3 @@ void CMainSignals::Broadcast(CConnman* connman) {
void CMainSignals::BlockChecked(const CBlock& block, const CValidationState& state) {
m_internals->BlockChecked(block, state);
}

void CMainSignals::ChainTip(const CBlockIndex* pindex, const CBlock* block, Optional<SaplingMerkleTree> tree) {
m_internals->ChainTip(pindex, block, tree);
}
2 changes: 0 additions & 2 deletions src/validationinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class CValidationInterface {
virtual void TransactionAddedToMempool(const CTransactionRef &ptxn) {}
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, int nBlockHeight) {}
virtual void ChainTip(const CBlockIndex *pindex, const CBlock *pblock, Optional<SaplingMerkleTree> added) {}
virtual void NotifyTransactionLock(const CTransaction &tx) {}
/** Notifies listeners of the new active block chain on-disk. */
virtual void SetBestChain(const CBlockLocator &locator) {}
Expand Down Expand Up @@ -68,7 +67,6 @@ class CMainSignals {
void SetBestChain(const CBlockLocator &);
void Broadcast(CConnman* connman);
void BlockChecked(const CBlock&, const CValidationState&);
void ChainTip(const CBlockIndex *, const CBlock *, Optional<SaplingMerkleTree>);
};

CMainSignals& GetMainSignals();
Expand Down
4 changes: 3 additions & 1 deletion src/wallet/test/wallet_shielded_balances_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,9 @@ BOOST_AUTO_TEST_CASE(GetShieldedAvailableCredit)
// 2) Confirm the tx
SaplingMerkleTree tree;
FakeBlock fakeBlock = SimpleFakeMine(wtxUpdated, tree);
wallet.ChainTip(fakeBlock.pindex, &fakeBlock.block, tree);
// Simulate receiving a new block and updating the witnesses/nullifiers
wallet.IncrementNoteWitnesses(fakeBlock.pindex, &fakeBlock.block, tree);
wallet.GetSaplingScriptPubKeyMan()->UpdateSaplingNullifierNoteMapForBlock(&fakeBlock.block);
wtxUpdated = wallet.mapWallet[wtxUpdated.GetHash()];

// 3) Now can spend one output and recalculate the shielded credit.
Expand Down
12 changes: 0 additions & 12 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,18 +445,6 @@ void CWallet::ChainTipAdded(const CBlockIndex *pindex,
m_sspk_man->UpdateSaplingNullifierNoteMapForBlock(pblock);
}

void CWallet::ChainTip(const CBlockIndex *pindex,
const CBlock *pblock,
Optional<SaplingMerkleTree> added)
{
if (added) {
ChainTipAdded(pindex, pblock, added.get());
} else {
DecrementNoteWitnesses(pindex);
m_sspk_man->UpdateSaplingNullifierNoteMapForBlock(pblock);
}
}

void CWallet::SetBestChain(const CBlockLocator& loc)
{
CWalletDB walletdb(*dbw);
Expand Down
5 changes: 0 additions & 5 deletions src/wallet/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -724,11 +724,6 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
CAmount GetCredit(const CWalletTx& tx, const isminefilter& filter) const;
CAmount GetChange(const CTransaction& tx) const;

//! Sapling merkle tree update
void ChainTip(const CBlockIndex *pindex,
const CBlock *pblock,
Optional<SaplingMerkleTree> added) override;

void SetBestChain(const CBlockLocator& loc) override;
void SetBestChainInternal(CWalletDB& walletdb, const CBlockLocator& loc); // only public for testing purposes, must never be called directly in any other situation
// Force balance recomputation if any transaction got conflicted
Expand Down

0 comments on commit 2f85421

Please sign in to comment.