diff --git a/client/core/bookie.go b/client/core/bookie.go index d1bc0845e6..541b15848a 100644 --- a/client/core/bookie.go +++ b/client/core/bookie.go @@ -184,13 +184,16 @@ func (b *bookie) logEpochReport(note *msgjson.EpochReportNote) error { marketID := marketName(b.base, b.quote) matchSummaries := b.AddRecentMatches(note.MatchSummary, note.EndStamp) - if len(note.MatchSummary) > 0 { - b.send(&BookUpdate{ - Action: EpochMatchSummary, - MarketID: marketID, - Payload: matchSummaries, - }) - } + + b.send(&BookUpdate{ + Action: EpochMatchSummary, + MarketID: marketID, + Payload: &EpochMatchSummaryPayload{ + MatchSummaries: matchSummaries, + Epoch: note.Epoch, + }, + }) + for durStr, cache := range b.candleCaches { c, ok := cache.addCandle(¬e.Candle) if !ok { diff --git a/client/core/core_test.go b/client/core/core_test.go index 17d57b4515..ef4c00623d 100644 --- a/client/core/core_test.go +++ b/client/core/core_test.go @@ -1500,6 +1500,7 @@ func TestBookFeed(t *testing.T) { dc := rig.dc checkAction := func(feed BookFeed, action string) { + t.Helper() select { case u := <-feed.Next(): if u.Action != action { @@ -1728,6 +1729,8 @@ func TestBookFeed(t *testing.T) { t.Fatalf("handleEpochReportMsg error: %v", err) } + checkAction(feed2, EpochMatchSummary) + // We'll only receive 1 candle update, since we only synced one set of // candles so far. checkAction(feed2, CandleUpdateAction) @@ -1743,6 +1746,7 @@ func TestBookFeed(t *testing.T) { if err := handleEpochReportMsg(tCore, dc, epochReport); err != nil { t.Fatalf("handleEpochReportMsg error: %v", err) } + checkAction(feed2, EpochMatchSummary) checkAction(feed2, CandleUpdateAction) checkAction(feed2, CandleUpdateAction) diff --git a/client/core/types.go b/client/core/types.go index 102b56798b..9fa94d278f 100644 --- a/client/core/types.go +++ b/client/core/types.go @@ -743,6 +743,11 @@ type CandlesPayload struct { Candles []msgjson.Candle `json:"candles"` } +type EpochMatchSummaryPayload struct { + MatchSummaries []*orderbook.MatchSummary `json:"matchSummaries"` + Epoch uint64 `json:"epoch"` +} + // dexAccount is the core type to represent the client's account information for // a DEX. type dexAccount struct { diff --git a/client/mm/mm_basic.go b/client/mm/mm_basic.go index 249128c6e0..0869a664df 100644 --- a/client/mm/mm_basic.go +++ b/client/mm/mm_basic.go @@ -716,8 +716,6 @@ func (m *basicMarketMaker) handleNotification(note core.Notification) { return } m.processTrade(ord) - case *core.EpochNotification: - go m.rebalance(n.Epoch) case *core.FiatRatesNote: go m.processFiatRates(n.FiatRates) } @@ -803,11 +801,11 @@ func (m *basicMarketMaker) run() { defer wg.Done() for { select { - case <-bookFeed.Next(): - // Really nothing to do with the updates. We just need to keep - // the subscription live in order to get a mid-gap rate when - // needed. We could use this to trigger rebalances mid-epoch - // though, which I think would provide some advantage. + case n := <-bookFeed.Next(): + if n.Action == core.EpochMatchSummary { + payload := n.Payload.(*core.EpochMatchSummaryPayload) + m.rebalance(payload.Epoch + 1) + } case <-m.ctx.Done(): return } diff --git a/client/webserver/site/src/html/bodybuilder.tmpl b/client/webserver/site/src/html/bodybuilder.tmpl index 0726783d84..ea413e7cc6 100644 --- a/client/webserver/site/src/html/bodybuilder.tmpl +++ b/client/webserver/site/src/html/bodybuilder.tmpl @@ -103,7 +103,7 @@ {{end}} {{define "bottom"}} - + {{end}} diff --git a/client/webserver/site/src/js/markets.ts b/client/webserver/site/src/js/markets.ts index c43cbae2da..46b5703c0d 100644 --- a/client/webserver/site/src/js/markets.ts +++ b/client/webserver/site/src/js/markets.ts @@ -1812,7 +1812,7 @@ export default class MarketsPage extends BasePage { } handleEpochMatchSummary (data: BookUpdate) { - this.addRecentMatches(data.payload) + this.addRecentMatches(data.payload.matchSummaries) this.refreshRecentMatchesTable() }