mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 15:09:42 +00:00
exchanges: Rename UpdatePushedAt field to LastPushed and use field in gateio REST books (#1917)
* Set update pushed at time and general clean * after merge fix * gk: nits * Update exchanges/gateio/gateio_types.go Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com> * Update exchanges/gateio/gateio_test.go Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com> * boss: nits * sneaky boss attack: nits --------- Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io> Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>
This commit is contained in:
@@ -78,7 +78,7 @@ func (d *Depth) Retrieve() (*Base, error) {
|
||||
Asset: d.asset,
|
||||
Pair: d.pair,
|
||||
LastUpdated: d.lastUpdated,
|
||||
UpdatePushedAt: d.updatePushedAt,
|
||||
LastPushed: d.lastPushed,
|
||||
InsertedAt: d.insertedAt,
|
||||
LastUpdateID: d.lastUpdateID,
|
||||
PriceDuplication: d.priceDuplication,
|
||||
@@ -92,7 +92,7 @@ func (d *Depth) Retrieve() (*Base, error) {
|
||||
}
|
||||
|
||||
// LoadSnapshot flushes the bids and asks with a snapshot
|
||||
func (d *Depth) LoadSnapshot(bids, asks []Tranche, lastUpdateID int64, lastUpdated, updatePushedAt time.Time, updateByREST bool) error {
|
||||
func (d *Depth) LoadSnapshot(bids, asks []Tranche, lastUpdateID int64, lastUpdated, lastPushed time.Time, updateByREST bool) error {
|
||||
d.m.Lock()
|
||||
defer d.m.Unlock()
|
||||
if lastUpdated.IsZero() {
|
||||
@@ -104,7 +104,7 @@ func (d *Depth) LoadSnapshot(bids, asks []Tranche, lastUpdateID int64, lastUpdat
|
||||
}
|
||||
d.lastUpdateID = lastUpdateID
|
||||
d.lastUpdated = lastUpdated
|
||||
d.updatePushedAt = updatePushedAt
|
||||
d.lastPushed = lastPushed
|
||||
d.insertedAt = time.Now()
|
||||
d.restSnapshot = updateByREST
|
||||
d.bidTranches.load(bids)
|
||||
@@ -387,7 +387,7 @@ func (d *Depth) TotalAskAmounts() (liquidity, value float64, err error) {
|
||||
func (d *Depth) updateAndAlert(update *Update) {
|
||||
d.lastUpdateID = update.UpdateID
|
||||
d.lastUpdated = update.UpdateTime
|
||||
d.updatePushedAt = update.UpdatePushedAt
|
||||
d.lastPushed = update.LastPushed
|
||||
d.insertedAt = time.Now()
|
||||
d.Alert()
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ func TestRetrieve(t *testing.T) {
|
||||
pair: currency.NewPair(currency.THETA, currency.USD),
|
||||
asset: asset.DownsideProfitContract,
|
||||
lastUpdated: time.Now(),
|
||||
updatePushedAt: time.Now(),
|
||||
lastPushed: time.Now(),
|
||||
insertedAt: time.Now(),
|
||||
lastUpdateID: 1337,
|
||||
priceDuplication: true,
|
||||
@@ -102,7 +102,7 @@ func TestRetrieve(t *testing.T) {
|
||||
assert.Equal(t, currency.NewPair(currency.THETA, currency.USD), ob.Pair, "Should have correct Pair")
|
||||
assert.Equal(t, asset.DownsideProfitContract, ob.Asset, "Should have correct Asset")
|
||||
assert.Equal(t, d.options.lastUpdated, ob.LastUpdated, "Should have correct LastUpdated")
|
||||
assert.Equal(t, d.options.updatePushedAt, ob.UpdatePushedAt, "Should have correct UpdatePushedAt")
|
||||
assert.Equal(t, d.options.lastPushed, ob.LastPushed, "Should have correct LastPushed")
|
||||
assert.Equal(t, d.options.insertedAt, ob.InsertedAt, "Should have correct InsertedAt")
|
||||
assert.EqualValues(t, 1337, ob.LastUpdateID, "Should have correct LastUpdateID")
|
||||
assert.True(t, ob.PriceDuplication, "Should have correct PriceDuplication")
|
||||
|
||||
@@ -52,7 +52,7 @@ func (s *store) Update(b *Base) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := book.Depth.LoadSnapshot(b.Bids, b.Asks, b.LastUpdateID, b.LastUpdated, b.UpdatePushedAt, true); err != nil {
|
||||
if err := book.Depth.LoadSnapshot(b.Bids, b.Asks, b.LastUpdateID, b.LastUpdated, b.LastPushed, true); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.signalMux.Publish(book.Depth, book.RouterID)
|
||||
|
||||
@@ -94,15 +94,15 @@ type Base struct {
|
||||
// which could be stale if there have been no recent changes.
|
||||
LastUpdated time.Time
|
||||
|
||||
// UpdatePushedAt is the time the exchange pushed this update. This helps
|
||||
// LastPushed is the time the exchange pushed this update. This helps
|
||||
// determine factors like distance from exchange (latency) and routing
|
||||
// time, which can affect the time it takes for an update to reach the user
|
||||
// from the exchange.
|
||||
UpdatePushedAt time.Time
|
||||
LastPushed time.Time
|
||||
|
||||
// InsertedAt is the time the update was inserted into the orderbook
|
||||
// management system. This field is used to calculate round-trip times and
|
||||
// processing delays, e.g., InsertedAt.Sub(UpdatePushedAt) represents the
|
||||
// processing delays, e.g., InsertedAt.Sub(LastPushed) represents the
|
||||
// total processing time including network latency.
|
||||
InsertedAt time.Time
|
||||
|
||||
@@ -136,7 +136,7 @@ type options struct {
|
||||
pair currency.Pair
|
||||
asset asset.Item
|
||||
lastUpdated time.Time
|
||||
updatePushedAt time.Time
|
||||
lastPushed time.Time
|
||||
insertedAt time.Time
|
||||
lastUpdateID int64
|
||||
priceDuplication bool
|
||||
@@ -166,10 +166,10 @@ const (
|
||||
|
||||
// Update and things and stuff
|
||||
type Update struct {
|
||||
UpdateID int64
|
||||
UpdateTime time.Time
|
||||
UpdatePushedAt time.Time
|
||||
Asset asset.Item
|
||||
UpdateID int64
|
||||
UpdateTime time.Time
|
||||
LastPushed time.Time
|
||||
Asset asset.Item
|
||||
Action
|
||||
Bids []Tranche
|
||||
Asks []Tranche
|
||||
|
||||
Reference in New Issue
Block a user