-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix issue with offers getting disabled for no apparent reason #6342
Conversation
This code change would work, but what I'm not getting right now is, why the remove is not working. It is the same object (in memory pointer) that is in the set and also the same in-memory object passed in the remove handler. It is not found in the set when looking with |
Something must be different, as I can add it again only once. So something must have changed the hash which I haven't found yet. |
Even the |
@ripcurlx I had the same question when trying to debug this code but after a while I stopped investigating when I figured I could just bypass this problem with the given solution. After examining the code and running some tests again, I think that the point of failure is the offer's
OpenOffer excludes from |
When I say to "bypass this problem" I don't mean this in a lazy way... |
ah - I missed that the hashcode is generated and used internally in the HashMap during adding and the referenced object is not immutable. I hate this mutable stuff. I'll merge it the way you implemented it. |
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.
ACK - Tested it locally on Regtest. Works as expected. 👍
@Android-X13 Your last commit is not signed. |
123bd51
to
654259e
Compare
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.
ACK - again because of force push
See comments by Droidus (me) in this forum thread.
Steps to reproduce:
Create an offer (suppose that current market price is 20.000$)
Set a price trigger (say, 20.200$) and confirm
Change your mind and re-edit the offer, set a different price trigger (say, 21.000$) and confirm
You now unknowingly have two trigger prices waiting in a queue instead of one, and the first to be triggered is not the last one that you've set. If you wait a while and assuming the market price will go up, your offer will be "disabled" way before the market price reaches 21.000$ and will leave you wondering why that has happened.
I put "disabled" inside quotes because the offer is not exactly getting disabled but is definitely thrown off the offerbook, and the log states the following:
However if you go to PORTFOLIO > OPEN OFFERS you will see that the offer is still "enabled", but the only way to really bring it back is by manually disabling and re-enabling it (assuming the market price has not yet reached the next in line price trigger).
If you keep editing the price trigger then your offer will keep getting randomly deactivated for no apparent reason at all. This is a real life scenario and a very frustrating one by the way because it was happening to my own offers lately (as the market price was fluctuating I kept changing the price trigger but without realizing what was happening under the hood, so I ended up with problematic offers that couldn't stay up for long).
set.remove
does not work in this case,onRemovedOpenOffers
method does nothing andopenOffersByCurrency
keeps getting larger after every modification of an open offer. So whenonPriceFeedChanged
is triggered it iterates through allopenOffersByCurrency
and since it finds all the canceled ones as well, a previous trigger price is used instead of the current one.Tested live (I haven't setup regtest yet)