Skip to content

Commit

Permalink
don't send dex update if we don't have sane value
Browse files Browse the repository at this point in the history
Signed-off-by: Philemon Ukane <ukanephilemon@gmail.com>
  • Loading branch information
ukane-philemon committed Sep 20, 2024
1 parent c665c90 commit 2af39f7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions exchanges/exchanges.go
Original file line number Diff line number Diff line change
Expand Up @@ -2489,9 +2489,8 @@ func (dcr *DecredDEX) Refresh() {
}
}

// Use mid gap if we are yet to get an epoch report notification.
if dcr.lastRate == 0 {
dcr.lastRate = depth.MidGap()
return // no rate, nothing to do.
}

dcr.Update(&ExchangeState{
Expand Down Expand Up @@ -2859,6 +2858,15 @@ func (dcr *DecredDEX) setOrderBook(ob *msgjson.OrderBook) {

depth := dcr.wsDepthSnapshot()

if dcr.lastRate == 0 {
// Use mid gap as a sane default if the orderbook is not empty.
midGap := depth.MidGap()
if midGap == 1 {
return // don't send rate update if we don't have a valid rate.
}
dcr.lastRate = midGap
}

dcr.Update(&ExchangeState{
BaseState: BaseState{
Price: dcr.lastRate,
Expand Down

0 comments on commit 2af39f7

Please sign in to comment.