Skip to content

Commit

Permalink
remove core.ActiveOrder
Browse files Browse the repository at this point in the history
core.ActiveOrders was useful until now. The current consumer (cryptopower) now prefers
core.Active as they don't need much info anymore and it won't be nice to leave unused
methods.

Signed-off-by: Philemon Ukane <ukanephilemon@gmail.com>
  • Loading branch information
ukane-philemon committed Nov 19, 2024
1 parent 0dfaf4c commit 95f13fb
Showing 1 changed file with 0 additions and 52 deletions.
52 changes: 0 additions & 52 deletions client/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,26 +580,6 @@ func (dc *dexConnection) hasActiveOrders() bool {
return false
}

// activeOrders returns a slice of active orders and inflight orders.
func (dc *dexConnection) activeOrders() ([]*Order, []*InFlightOrder) {
dc.tradeMtx.RLock()
defer dc.tradeMtx.RUnlock()

var activeOrders []*Order
for _, trade := range dc.trades {
if trade.isActive() {
activeOrders = append(activeOrders, trade.coreOrder())
}
}

var inflightOrders []*InFlightOrder
for _, ord := range dc.inFlightOrders {
inflightOrders = append(inflightOrders, ord)
}

return activeOrders, inflightOrders
}

// findOrder returns the tracker and preimage for an order ID, and a boolean
// indicating whether this is a cancel order.
func (dc *dexConnection) findOrder(oid order.OrderID) (tracker *trackedTrade, isCancel bool) {
Expand Down Expand Up @@ -4816,38 +4796,6 @@ func (c *Core) initializePrimaryCredentials(pw []byte, oldKeyParams []byte) erro
return nil
}

// ActiveOrders returns a map of host to all of their active orders from db if
// core is not yet logged in or from loaded trades map if core is logged in.
// Inflight orders are also returned for all dex servers if any.
func (c *Core) ActiveOrders() (map[string][]*Order, map[string][]*InFlightOrder, error) {
c.loginMtx.Lock()
loggedIn := c.loggedIn
c.loginMtx.Unlock()

dexInflightOrders := make(map[string][]*InFlightOrder)
dexActiveOrders := make(map[string][]*Order)
for _, dc := range c.dexConnections() {
if loggedIn {
orders, inflight := dc.activeOrders()
dexActiveOrders[dc.acct.host] = append(dexActiveOrders[dc.acct.host], orders...)
dexInflightOrders[dc.acct.host] = append(dexInflightOrders[dc.acct.host], inflight...)
continue
}

// Not logged in, load from db orders.
ords, err := c.dbOrders(dc.acct.host)
if err != nil {
return nil, nil, err
}

for _, ord := range ords {
dexActiveOrders[dc.acct.host] = append(dexActiveOrders[dc.acct.host], coreOrderFromTrade(ord.Order, ord.MetaData))
}
}

return dexActiveOrders, dexInflightOrders, nil
}

// Active indicates if there are any active orders across all configured
// accounts. This includes booked orders and trades that are settling.
func (c *Core) Active() bool {
Expand Down

0 comments on commit 95f13fb

Please sign in to comment.