Skip to content
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

core: Ensure login in core.resendPendingRequests #2633

Merged
merged 4 commits into from
Jan 11, 2024

Conversation

ukane-philemon
Copy link
Contributor

This PR handles an edge case that causes a match init request to be sent before connecting to the server : See: #2617 (comment)
Closes: #2617

@ukane-philemon ukane-philemon changed the title Connect to DEX servers before resuming trades core: Connect to DEX servers before resuming trades Dec 16, 2023
Comment on lines 4743 to 4746
c.notify(newLoginNote("Resuming active trades..."))
c.resolveActiveTrades(crypter)
c.notify(newLoginNote("Connecting to DEX servers..."))
c.initializeDEXConnections(crypter)
c.notify(newLoginNote("Resuming active trades..."))
c.resolveActiveTrades(crypter)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems dangerous. What if the DEX server sends info about an active trade that we haven't loaded from the database yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, then a better resolution to this would be to check if we are logged in? #2617 (comment), but we can just log a msg and not exit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah maybe.

@ukane-philemon ukane-philemon changed the title core: Connect to DEX servers before resuming trades core: Ensure login in core.resendPendingRequests Dec 18, 2023
Signed-off-by: Philemon Ukane <[email protected]>
@@ -2086,7 +2086,7 @@ func (c *Core) tick(t *trackedTrade) (assetMap, error) {
// This method modifies match fields and MUST be called with the trackedTrade
// mutex lock held for reads.
func (c *Core) resendPendingRequests(t *trackedTrade) {
if t.isSelfGoverned() {
if t.isSelfGoverned() || !c.loggedIn /* we can't send `init` or `redeem` if we are not logged in */ {
Copy link
Contributor Author

@ukane-philemon ukane-philemon Dec 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to log a message, just move on. It's not going to be helpful to the user and we know this can happen.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log debug maybe?

Also I think c.loginMtx should be held.

Signed-off-by: Philemon Ukane <[email protected]>
@buck54321 buck54321 merged commit df94dbe into decred:master Jan 11, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

login: Reporting init can happen before connecting to dex server.
4 participants