mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-14 02:53:50 +00:00
binance: save newer events for later usage
This commit is contained in:
parent
2fddc9166f
commit
e95429bbc3
|
@ -72,9 +72,9 @@ func (f *DepthFrame) loadDepthSnapshot() {
|
||||||
// if the head event is newer than the depth we got,
|
// if the head event is newer than the depth we got,
|
||||||
// then there are something missed, we need to restart the process.
|
// then there are something missed, we need to restart the process.
|
||||||
if len(events) > 0 {
|
if len(events) > 0 {
|
||||||
e := events[0]
|
firstEvent := events[0]
|
||||||
if e.FirstUpdateID > depth.FinalUpdateID+1 {
|
if firstEvent.FirstUpdateID > depth.FinalUpdateID+1 {
|
||||||
log.Warn("miss matched final update id for order book")
|
log.Warn("miss matched final update id for order book, resetting depth...")
|
||||||
f.SnapshotDepth = nil
|
f.SnapshotDepth = nil
|
||||||
f.BufEvents = nil
|
f.BufEvents = nil
|
||||||
f.mu.Unlock()
|
f.mu.Unlock()
|
||||||
|
@ -138,6 +138,9 @@ func (f *DepthFrame) PushEvent(e DepthEvent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
f.SnapshotDepth = nil
|
f.SnapshotDepth = nil
|
||||||
|
|
||||||
|
// save the new event for later
|
||||||
|
f.BufEvents = append(f.BufEvents, e)
|
||||||
f.mu.Unlock()
|
f.mu.Unlock()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user