This repository has been archived by the owner on Nov 6, 2020. It is now read-only.
Remove engine to client circular reference #9114
Labels
F6-refactor 📚
Code needs refactoring.
M4-core ⛓
Core client code / Rust.
P5-sometimesoon 🌲
Issue is worth doing soon.
Milestone
In
ethcore
, theEngine
trait is usually invoked byClient
. However, in some cases, anEngine
would also need to query additional state, and requires a reference back toClient
. We haveEngine::register_client
andError::RequiresClient
. Because this is circular, it may be better if we can remove it.Currently we only use this feature for Aura engine in two places:
on_close_block
, where we need to calculate how many empty steps have passed.EpochManager::zoom_to
function, where we need to get the epoch transition for the parent block.The first one can be easily fixed by using the new AncestryIterator, possibly combined with
set_metadata
.The second one is a little bit more complicated -- we would need to add an extra field to
BlockDetails
, recording the current epoch transition directly, and then use the same method we allowed engine to fetch finalized info to fetch current epoch transition. The complication arises because this time we cannot avoid a DB migration. But it indeed has its benefits -- theepoch_transition_for
function can now be alwaysO(1)
.The text was updated successfully, but these errors were encountered: