Open lukechilds opened 6 years ago
maybe you can wait 3 seconds before the first query? you are actually querying it and it is returning all the data it has about the swap
what is happening is that the requestid/quoteid is added to the list of all swaps then as the state changes, files are created and that allows the swapstatus to update the return result.
it seems for the first few seconds there is no new file as I am now adding the requestid/quoteid to the tracking BEFORE it actually starts (to fix the limbo issue). Of course I still need to fully fix the limbo issue, so maybe this is a side effect of that bug.
However, internally what is happening is that there is no info about that swap at all the first couple seconds after it appears on the tracking list. so "swap never started" is technically accurate and I have no way of knowing if it will start in 2.1 seconds or maybe it wont ever start...
this uncertainity is the result of needing the other party to be following the protocol and if they dont, it eventually times out. So we can say that if after 2 minutes it is still in the "swap never started" that it wont ever start.
Maybe it would be more accurate to keep the swap in the pending
object until it's fully started.
It seems like we need more statuses, it's kind of confusing because recentswaps
gives us either pending
or swap
. Insinuating that when it's moved out of pending it's no longer pending.
However when we query swapstatus(requestid, quoteid)
(which we can only do when it's no long er pending) it says the status is finished
. Then back to pending
. Then back to finished
again.
So it seems like two different commands have two different ideas of what pending
means.
Could I propose some more statuses to give us a better idea of what's happening?
A trade should always have one of the following statuses:
matching
swapping
finished
failed
The only possibilities should be:
failed
matching
-> failed
matching
-> swapping
-> failed
matching
-> swapping
-> finished
matching
is as soon as an order is placed (waiting for a match).
swapping
is the duration of the swap.
We can use bobpayment
,alicepayment
,bobdeposit
,myfee
flags to display more accurate progress in the UI while it's in swapping
state.
finished
is when the trade has fully completed.
failed
is when a swap has failed for any reason.
Preferably also combined with a helpful error message e.g: "Unable to match", "Other party cancelled" etc.
I will try to do this, but cant guarantee there wont be some edge cases, especially if you are finding gaps of one second.
Following on from https://github.com/jl777/SuperNET/issues/626
Once a swap moves from
pending
toswaps
inrecentswaps
and gives usrequestid
/quoteid
, if we try to query it it shows invalid data:As soon as the swap is moved out of pending and we can query it it's in a weird state for 2.1 seconds. There is an error saying it never started but the status is set to
finished
which is confusing. After 2.1 seconds it starts it's normalpending
status.I think the correct behaviour should be that as soon the trade has moved from
pending
toswaps
in theswapstatus
output so we can query it, it should be set aspending
.