Skip to content
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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MartinSchere
Copy link
Contributor

@MartinSchere MartinSchere commented Jun 10, 2022

In progress

  • Finds the script in the witness set
  • Hashes it to get the key and stores it using the LastWriteWins CRDT
  • Had to remove some #[cfg(feature = "unstable")] as it was skipping some stuff in my linter

@MartinSchere
Copy link
Contributor Author

I could get the correct information to send_set_add, however, for some reason, it's not getting stored to Redis. I probably missed some boilerplate regarding that.

@matiwinnetou
Copy link
Collaborator

I had the same issue, when something is part of cfg unstable, linter skips this in vscode (rust-analyzer)

@scarmuega
Copy link
Member

if you're using VSCode, try adding "rust-analyzer.cargo.features": "all" to you settings.json


pub struct Reducer {
config: Config,
address_hrp: String,
Copy link
Collaborator

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 {
Copy link
Collaborator

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?

Copy link
Member

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

Copy link
Collaborator

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);
Copy link
Collaborator

@matiwinnetou matiwinnetou Jun 10, 2022

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants