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

app: show more details in user orders table #378

Merged
merged 2 commits into from
May 20, 2020

Conversation

buck54321
Copy link
Member

@buck54321 buck54321 commented May 18, 2020

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.

image

Resolves #297

Comment on lines 299 to 334
// 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
Copy link
Member

Choose a reason for hiding this comment

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

@dnldd Note these changes that are likely to be merged shortly, with reference to #269, which as per our matrix chat will likely need to track the active epoch.

return mkt.EpochLen
}

// marketEpoch gets the best known epoch for the specified market and time
Copy link
Member

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.

}

// 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,
Copy link
Member

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?

Copy link
Member Author

@buck54321 buck54321 May 20, 2020

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.

Comment on lines 914 to 921
// 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.
Copy link
Member Author

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.

@chappjc
Copy link
Member

chappjc commented May 20, 2020

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.
@chappjc chappjc merged commit b54979c into decred:master May 20, 2020
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.

app: improve user orders table on markets view
2 participants