cashubtc / cdk

Cashu Development Kit
MIT License
87 stars 44 forks source link

Send current state of the subscriptions #444

Closed crodas closed 2 weeks ago

crodas commented 2 weeks ago

Improve #394

Make WebSocket subscriptions send the current status when subscribing. It would also be interesting to implement this logic into the PubSub crate. If we do this, this solution would be agnostic to the WebSocket, and any other bit of the rust code that wants to subscribe would inherit messages of current status when they subscribe. What are your thoughts @thesimplekid ?

thesimplekid commented 2 weeks ago

It would also be interesting to implement this logic into the PubSub crate

It looks like the pubsub mod doesn't currently have access to the database so we would have to provide that? I'm happy with it in either place so if you think its worth refactoring to put it there I'm happy with that, I do see your point about making it agnostic, but if its much more complicated it may not be worht it?

Looking at the current code it looks good my only concern is it looks like we will silently fail, granted on calls that really shouldnt fail, but in general I think its good to at least log errors if returning them is impractical as we don't want to stop the whole call failing for a partial failure.

thesimplekid commented 2 weeks ago

Rebase on main will fix the ci issue