@@ -372,6 +372,7 @@ typedef struct layer_val {
372372 uint64_t child_chunk_idx;
373373 crypto::ec_point child_chunk_hash;
374374} layer_val;
375+ static_assert (sizeof (layer_val) == (8 +32 ), " layer_val unexpected size" );
375376
376377typedef struct mdb_tree_meta {
377378 uint64_t n_leaf_tuples;
@@ -1427,7 +1428,7 @@ void BlockchainLMDB::del_locked_outs_at_block_idx(uint64_t block_idx)
14271428 throw1 (DB_ERROR (lmdb_error (" Error removing locked outputs: " , result).c_str ()));
14281429}
14291430
1430- std::vector<crypto::ec_point> BlockchainLMDB::grow_with_tree_extension (const fcmp_pp::curve_trees::CurveTreesV1::TreeExtension &tree_extension)
1431+ std::vector<crypto::ec_point> BlockchainLMDB::grow_with_tree_extension (const fcmp_pp::CompressedTreeExtension &tree_extension)
14311432{
14321433 LOG_PRINT_L3 (" BlockchainLMDB::" << __func__);
14331434 check_open ();
@@ -1452,60 +1453,22 @@ std::vector<crypto::ec_point> BlockchainLMDB::grow_with_tree_extension(const fcm
14521453 }
14531454
14541455 // Grow the layers
1455- const auto &c1_extensions = tree_extension.c1_layer_extensions ;
1456- const auto &c2_extensions = tree_extension.c2_layer_extensions ;
1457- const std::size_t n_layers = c1_extensions.size () + c2_extensions.size ();
1458- if (n_layers == 0 )
1456+ const auto &layer_extensions = tree_extension.layer_extensions ;
1457+ if (layer_extensions.empty ())
14591458 throw0 (DB_ERROR (" Unexpected 0 n layers" ));
14601459
1461- bool parent_is_c1 = true ;
1462- uint64_t c1_idx = 0 ;
1463- uint64_t c2_idx = 0 ;
14641460 std::vector<crypto::ec_point> tree_edge;
1465- tree_edge.reserve (n_layers );
1466- for (uint64_t i = 0 ; i < n_layers ; ++i )
1461+ tree_edge.reserve (layer_extensions. size () );
1462+ for (uint64_t layer_idx = 0 ; layer_idx < layer_extensions. size () ; ++layer_idx )
14671463 {
1468- const uint64_t layer_idx = c1_idx + c2_idx;
14691464 MTRACE (" Growing layer " << layer_idx);
1470-
1471- if (parent_is_c1)
1472- {
1473- if (layer_idx % 2 != 0 )
1474- throw0 (DB_ERROR ((" Growing odd c1 layer, expected even layer idx for c1: "
1475- + std::to_string (layer_idx)).c_str ()));
1476-
1477- tree_edge.emplace_back (this ->grow_layer <fcmp_pp::curve_trees::Selene>(
1478- m_curve_trees->m_c1 ,
1479- c1_extensions.at (c1_idx),
1480- layer_idx
1481- ));
1482-
1483- ++c1_idx;
1484- }
1485- else
1486- {
1487- if (layer_idx % 2 == 0 )
1488- throw0 (DB_ERROR ((" Growing even c2 layer, expected odd layer idx for c2: "
1489- + std::to_string (layer_idx)).c_str ()));
1490-
1491- tree_edge.emplace_back (this ->grow_layer <fcmp_pp::curve_trees::Helios>(
1492- m_curve_trees->m_c2 ,
1493- c2_extensions.at (c2_idx),
1494- layer_idx
1495- ));
1496-
1497- ++c2_idx;
1498- }
1499-
1500- parent_is_c1 = !parent_is_c1;
1465+ tree_edge.emplace_back (this ->grow_layer (layer_extensions.at (layer_idx), layer_idx));
15011466 }
15021467
15031468 return tree_edge;
15041469}
15051470
1506- template <typename C>
1507- crypto::ec_point BlockchainLMDB::grow_layer (const std::unique_ptr<C> &curve,
1508- const fcmp_pp::LayerExtension<C> &layer_extension,
1471+ crypto::ec_point BlockchainLMDB::grow_layer (const fcmp_pp::CompressedLayerExtension &layer_extension,
15091472 const uint64_t layer_idx)
15101473{
15111474 LOG_PRINT_L3 (" BlockchainLMDB::" << __func__);
@@ -1525,7 +1488,7 @@ crypto::ec_point BlockchainLMDB::grow_layer(const std::unique_ptr<C> &curve,
15251488 // 1. Update the existing last hash if necessary
15261489 if (layer_extension.update_existing_last_hash )
15271490 {
1528- hashes.emplace_back (curve-> to_bytes ( layer_extension.hashes .front () ));
1491+ hashes.emplace_back (layer_extension.hashes .front ());
15291492
15301493 // We updated the last hash, so update it
15311494 layer_val lv;
@@ -1543,7 +1506,7 @@ crypto::ec_point BlockchainLMDB::grow_layer(const std::unique_ptr<C> &curve,
15431506 // 2. Add all the new hashes found in the extension
15441507 for (uint64_t i = layer_extension.update_existing_last_hash ? 1 : 0 ; i < layer_extension.hashes .size (); ++i)
15451508 {
1546- hashes.emplace_back (curve-> to_bytes ( layer_extension.hashes [i]) );
1509+ hashes.emplace_back (layer_extension.hashes [i]);
15471510
15481511 layer_val lv;
15491512 lv.child_chunk_idx = i + layer_extension.start_idx ;
@@ -1652,7 +1615,7 @@ std::vector<crypto::ec_point> BlockchainLMDB::get_tree_edge(uint64_t block_id) c
16521615 return res;
16531616}
16541617
1655- fcmp_pp::PathBytes BlockchainLMDB::get_path (const fcmp_pp::PathIndexes &path_indexes) const
1618+ fcmp_pp::CompressedPath BlockchainLMDB::get_path (const fcmp_pp::PathIndexes &path_indexes) const
16561619{
16571620 LOG_PRINT_L3 (" BlockchainLMDB::" << __func__);
16581621 check_open ();
@@ -1661,7 +1624,7 @@ fcmp_pp::PathBytes BlockchainLMDB::get_path(const fcmp_pp::PathIndexes &path_ind
16611624 RCURSOR (leaves)
16621625 RCURSOR (layers)
16631626
1664- fcmp_pp::PathBytes path_bytes;
1627+ fcmp_pp::CompressedPath path_bytes;
16651628
16661629 auto &leaves_out = path_bytes.leaves ;
16671630 auto &layer_chunks_out = path_bytes.layer_chunks ;
@@ -1705,7 +1668,7 @@ fcmp_pp::PathBytes BlockchainLMDB::get_path(const fcmp_pp::PathIndexes &path_ind
17051668 std::size_t layer_idx = 0 ;
17061669 for (const auto &layer_idx_range : path_indexes.layers )
17071670 {
1708- fcmp_pp::ChunkBytes chunk;
1671+ fcmp_pp::CompressedChunk chunk;
17091672
17101673 MDB_val_set (k, layer_idx);
17111674 MDB_val_set (v, layer_idx_range.first );
@@ -1722,7 +1685,7 @@ fcmp_pp::PathBytes BlockchainLMDB::get_path(const fcmp_pp::PathIndexes &path_ind
17221685 throw0 (DB_ERROR (lmdb_error (" Failed to get layer elem: " , result).c_str ()));
17231686
17241687 auto *lv = (layer_val *)v.mv_data ;
1725- chunk.chunk_bytes .emplace_back (std::move (lv->child_chunk_hash ));
1688+ chunk.elems .emplace_back (std::move (lv->child_chunk_hash ));
17261689 }
17271690
17281691 layer_chunks_out.emplace_back (std::move (chunk));
0 commit comments