XRPL-Labs / xrpl-client

Connect to the XRP Ledger using WebSockets
https://www.npmjs.com/package/xrpl-client
MIT License
12 stars 8 forks source link

Inactive subscriptions #12

Open elmurci opened 1 year ago

elmurci commented 1 year ago

(Not a bug a such, but a thought I would like to share for discussion)

The library persists a subscriptions array that is helpful in case of connection loss so we can keep the "state".

In some cases, we might want to remove certain entries from the array as they become obsolete.

For example, in the following flow:

  1. Path find create request for A
  2. Path find close request for A
  3. Path find create request for B

Even if A is not longer a path we want to explore, the path_find request gets created and closed (before path find request B) on every reconnection meaning we will receive some path messages for it for a few seconds.

WietseWind commented 1 year ago

I considered this before, indeed, and to keep it simple I left it. But I agree. The best way to deal with this is to "diff" subscriptions and let 2 cancel out 1 if equal. This would be tricky (not impossible) when users e.g. subscribe to certain accounts and then unsubscribe to a part of them.

elmurci commented 1 year ago

Would you like a PR for this?

WietseWind commented 1 year ago

Would you like a PR for this?

Who would say no to that 🎉 PR for an issue/challenge/shortcoming/... is the dream of an open source maintainer :D