Damus
JeffG · 3w
Over the past 6 weeks we've been rebuilding the White Noise flutter app from scratch. We use flutter_rust_bridge to keep all core logic and crypto in Rust. But trying to follow Flutter "best practice...
SatsAndSports profile picture
It might be different, but this kinda reminds me of something I'm doing with my library for processing payments cashu spilman channels.

(I have a question at the end of this long comment)

I have Rust code for processing payments, wrapped around a transport-neutral and stateless core

The wrapper needs to do complex stuff, while also managing state ("how many payments have been made on this channel so far?"). But I didn't want the wrapper to hardcode an arbitrary choice about how to store the state, e.g. SQLite

So, I have a relatively dumb 'Host' interface, where the developer specifies how state is managed. For example, it has a methods "mark_closed(channel_id)" where the developer fills in the code that writes to the database of their choice to record that a channel is now closed.

The developer will typically not call those functions directly from their code. They just call a higher level "process_payment" method in my library which does all the complex stuff and which calls the Host object when needed

The Host also handles all the "pricing policy"

Anyway, I should get back on topic and ask a question ๐Ÿ™‚: I guess you might have something similar? The MDK doesn't need to know where state is stored?

I vaguely remember dealing with this when I used the MDK a little on my toy app. I think I had to do something special to get it working with localStorage in the browser, but I forget the details
1
JeffG · 3w
Yeah! Sounds very similar. We're using a set of storage traits in MDK so that the storage layer is abstracted from the code. The traits define the interface that any storage backend has to implement, then MDK can just call those methods when needed and doesn't need to know exactly what is happening ...