Clean up mailbox messages for closed trades #4746
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We got growing pending mailbox messages since 1.4.2. (about 2000 now, normal is about 500). With the trade protocol refactoring a cleanup for mailbox messages has been missed.
Steps to reproduce issue:
Start a trade and let peer go offline. When Seller confirms receipt he sends a msg to buyer, as he is offline its a mailbox msg. Seller moves funds to his wallet and his trade is closed. Buyer goes online and closes his trade as well. He sends back a AckMessage that he received the trade message but as sellers trade is closed that ackMsg is not being processed (done in tradeProtocol class which is not initialized for closed trades).
Solution:
We iterate closed and failed trades and look up if there are some pending mailbox messages and if we find any we remove them from the network.
It can be that there are failure scenarios where mailbox messages did not got removed as well. This should fix those cases as well.