input-output-hk / rust-byron-cardano

rust client libraries to deal with the current cardano mainnet (byron / cardano-sl)
MIT License
264 stars 75 forks source link

chain-storage: Get rid of excessive boxing and dynamism #742

Closed mzabaluev closed 5 years ago

mzabaluev commented 5 years ago

Remove the boxed closures and dynamic trait objects. The BlockStore trait loses object safety, but it should never have required it.

get_path_to_nth_accessor is removed from the trait methods and turned into a free helper fn for_path_to_nth_accessor.

edolstra commented 5 years ago

Does this still work in jormungandr? I seem to remember it was needed there (see NodeStorage in jormungandr/src/start_up/mod.rs).

mzabaluev commented 5 years ago

I need a rust-cardano port to recent master to try it out. I'm going to use an enum. Or perhaps it would be more elegant to restore object safety with the dynamic reference in the iterator.

edolstra commented 5 years ago

Hm, how is that an improvement though? What's the problem with the dynamism?

mzabaluev commented 5 years ago

Many things were boxed when they don't have to. I have now provided impls for both the static and boxed case.

edolstra commented 5 years ago

BTW shouldn't this PR be moved to https://github.com/input-output-hk/chain-libs?

mzabaluev commented 5 years ago

Moved to input-output-hk/chain-libs#1 :1st_place_medal: