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
Login to reply
Replies (1)
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 in storage. We have two implementations that we maintain; a simple memory storage backend (mostly for tests) and a sqlite storage backend (which is now also encrypted at rest using SQLCipher). I hope that more storage backends will crop up from the community for other databases over time.
I only talked about the Flutter app refactor here but we've done a massive refactor of MDK and the whitenoise-rs crates as well over the last two months. Largely based on the audit feedback but also cleaning up and improving a lot of things based on learnings of having the app out there in the wild over the last 7 months.