Skip to content

Quotes refactor#47

Closed
machuPikacchuBTC wants to merge 6 commits intovnprc:masterfrom
machuPikacchuBTC:quotes-refactor
Closed

Quotes refactor#47
machuPikacchuBTC wants to merge 6 commits intovnprc:masterfrom
machuPikacchuBTC:quotes-refactor

Conversation

@machuPikacchuBTC
Copy link
Collaborator

Note: this is dependent on a proposed change to CDK.

Addresses #45

This PR adds a method for fetching a batch of quote IDs from the mint via an HTTP Get request instead of reading from Redis directly.

Steps to get it running:

  • export CDK_PATH=/path/to/cdk/repo/crates/cdk/
  • just local-cdk
  • add the redis feature to the cdk-axum import in the mint Cargo.toml cdk-axum = { path = "$CDK_PATH/cdk-axum", features = ["redis"] }
  • devenv up

I'm still testing this before I open a full PR, but it runs locally. We should also consider updating the CDK wallet client so that we don't have to hardcode the mint URL and path here. Opening this draft now for early feedback!

Comment on lines 359 to 360
match serde_json::from_str::<HashMap<String, String>>(&body) {
Ok(mapping) => mapping,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
match serde_json::from_str::<HashMap<String, String>>(&body) {
Ok(mapping) => mapping,
match serde_json::from_str::<serde_json::Value>(&body) {
Ok(json) => {
let mut result = HashMap::new();
if let Some(quote_ids) = json.get("quote_ids").and_then(|v| v.as_object()) {
for (k, v) in quote_ids {
if let Some(uuid) = v.as_str() {
result.insert(k.clone(), uuid.to_string());
}
}
}
result
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the CDK wallet client to support the new route so we may be able to avoid this whole serde block. I'm still testing it locally but I'll push up the changes so you can take a look.

@vnprc
Copy link
Owner

vnprc commented May 29, 2025

You don't need to add redis to all the example toml files. If you look here in devenv.nix you can see which toml we actually use: tproxy-config-local-jdc-example.toml. But we should probably move away from this example config.

I've been working on a hashpool global config file. Check out how I imported the redis URL in the translator proxy mint. https://github.com/vnprc/hashpool/blob/master/roles/mint/src/main.rs#L55

We should do something similar in the translator main.rs or wherever makes the most sense. I need to convert it into rust structs to get away from the manual parsing you can see here: https://github.com/vnprc/hashpool/blob/master/roles/mint/src/main.rs#L154-L157

Just a heads up. I will comment again when I get the config struct committed. Done ✅

@vnprc
Copy link
Owner

vnprc commented May 29, 2025

I just updated global config to work with an import. It only has redis configs for now but this is the new home for any shared config between roles.

@vnprc
Copy link
Owner

vnprc commented Jun 3, 2025

I just rebased master into this branch and wow it was rough. I got it working but I didn't like the way it reassigned your commits to me. That would bother me if I was a contributor so I made this fork with the working code after rebase.

https://github.com/vnprc/hashpool/tree/pikacchu-rebase

We can proceed however you want. If you don't care about the commit author field and want to make forward progress on the project the fastest thing is probably for me to force push this up to the master branch. The commit messages are kind of inaccurate now but as long as it works we can roll forward.

If you want to take this as a learning opportunity you can use this branch as a reference to do the rebase yourself. You'll definitely learn more this way. I'd probably take this path, but it's up to you.

@machuPikacchuBTC
Copy link
Collaborator Author

Closing in favor of #48 as this branch has conflicts and the git history will be cleaner with the other PR.

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.

2 participants