-
Notifications
You must be signed in to change notification settings - Fork 42
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
feat: script by hash reducer #25
base: main
Are you sure you want to change the base?
Conversation
I could get the correct information to |
I had the same issue, when something is part of cfg unstable, linter skips this in vscode (rust-analyzer) |
if you're using VSCode, try adding |
|
||
pub struct Reducer { | ||
config: Config, | ||
address_hrp: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need address_hrp for anything, probably copy and paste.
tx: &alonzo::TransactionWitnessSet, | ||
output: &mut super::OutputPort, | ||
) -> Result<(), gasket::error::Error> { | ||
if let Some(plutus_scripts) = &tx.plutus_script { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your code is iterative but actually the way one should write this IMHO is that rather than returning OK at the end, one should rather map and collect all results and return them from this function. Now I am by far a Rust noob but perhaps Rust will take a first item out of all results or evaluate lazily and stop execution and return result on first error.
@scarmuega do you agree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it return result on first error if we use the ?
operator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting operator... this is what I thought but you confirmed it.
Powerful and confusing operator.
cbor: PlutusScript, | ||
output: &mut super::OutputPort, | ||
) -> Result<(), gasket::error::Error> { | ||
let key = format!("{}", hash); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like you are ignoring a configuration key (prefix)
In progress
LastWriteWins
CRDT#[cfg(feature = "unstable")]
as it was skipping some stuff in my linter