-
Notifications
You must be signed in to change notification settings - Fork 92
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: match status resolution #704
Conversation
c701f0e
to
8d8d353
Compare
With your next commit, please rebase away c701f0e since that's in |
33deee8
to
3902a61
Compare
@@ -804,15 +808,15 @@ func (t *trackedTrade) shouldBeginFindRedemption(match *matchTracker) bool { | |||
} | |||
|
|||
// tick will check for and perform any match actions necessary. | |||
func (t *trackedTrade) tick() (assetMap, error) { | |||
func (c *Core) tick(t *trackedTrade) (assetMap, error) { |
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.
I've elevated a handful of methods to *Core
methods. I didn't move them, because it would make the diff ridiculous, but I'll do some re-arranging in another PR.
I guess I did move runMatches
though. My bad.
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.
The main reason being that the finalize*
functions now require calling (*Core).resolveMatchConflicts
and on to one of the conflictResolvers
? I'm prying because each one of the conflictResolvers
seems to have the *Core
input argument unused. I replaced (c *Core...
with (_ *Core...
on each one and there were no compilation issues. Perhaps the type matchConflictResolver func(*Core, *dexConnection, *trackedTrade, *matchTracker, *msgjson.MatchStatusResult)
can be redefined without a *Core
?
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.
The main reason being that the finalize* functions now require calling (*Core).resolveMatchConflicts and on to one of the conflictResolvers?
Yep.
Perhaps the type matchConflictResolver func(*Core, *dexConnection, *trackedTrade, *matchTracker, *msgjson.MatchStatusResult) can be redefined without a *Core
Yes to that too.
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.
Doesn't this mean that redefining the receiver isn't necessary any more, noting that c.notify is replaceable because the notify function is in the trackedTrades too? Really though, I have no objection to the change. Just want to understand the considerations.
var msgErr *msgjson.Error | ||
if errors.As(err, &msgErr) && msgErr.Code == msgjson.SettlementSequenceError { | ||
// Try resolving the match status conflict. | ||
go c.resolveMatchConflicts(t.dc, []*matchStatusConflict{{ | ||
trade: t, | ||
match: match, | ||
}}) | ||
} |
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.
I actually don't think that we're likely to recover from this, so the call to resolveMatchConflicts
is sort of a hail mary last ditch attempt to try to make sense of the situation.
PR #677 is in |
69bec54
to
dbf3eba
Compare
@@ -804,15 +808,15 @@ func (t *trackedTrade) shouldBeginFindRedemption(match *matchTracker) bool { | |||
} | |||
|
|||
// tick will check for and perform any match actions necessary. | |||
func (t *trackedTrade) tick() (assetMap, error) { | |||
func (c *Core) tick(t *trackedTrade) (assetMap, error) { |
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.
The main reason being that the finalize*
functions now require calling (*Core).resolveMatchConflicts
and on to one of the conflictResolvers
? I'm prying because each one of the conflictResolvers
seems to have the *Core
input argument unused. I replaced (c *Core...
with (_ *Core...
on each one and there were no compilation issues. Perhaps the type matchConflictResolver func(*Core, *dexConnection, *trackedTrade, *matchTracker, *msgjson.MatchStatusResult)
can be redefined without a *Core
?
459a742
to
139c7fb
Compare
a4cc239
to
f4cd8a5
Compare
1. Match status resolution is run on startup and reconnects for any status mismatches observed when comparing the `connect` result with our local state. 2. Client will now begin negotiation based on the extra matches in the connect response. 3. Differentiate between server-initiated revocations and client-initiated revocations. Required a database upgrade. - Log error and issue notification for active orders reported by DEX that are unknown to the client. - Update order statuses where server-reported statuses are different from statuses recorded by client. - Set statuses to Executed, Canceled or Revoked for orders considered active by the client but not returned by the DEX in the connect response.
f4cd8a5
to
5f8f43e
Compare
Implement match status resolution.
connect
result with our local state.