Closed nils-mathieu closed 18 hours ago
The ffi::MDBX_RDONLY
type and friends seem to have different types on my machine (Windows 11) than they are on the testing environment.
Should I duplicate the function? Ideally the constant themselves should change not to change type depending on the compilation target, I guess.
regarding the different mdbx type, could you ptal at
https://github.com/paradigmxyz/reth/issues/12259#issuecomment-2452962847
@mattsse done!
This pull request fixes #12672.
It adds the type
HooksBuilder
, responsible for creating new custom instances of theHooks
collection.Changes
HooksBuilder
type.Hooks::builder
method to create a newHooksBuilder
.Hooks::new
byHooks::builder
.Hooks::new
.Considerations
HooksBuilder
to ease its usage a bit.HooksBuilder::with_database_metrics
HooksBuilder::with_static_file_provider
HooksBuilder::with_default_collector
I made that choice because moving the cloning logic to the caller of
Hooks::new
requires us to write a bit of boilerplate due to having to move resources into the static hook closure:Replaced by:
I'm not sure whether this was a good idea. It is a bit faster to write, but maybe it makes the logic a bit harder to reason about. If someone reads that, they might assume that
with_database_metrics
is setting a specific "database_metrics" field in the builder, when it is not.I can remove those convenience methods if needed.
Other
I had to fix a compilation error here (there was a comparaison between
i32
andu32
: https://github.com/paradigmxyz/reth/blob/7c7baca9807e9a9556cb217d3df8cd03c21ba4ed/crates/storage/libmdbx-rs/src/environment.rs#L431-L444I changed a
format!
to aformat_args!
in theDebug
implementation ofHooks
to save on an allocation.