mintlayer / mintlayer-core

Mintlayer Core: The central repository housing the essential components to operate a Mintlayer node. It encompasses the node and wallet functionalities necessary for seamless operation, alongside an additional API server designed to facilitate applications.
https://www.mintlayer.org
MIT License
42 stars 24 forks source link

Implement in_mem_block_tree #1786

Open ImplOfAnImpl opened 1 week ago

ImplOfAnImpl commented 1 week ago

This is the generalized version of the "in-memory block tree" from #1768 . The corresponding Trees/Tree/TreeRef structs are in tree_wrappers.rs. However, I also had to wrap all indextree's primitives (which are in the primitives module), so that they can be exposed to the user and still maintain the required guarantees (i.e. that a parent/child nodes will always correspond to parent/child blocks).

ImplOfAnImpl commented 1 week ago

Can we move this to its own crate in utils?

in_mem_block_tree depends on common because it needs primitives related to blocks, such as Id and GenBlock. So, utils is not a good place for it. But I agree that the current place is not the best for it either.

ImplOfAnImpl commented 6 days ago

Can we move this to its own crate in utils?

in_mem_block_tree depends on common because it needs primitives related to blocks, such as Id and GenBlock. So, utils is not a good place for it. But I agree that the current place is not the best for it either.

I've abstracted Id<GenBlock> away from it and then moved it to utils. Some caveats: 1) I've renamed it to in_mem_item_tree, because the crate has nothing to do with blocks anymore; I don't really like this new name, but I couldn't come up with anything better. 2) utils/in_mem_item_tree depends on utils and not vice versa, like its other crates. This doesn't look nice, but we already have similar inconsistency in other places, e.g. in the wallet, so I guess it's ok?

TheQuantumPhysicist commented 6 days ago

That's alright.