-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rpc-api: scheduler status flag in session #1307
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
I like the non-invasive approach of adding a flag, this way we don't risk any regressions by removing or modifying the existing flags.
Looks good to me ✅
My 2 sats: I can see that this desire to query what is currently happening, could arise out of the situation that client-side code is either starting or restarting, not knowing the current state of the If (I see the existing (It's probably orthogonal but - are we not using websockets at all? I put that in because I felt it was essential so that you could get pushed updates immediately without having to poll - |
That seems like a reasonable and nice solution. Is it rather straightforward to add the schedule to the response without, for example, including a schedule that is present but not currently running? |
Sure I can do that!
Good point we are using them and we should add something there as well. I did not think about that -- thanks for bringing it up. The socket currently sends a
@AdamISZ would you prefer adding a new
@theborakompanioni good point, we can't just rely on the existence of the schedule file. That is present even after a schedule completed successfully. Like in the current implementation, what we would need to do is something like: if self.coinjoin_state == CJ_TAKER_RUNNING and self.tumbler_options is not None:
# include schedule |
@dnlggr Seeing that |
Yes definitely! I think I've addressed all feedback. |
Thanks @dnlggr . So a couple of things I see: first, to get the current schedule, I think you'd better check the value of Next, is the entry in the yaml only a single array instead of an array of arrays? |
Applied your suggestions @AdamISZ. As you said, communicating schedule changes via the websocket would be good as well. However, I'd prefer doing this another time in a separate PR to keep changes small and incremental. |
This setup looks correct to me. I did briefly wonder about I'll try to run some brief sanity check test, but assuming that passes, I'm happy to merge unless someone objects. |
OK, using curl I have tested successfully that this functions as intended:
tACK, merging. |
This adds an additional status flag to the
/session
endpoint that allows consumers of the API to differentiate whether a currently running coinjoin is part of a schedule of coinjoins or if it is a "single coinjoin".Behavior
Single CJ:
coinjoin_in_process
:true
coinjoin_is_part_of_schedule
:false
Schedule of CJs:
coinjoin_in_process
:true
coinjoin_is_part_of_schedule
:true
Reasoning
I'm aware that fundamentally there's no difference between a CJ that's part of a schedule or a single CJ. They're both just instantiating the
Taker
who takes care of the appropriate logic.Still for no other reasons than UI, it can be important to be able to differentiate the two on the client side.
In Jam, for example, we have one flow that takes care of running a schedule of transactions and another for making single collaborative transactions (aka "single CJs").
While a schedule is running, we'd like to indicate that in the UI in a way so that the user knows that the current transaction is not just a single CJ.
That's were a flag like this comes in handy.
We could of course try to retrieve the schedule via
GET /taker/schedule
and depending on the response determine if a schedule is setup to run. But this would be a rather clumsy approach.Implementation
I decided to keep the semantics of the existing
coinjoin_in_process
intact and add an additional flag that further qualifies whether the CJ is part of a larger schedule of CJs.Another way to do this would've been to introduce two distinct flags: one
single_coinjoin_in_process
and the otherschedule_in_process
. But this would have suggested that there are different types of CJs which is not really true as discussed above. Also, it would've technically been a breaking change. Therefore, I decided to go with the slightly less obvious, but probably more correct way.Let me know what you think! Any feedback welcome. If we could get that in, it would help us a lot making the UI for Jam more intuitive.