-
Notifications
You must be signed in to change notification settings - Fork 86
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
app: show more details in user orders table #378
Conversation
client/core/core.go
Outdated
// setEpoch sets the epoch. If the passed epoch is greater than the highest | ||
// previously passed epoch, send an epoch notification to all subscribers. | ||
func (dc *dexConnection) setEpoch(mktID string, epochIdx uint64) bool { | ||
dc.epochMtx.Lock() | ||
defer dc.epochMtx.Unlock() | ||
if epochIdx > dc.epoch[mktID] { | ||
dc.epoch[mktID] = epochIdx | ||
dc.notify(newEpochNotification(dc.acct.url, mktID, epochIdx)) | ||
var updateCount int | ||
dc.tradeMtx.Lock() | ||
for _, trade := range dc.trades { | ||
if trade.processEpoch(epochIdx) { | ||
updateCount++ | ||
} | ||
} | ||
dc.tradeMtx.Unlock() | ||
if updateCount > 0 { | ||
dc.refreshMarkets() | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
|
||
// marketEpochDuration gets the market's epoch duration. If the market is not | ||
// known, an error is logged and 0 is returned. | ||
func (dc *dexConnection) marketEpochDuration(mktID string) uint64 { | ||
mkt := dc.market(mktID) | ||
if mkt == nil { | ||
log.Errorf("marketEpoch called for unknown market %s", mktID) | ||
return 0 | ||
} | ||
return mkt.EpochLen | ||
} | ||
|
||
// marketEpoch gets the best known epoch for the specified market and time | ||
// stamp. If the market is not known, 0 is returned. | ||
func (dc *dexConnection) marketEpoch(mktID string, stamp time.Time) uint64 { | ||
epochLen := dc.marketEpochDuration(mktID) | ||
if epochLen == 0 { | ||
return 0 | ||
} | ||
return encode.UnixMilliU(stamp) / epochLen |
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.
client/core/core.go
Outdated
return mkt.EpochLen | ||
} | ||
|
||
// marketEpoch gets the best known epoch for the specified market and time |
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.
"best known epoch" is a bit confusing. Looks like the function returns the epoch index that includes the specified stamp
time.
client/core/trade.go
Outdated
} | ||
|
||
// newTrackedTrade is a constructor for a trackedTrade. | ||
func newTrackedTrade(dbOrder *db.MetaOrder, preImg order.Preimage, dc *dexConnection, | ||
func newTrackedTrade(dbOrder *db.MetaOrder, preImg order.Preimage, dc *dexConnection, mkt *Market, |
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.
Unless you have plans for the *Market
argument, can we just pass epochLen uint64
?
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.
Yeah. I was on the fence with that anyway. At one point I was storing the whole *Market
.
client/core/trade.go
Outdated
// DRAFT NOTE: As of now, if the client is not subscribed to the order book when | ||
// the order actually matches, the status might not be set correctly. This is a | ||
// consequence of having no notifications for orders which either are 1) | ||
// unmatched (market order against empty book, or immediate limit order with | ||
// restrictive rate), or 2) are booked without matching. This also creates the | ||
// odd case that a fully-matched standing limit order may be set to | ||
// OrderStatusBooked before a subsequent match notification might change it | ||
// to OrderStatusExecuted. |
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'm going to remove this draft note. I don't know if this is an issue or not, but I suspect it is. The crux is that the client has no way of knowing for certain that their order was booked if they don't actually receive a match notification (indicating only partial matching), which will often be the case. The client right now is just assuming that their order was booked, because the epoch expired and they haven't heard otherwise.
Got a not-a-conflict to resolve. :) |
Shows additional details in the user orders table. New columns include order type, percent settled, and order status. Additionally, the age column is refreshed every second.
New columns include order type, percent settled, and order status. Additionally, the age column is refreshed every second. Corrects a number of related deficiencies with epoch handling and status updates.
Resolves #297