diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-04-29 09:49:19 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-04-29 09:52:39 +0200 |
commit | 23c998d81133b7846808ade579b4a00cad611d49 (patch) | |
tree | c4a7f981b69d059d009e6fad93f50aa7fe75bece | |
parent | 948beaf1905b666bfd2ebc171adf06f478e26268 (diff) | |
parent | e9c3215b776b07faeb5184249fc0e43876f26723 (diff) |
Merge pull request #5511
e9c3215 [Wallet] sort pending wallet transactions before reaccepting (dexX7)
-rw-r--r-- | src/wallet/wallet.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 81a9932f36..bb73038b97 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1101,6 +1101,9 @@ void CWallet::ReacceptWalletTransactions() if (!fBroadcastTransactions) return; LOCK2(cs_main, cs_wallet); + std::map<int64_t, CWalletTx*> mapSorted; + + // Sort pending wallet transactions based on their initial wallet insertion order BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet) { const uint256& wtxid = item.first; @@ -1109,13 +1112,19 @@ void CWallet::ReacceptWalletTransactions() int nDepth = wtx.GetDepthInMainChain(); - if (!wtx.IsCoinBase() && nDepth < 0) - { - // Try to add to memory pool - LOCK(mempool.cs); - wtx.AcceptToMemoryPool(false); + if (!wtx.IsCoinBase() && nDepth < 0) { + mapSorted.insert(std::make_pair(wtx.nOrderPos, &wtx)); } } + + // Try to add wallet transactions to memory pool + BOOST_FOREACH(PAIRTYPE(const int64_t, CWalletTx*)& item, mapSorted) + { + CWalletTx& wtx = *(item.second); + + LOCK(mempool.cs); + wtx.AcceptToMemoryPool(false); + } } bool CWalletTx::RelayWalletTransaction() |