@@ -1398,7 +1398,7 @@ void BlockchainLMDB::remove_spent_key(const crypto::key_image& k_image)
13981398 }
13991399}
14001400
1401- void BlockchainLMDB::advance_tree_one_block (const uint64_t blk_idx)
1401+ void BlockchainLMDB::advance_tree (const uint64_t blk_idx)
14021402{
14031403 LOG_PRINT_L3 (" BlockchainLMDB::" << __func__);
14041404 check_open ();
@@ -1409,21 +1409,24 @@ void BlockchainLMDB::advance_tree_one_block(const uint64_t blk_idx)
14091409 // If we're advancing the genesis block, make sure to initialize the tree
14101410 if (blk_idx == 0 )
14111411 {
1412+ // TODO: include a pre-check that tree meta is empty
1413+
14121414 // We grow the first blocks with empty outputs, since no outputs in this range should be spendable yet
14131415 for (uint64_t new_blk_idx = blk_idx; new_blk_idx < earliest_last_locked_block; ++new_blk_idx)
14141416 {
14151417 this ->grow_tree (new_blk_idx, {});
14161418 }
14171419 }
1420+ // TODO: include a pre-check that earliest_last_locked_block == last block idx + 1 in tree meta (when blk_idx != 0)
14181421
14191422 // Now we can advance the tree 1 block
1420- auto unlocked_outputs = this ->get_outs_at_last_locked_block_id (earliest_last_locked_block);
1423+ auto unlocked_outputs = this ->get_outs_at_last_locked_block_idx (earliest_last_locked_block);
14211424
14221425 // Grow the tree with outputs that are spendable once the earliest_last_locked_block is in the chain
14231426 this ->grow_tree (earliest_last_locked_block, std::move (unlocked_outputs));
14241427
14251428 // Now that we've used the unlocked leaves to grow the tree, we delete them from the locked outputs table
1426- this ->del_locked_outs_at_block_id (earliest_last_locked_block);
1429+ this ->del_locked_outs_at_block_idx (earliest_last_locked_block);
14271430}
14281431
14291432void BlockchainLMDB::grow_tree (const uint64_t blk_idx, std::vector<fcmp_pp::curve_trees::OutputContext> &&new_outputs)
@@ -2391,16 +2394,16 @@ bool BlockchainLMDB::audit_layer(const std::unique_ptr<C_CHILD> &c_child,
23912394 return audit_complete;
23922395}
23932396
2394- std::vector<fcmp_pp::curve_trees::OutputContext> BlockchainLMDB::get_outs_at_last_locked_block_id (
2395- uint64_t block_id )
2397+ std::vector<fcmp_pp::curve_trees::OutputContext> BlockchainLMDB::get_outs_at_last_locked_block_idx (
2398+ uint64_t block_idx )
23962399{
23972400 LOG_PRINT_L3 (" BlockchainLMDB::" << __func__);
23982401 check_open ();
23992402
24002403 TXN_PREFIX_RDONLY ();
24012404 RCURSOR (locked_outputs)
24022405
2403- MDB_val_set (k_block_id, block_id );
2406+ MDB_val_set (k_block_idx, block_idx );
24042407 MDB_val v_output;
24052408
24062409 // Get all the locked outputs at the provided block id
@@ -2409,16 +2412,16 @@ std::vector<fcmp_pp::curve_trees::OutputContext> BlockchainLMDB::get_outs_at_las
24092412 MDB_cursor_op op = MDB_SET;
24102413 while (1 )
24112414 {
2412- int result = mdb_cursor_get (m_cur_locked_outputs, &k_block_id , &v_output, op);
2415+ int result = mdb_cursor_get (m_cur_locked_outputs, &k_block_idx , &v_output, op);
24132416 if (result == MDB_NOTFOUND)
24142417 break ;
24152418 if (result != MDB_SUCCESS)
24162419 throw0 (DB_ERROR (lmdb_error (" Failed to get next locked outputs: " , result).c_str ()));
24172420 op = MDB_NEXT_MULTIPLE;
24182421
2419- const uint64_t blk_id = *(const uint64_t *)k_block_id .mv_data ;
2420- if (blk_id != block_id )
2421- throw0 (DB_ERROR ((" Blk id " + std::to_string (blk_id) + " not the expected" + std::to_string (block_id )).c_str ()));
2422+ const uint64_t blk_id = *(const uint64_t *)k_block_idx .mv_data ;
2423+ if (blk_id != block_idx )
2424+ throw0 (DB_ERROR ((" Blk id " + std::to_string (blk_id) + " not the expected" + std::to_string (block_idx )).c_str ()));
24222425
24232426 const auto range_begin = ((const fcmp_pp::curve_trees::OutputContext*)v_output.mv_data );
24242427 const auto range_end = range_begin + v_output.mv_size / sizeof (fcmp_pp::curve_trees::OutputContext);
@@ -2441,17 +2444,17 @@ std::vector<fcmp_pp::curve_trees::OutputContext> BlockchainLMDB::get_outs_at_las
24412444 return outs;
24422445}
24432446
2444- void BlockchainLMDB::del_locked_outs_at_block_id (uint64_t block_id )
2447+ void BlockchainLMDB::del_locked_outs_at_block_idx (uint64_t block_idx )
24452448{
24462449 LOG_PRINT_L3 (" BlockchainLMDB::" << __func__);
24472450 check_open ();
24482451 mdb_txn_cursors *m_cursors = &m_wcursors;
24492452
24502453 CURSOR (locked_outputs)
24512454
2452- MDB_val_set (k_block_id, block_id );
2455+ MDB_val_set (k_block_idx, block_idx );
24532456
2454- int result = mdb_cursor_get (m_cur_locked_outputs, &k_block_id , NULL , MDB_SET);
2457+ int result = mdb_cursor_get (m_cur_locked_outputs, &k_block_idx , NULL , MDB_SET);
24552458 if (result == MDB_NOTFOUND)
24562459 return ;
24572460 if (result != MDB_SUCCESS)
@@ -7587,7 +7590,7 @@ void BlockchainLMDB::migrate_5_6()
75877590 }
75887591 }
75897592
7590- this ->advance_tree_one_block (i);
7593+ this ->advance_tree (i);
75917594
75927595 LOGIF (el::Level::Info)
75937596 {
0 commit comments