From 461e49fee2935b1eb4d4ea7bae3023e655c0a6d8 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 29 Mar 2017 21:12:42 -0400 Subject: SyncTransaction->TxAddedToMempool/BlockConnected/Disconnected This simplifies fixing the wallet-returns-stale-info issue as we can now hold cs_wallet across an entire block instead of only per-tx (though we only actually do so in the next commit). This change also removes the NOT_IN_BLOCK constant in favor of only passing the CBlockIndex* parameter to SyncTransactions when a new block is being connected, instead of also when a block is being disconnected. This change adds a parameter to BlockConnectedDisconnected which lists the transactions which were removed from mempool due to confliction as a result of this operation. While its somewhat of a shame to make block-validation-logic generate a list of mempool changes to be included in its generated callbacks, fixing this isnt too hard. Further in this change-set, CValidationInterface starts listening to mempool directly, placing it in the middle and giving it a bit of logic to know how to route notifications from block-validation, mempool, etc (though not listening for conflicted-removals yet). --- src/wallet/wallet.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/wallet/wallet.h') diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index ccede60097..d7890ba0ca 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -661,6 +661,9 @@ private: void SyncMetaData(std::pair); + /* Used by TransactionAddedToMemorypool/BlockConnected/Disconnected */ + void SyncTransaction(const CTransactionRef& tx, const CBlockIndex *pindexBlockConnected, int posInBlock); + /* the HD chain data model (external chain counters) */ CHDChain hdChain; @@ -849,7 +852,9 @@ public: void MarkDirty(); bool AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose=true); bool LoadToWallet(const CWalletTx& wtxIn); - void SyncTransaction(const CTransaction& tx, const CBlockIndex *pindex, int posInBlock) override; + void TransactionAddedToMempool(const CTransactionRef& tx) override; + void BlockConnected(const std::shared_ptr& pblock, const CBlockIndex *pindex, const std::vector& vtxConflicted) override; + void BlockDisconnected(const std::shared_ptr& pblock) override; bool AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlockIndex* pIndex, int posInBlock, bool fUpdate); CBlockIndex* ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate = false); void ReacceptWalletTransactions(); -- cgit v1.2.3 From 91f1e6ce5e7854435196464aace0dcf7ce21dd5a Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 19 Jan 2017 15:47:03 -0500 Subject: Remove dead-code tracking of requests for blocks we generated --- src/wallet/wallet.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/wallet/wallet.h') diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index d7890ba0ca..127ffd6cf3 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -964,11 +964,6 @@ public: } void GetScriptForMining(boost::shared_ptr &script) override; - void ResetRequestCount(const uint256 &hash) override - { - LOCK(cs_wallet); - mapRequestCount[hash] = 0; - }; unsigned int GetKeyPoolSize() { -- cgit v1.2.3 From 1c95e2f9c94f172ddddedeb1358953992f39f8bd Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 19 Jan 2017 16:15:41 -0500 Subject: Use std::shared_ptr instead of boost::shared_ptr in ScriptForMining --- src/wallet/wallet.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/wallet/wallet.h') diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 127ffd6cf3..daae930399 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -28,8 +28,6 @@ #include #include -#include - extern CWallet* pwalletMain; /** @@ -963,7 +961,7 @@ public: } } - void GetScriptForMining(boost::shared_ptr &script) override; + void GetScriptForMining(std::shared_ptr &script) override; unsigned int GetKeyPoolSize() { -- cgit v1.2.3 From b1a6d4cd560fbdb66506841860db03c08ea4bbbc Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 6 Mar 2017 18:21:27 -0500 Subject: Take a CTransactionRef in AddToWalletIfInvolvingMe to avoid a copy --- src/wallet/wallet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/wallet/wallet.h') diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index daae930399..05c00326ec 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -853,7 +853,7 @@ public: void TransactionAddedToMempool(const CTransactionRef& tx) override; void BlockConnected(const std::shared_ptr& pblock, const CBlockIndex *pindex, const std::vector& vtxConflicted) override; void BlockDisconnected(const std::shared_ptr& pblock) override; - bool AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlockIndex* pIndex, int posInBlock, bool fUpdate); + bool AddToWalletIfInvolvingMe(const CTransactionRef& tx, const CBlockIndex* pIndex, int posInBlock, bool fUpdate); CBlockIndex* ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate = false); void ReacceptWalletTransactions(); void ResendWalletTransactions(int64_t nBestBlockTime, CConnman* connman) override; -- cgit v1.2.3