bdk icon indicating copy to clipboard operation
bdk copied to clipboard

`maybe_async` complicates isomorphic use-cases

Open cryptoquick opened this issue 3 years ago • 5 comments
trafficstars

The maybe_async macro makes the function signature of each method different depending on whether the dependency is compiled for wasm32 or not. This isn't ideal for libraries that might be used in isomoprhic app frameworks like iced, which can compile to either web or desktop-native targets.

I'm not sure what the best approach would be to fix this since Rust's async story is so complex right now. If at some point we enter the shiny future, we can just remove usage of the bdk-macros crate altogether.

For now, I think it's possible to bypass this issue by also using the bdk-macros crate, but this is imperfect because it essentially perpetuates the problem, and "infects" all upstream dependents.

cryptoquick avatar Mar 07 '22 12:03 cryptoquick

@cryptoquick fwiw I am working on this as part of #165. My plan is to have a sync blockchain traits in blockchain and async versions in blockchain::async. Would this work for your use case?

LLFourn avatar Mar 08 '22 00:03 LLFourn

Maybe! I might be able to finagle conditional compilation to accomplish that. Is your branch ready to try? Also, is it merged with main? (I'm typing this on mobile, otherwise I'd check, myself)

cryptoquick avatar Mar 08 '22 00:03 cryptoquick

Just got back to my machine to check, and it looks like that's just an issue, not a pull request. Still, this might work, and it's idiomatic to how other libraries in the Rust ecosystem works. I'd be willing to close this in light of the work being done there, if you think that makes sense, @LLFourn ?

cryptoquick avatar Mar 08 '22 00:03 cryptoquick

We are starting work on this change today. Won't be ready for testing this week I suspect. I'll keep you updated.

LLFourn avatar Mar 08 '22 00:03 LLFourn

Sounds good. I've also subscribed to the other thread, and also, let me know if you need any help testing your work.

cryptoquick avatar Mar 08 '22 00:03 cryptoquick