SuperNET icon indicating copy to clipboard operation
SuperNET copied to clipboard

What does the output of the cancel command mean.

Open lukechilds opened this issue 7 years ago • 4 comments

Related: https://github.com/lukechilds/hyperdex/issues/129

We're trying to add a cancel button to allow users to panic cancel incorrect trades.

If the trade hasn't been matched yet it normally works fine and we get:

{result: "success", numentries: 1, status: "uuid canceled"}

And a failed message is sent over the socket so we can correctly update our UI.


If we cancel as soon as it's been matched but before any TXs have been sent we get:

{result: "success", numentries: 1, status: "will stop trade negotiation, but if swap started it wont cancel"}

The swap never normally cancels at this point. Should it? When is a swap considered "started"? After being matched or after the first TX.

And what does stopping trade negotiation mean? Is there any way for us to check if the negotiation has been stopped so we can update the UI and say it's no longer pending/matched? Should we get a failed event over the socket in this scenario if the negotiation is stopped?


Cancelling again right after the first TX has been sent will return:

{result: "success", numentries: 0, status: "will stop trade negotiation, but if swap started it wont cancel"}

(same response but numentries is now 0)

What is numentries referring to? Whether or not the swap has already started?


I understand swaps shouldn't and won't be cancelled after they've started. But I'm not sure exactly when that is. We need a way to reliably determine from the response whether the swap will continue or be stopped so we can update the UI to notify the user.

lukechilds avatar May 17 '18 11:05 lukechilds

there are internal entries for a swap in progress. there can be more than one, ie. request, reserved, connect, connected.

so if numentries is 0, then it is likely already moved onto a DB/SWAPS swap if it is 1, then very good that it was stopped

all this is very edge casey... to be sure the swap status needs to be issued to see what the swapstatus is

jl777 avatar May 17 '18 11:05 jl777

all this is very edge casey... to be sure the swap status needs to be issued to see what the swapstatus is

Can we also rely on socket messages or would that be subject to edgecases too and we should fall back to swapstatus?

if it is 1, then very good that it was stopped

But it only does that before it's matched (connected message), after that but before the first TX numentries is still 1. Should this be cancellable or not?

lukechilds avatar May 17 '18 11:05 lukechilds

it is unpredictable. it is doing the best it can to stop the swap. i think the best way is to do a swapstatus and make sure it doesnt advance. lack of activity is the only proof that the swap is stopped

jl777 avatar May 17 '18 12:05 jl777

Ok, thanks.

lukechilds avatar May 17 '18 12:05 lukechilds