aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_db/blockchain_db.cpp
diff options
context:
space:
mode:
authorwarptangent <warptangent@tutanota.com>2015-12-24 15:01:00 -0800
committerwarptangent <warptangent@tutanota.com>2015-12-24 15:09:09 -0800
commitd4c2fae2fb85e6064296a2467dc8ac28f431f3ee (patch)
tree1a43b9a460b5c91c7643929bfb11b4f8282ec714 /src/blockchain_db/blockchain_db.cpp
parentBlockchainLMDB: When removing, find amount output index fast by starting at end (diff)
downloadmonero-d4c2fae2fb85e6064296a2467dc8ac28f431f3ee.tar.xz
BlockchainDB: Remove txs in reverse order
Data should be removed in the reverse order it was added. Not doing so breaks assumptions and can cause problems in other DB implementations. This matches the order of tx removal in blockchain_storage::purge_block_data_from_blockchain.
Diffstat (limited to 'src/blockchain_db/blockchain_db.cpp')
-rw-r--r--src/blockchain_db/blockchain_db.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/blockchain_db/blockchain_db.cpp b/src/blockchain_db/blockchain_db.cpp
index 32e89e06a..4fa8cce26 100644
--- a/src/blockchain_db/blockchain_db.cpp
+++ b/src/blockchain_db/blockchain_db.cpp
@@ -26,6 +26,8 @@
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#include <boost/range/adaptor/reversed.hpp>
+
#include "blockchain_db.h"
#include "cryptonote_core/cryptonote_format_utils.h"
#include "profile_tools.h"
@@ -133,13 +135,13 @@ void BlockchainDB::pop_block(block& blk, std::vector<transaction>& txs)
blk = get_top_block();
remove_block();
-
- remove_transaction(get_transaction_hash(blk.miner_tx));
- for (const auto& h : blk.tx_hashes)
+
+ for (const auto& h : boost::adaptors::reverse(blk.tx_hashes))
{
txs.push_back(get_tx(h));
remove_transaction(h);
}
+ remove_transaction(get_transaction_hash(blk.miner_tx));
}
bool BlockchainDB::is_open() const