Skip to content

Commit

Permalink
cache exchange info
Browse files Browse the repository at this point in the history
Signed-off-by: Philemon Ukane <[email protected]>
  • Loading branch information
ukane-philemon committed Sep 24, 2024
1 parent 7b3143e commit abbac44
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions ui/page/dcrdex/market.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ type DEXMarketPage struct {
serverSelector *cryptomaterial.DropDown
lastSelectedDEXServer string
addServerBtn *cryptomaterial.Clickable
xc *core.Exchange

marketSelector *cryptomaterial.DropDown
noMarketOrServerDisconnected atomic.Bool
Expand Down Expand Up @@ -341,6 +342,7 @@ func (pg *DEXMarketPage) setServerMarkets() {
if err != nil {
pg.notifyError(err.Error())
} else {
pg.xc = xc
serverIsDisconnected = xc.ConnectionStatus != comms.Connected
for _, m := range xc.Markets {
base, quote := convertAssetIDToAssetType(m.BaseID), convertAssetIDToAssetType(m.QuoteID)
Expand Down Expand Up @@ -664,9 +666,8 @@ func (pg *DEXMarketPage) selectedMarketInfo() (mkt *core.Market) {
return
}

xc := pg.exchange()
if xc != nil {
mkt = xc.Markets[dexMarketName]
if pg.xc != nil {
mkt = pg.xc.Markets[dexMarketName]
}

return mkt
Expand All @@ -679,16 +680,6 @@ func (pg *DEXMarketPage) formatSelectedMarketAsDEXMarketName() string {
return dexMarketName
}

func (pg *DEXMarketPage) exchange() *core.Exchange {
host := pg.serverSelector.Selected()
xc, err := pg.AssetsManager.DexClient().Exchange(host)
if err != nil {
pg.notifyError(err.Error())
return nil
}
return xc
}

func (pg *DEXMarketPage) priceAndVolumeColumn(gtx C, title1 string, body1 func(gtx C) D, title2, body2 string) D {
return layout.Flex{Axis: vertical}.Layout(gtx,
layout.Rigid(func(gtx C) D {
Expand Down Expand Up @@ -743,7 +734,7 @@ func (pg *DEXMarketPage) orderForm(gtx C) D {
var overlaySet bool
var overlayMsg string
var actionBtn *cryptomaterial.Button
xc := pg.exchange()
xc := pg.xc
dexClient := pg.AssetsManager.DexClient()
hasZeroEffectiveTier := dexClient.IsLoggedIn() && xc != nil && xc.Auth.EffectiveTier == 0 && xc.Auth.PendingStrength == 0
if !dexClient.IsLoggedIn() {
Expand Down

0 comments on commit abbac44

Please sign in to comment.