Egge on Nostr: I have spent several weeks trying to replace the Blink API wrapper of npub.cash with ...
I have spent several weeks trying to replace the Blink API wrapper of npub.cash with a Cashu native alternative and its been a wild ride.
While Cashu mints do support WebSockets for realtime updates, it turned out that WebSockets are pretty difficult to work with, when you are trying to keep them and the subscriptions alive for long periods (in my case days).
But there is a second issue: You see Cashu mints enfore rather strict rate limits on their users. This is important as Cashu is account-less and preventing spam attacks is difficult. Usually this is no issue, as regular users interacting with a mint do not hit these limits. But npub.cash is a funnel. Instead of every user using their own IP to hit the mint, with npub.cash every user "proxies" through the services server.
Turns out this second issue is much bigger than the first one and WebSockets do not solve this. So I decided to build a scheduler that make sure that all mint communication happens as frequent as possible, but never to frequent. This module also solves the first issue, as it allows to queue polling tasks in a lower priority making sure the service stays up to date about payment activity.
If the server restarts it wont hit the mint with a gazillion subs at once, it will make sure they are evenly spread out through low priority calls, while always making sure there is "rate" left for calls that need to be instant.
I built this module externally, so theoretically I could publish it as npm package for structured and timed mint communication. Please let me know if you could use something like this (because as of right now I don't think most Cashu applications would benefit from this, npub.cash is not your usual Cashu application).
After doing some testing I think it is ready to put into an experimental version of npub.cash. I hope to release this on reckless-npub.cash by the end of the week.
While Cashu mints do support WebSockets for realtime updates, it turned out that WebSockets are pretty difficult to work with, when you are trying to keep them and the subscriptions alive for long periods (in my case days).
But there is a second issue: You see Cashu mints enfore rather strict rate limits on their users. This is important as Cashu is account-less and preventing spam attacks is difficult. Usually this is no issue, as regular users interacting with a mint do not hit these limits. But npub.cash is a funnel. Instead of every user using their own IP to hit the mint, with npub.cash every user "proxies" through the services server.
Turns out this second issue is much bigger than the first one and WebSockets do not solve this. So I decided to build a scheduler that make sure that all mint communication happens as frequent as possible, but never to frequent. This module also solves the first issue, as it allows to queue polling tasks in a lower priority making sure the service stays up to date about payment activity.
If the server restarts it wont hit the mint with a gazillion subs at once, it will make sure they are evenly spread out through low priority calls, while always making sure there is "rate" left for calls that need to be instant.
I built this module externally, so theoretically I could publish it as npm package for structured and timed mint communication. Please let me know if you could use something like this (because as of right now I don't think most Cashu applications would benefit from this, npub.cash is not your usual Cashu application).
After doing some testing I think it is ready to put into an experimental version of npub.cash. I hope to release this on reckless-npub.cash by the end of the week.
