-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generalize/deduplicate async batch verification services / create a derive-able proc macro #1951
Comments
I ended up looking at the code as part of working on #2371 (and investigating what became #2390), and I stumbled upon an idea. I'll post it as a comment here before I forget it and just in case it's useful in the future. I thought about creating a trait that resembles something like:
and also a wrapper type to have the actual implementation of the service:
The remaining piece would be to have the actual batch and fallback wrapping code. This could be done by having a single constructor exposed for the
With this trait and this wrapper type, it's possible to only implement the Not actually sure any of this works, so more research will be needed in the future. |
I think trait constants might have to be const generics, but they actually work in recent rust versions. Or they could just be functions. |
Associated constants should work since Rust 1.20. Or do you mean it should be configurable when instantiated? |
Ah you're right, I just haven't used them with traits before: |
Nice to have, but I think redundant now |
We now have three async batch verifiers in
zebra-consensus::primitives
, and they won't be the last (Orchard will bringhalo2::Verifier
andredpallas::Verifier
eventually). There is a lot of boilerplate being copy-pasted around, which may be ok for easy deletion, but when it's duplicated amongst ~5 variants, it's a signal to revisit where we can DRY this up or make a more generic async batch Verifier, which can then be instantiated with differentItem
s/ItemWrapper
s and somecall
method/function.Or we could create a derive-able proc macro: https://github.com/imbolc/rust-derive-macro-guide
The text was updated successfully, but these errors were encountered: