diff options
| author | Antoine Riard <[email protected]> | 2019-04-20 12:02:52 -0400 |
|---|---|---|
| committer | Antoine Riard <[email protected]> | 2019-11-05 12:59:16 -0500 |
| commit | 5aacc3eff15b9b5bdc951f1e274f00d581f63bce (patch) | |
| tree | cdfccd67221dfa0ea43311e5fb99f2b74140e4f6 /src/wallet/wallet.cpp | |
| parent | Pass block height in Chain::BlockConnected/Chain::BlockDisconnected (diff) | |
| download | discoin-5aacc3eff15b9b5bdc951f1e274f00d581f63bce.tar.xz discoin-5aacc3eff15b9b5bdc951f1e274f00d581f63bce.zip | |
Add m_last_block_processed_height field in CWallet
At BlockConnected/BlockDisconnected, we rely on height of block
itself to know current height of wallet
Diffstat (limited to 'src/wallet/wallet.cpp')
| -rw-r--r-- | src/wallet/wallet.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 365a296e6..6c5754aa1 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1058,6 +1058,8 @@ void CWallet::BlockConnected(const CBlock& block, const std::vector<CTransaction auto locked_chain = chain().lock(); LOCK(cs_wallet); + m_last_block_processed_height = height; + m_last_block_processed = block_hash; for (size_t i = 0; i < block.vtx.size(); i++) { SyncTransaction(block.vtx[i], CWalletTx::Status::CONFIRMED, block_hash, i); TransactionRemovedFromMempool(block.vtx[i]); @@ -1065,8 +1067,6 @@ void CWallet::BlockConnected(const CBlock& block, const std::vector<CTransaction for (const CTransactionRef& ptx : vtxConflicted) { TransactionRemovedFromMempool(ptx); } - - m_last_block_processed = block_hash; } void CWallet::BlockDisconnected(const CBlock& block, int height) @@ -1078,6 +1078,8 @@ void CWallet::BlockDisconnected(const CBlock& block, int height) // be unconfirmed, whether or not the transaction is added back to the mempool. // User may have to call abandontransaction again. It may be addressed in the // future with a stickier abandoned state or even removing abandontransaction call. + m_last_block_processed_height = height - 1; + m_last_block_processed = block.hashPrevBlock; for (const CTransactionRef& ptx : block.vtx) { SyncTransaction(ptx, CWalletTx::Status::UNCONFIRMED, {} /* block hash */, 0 /* position in block */); } @@ -3785,8 +3787,10 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain, const Optional<int> tip_height = locked_chain->getHeight(); if (tip_height) { walletInstance->m_last_block_processed = locked_chain->getBlockHash(*tip_height); + walletInstance->m_last_block_processed_height = *tip_height; } else { walletInstance->m_last_block_processed.SetNull(); + walletInstance->m_last_block_processed_height = -1; } if (tip_height && *tip_height != rescan_height) |