mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
linters: Add modernise tool check and fix issues (#2012)
* linters: Add modernise tool check and fix issues * engine: Simplify exch.SetDefaults call and remove localWG * CI: Revert config versions lint workflow
This commit is contained in:
@@ -703,9 +703,7 @@ func (o *orderbookManager) setNeedsFetchingBook(pair currency.Pair) error {
|
||||
// SynchroniseWebsocketOrderbook synchronises full orderbook for currency pair
|
||||
// asset
|
||||
func (e *Exchange) SynchroniseWebsocketOrderbook(ctx context.Context) {
|
||||
e.Websocket.Wg.Add(1)
|
||||
go func() {
|
||||
defer e.Websocket.Wg.Done()
|
||||
e.Websocket.Wg.Go(func() {
|
||||
for {
|
||||
select {
|
||||
case <-e.Websocket.ShutdownC:
|
||||
@@ -717,15 +715,12 @@ func (e *Exchange) SynchroniseWebsocketOrderbook(ctx context.Context) {
|
||||
}
|
||||
}
|
||||
case j := <-e.obm.jobs:
|
||||
err := e.processJob(ctx, j.Pair)
|
||||
if err != nil {
|
||||
log.Errorf(log.WebsocketMgr,
|
||||
"%s processing websocket orderbook error %v",
|
||||
e.Name, err)
|
||||
if err := e.processJob(ctx, j.Pair); err != nil {
|
||||
log.Errorf(log.WebsocketMgr, "%s processing websocket orderbook error: %v", e.Name, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
})
|
||||
}
|
||||
|
||||
// processJob fetches and processes orderbook updates
|
||||
|
||||
@@ -632,9 +632,7 @@ func (e *Exchange) setupOrderbookManager(ctx context.Context) {
|
||||
|
||||
// SynchroniseWebsocketOrderbook synchronises full orderbook for currency pair asset
|
||||
func (e *Exchange) SynchroniseWebsocketOrderbook(ctx context.Context) {
|
||||
e.Websocket.Wg.Add(1)
|
||||
go func() {
|
||||
defer e.Websocket.Wg.Done()
|
||||
e.Websocket.Wg.Go(func() {
|
||||
for {
|
||||
select {
|
||||
case <-e.Websocket.ShutdownC:
|
||||
@@ -646,15 +644,12 @@ func (e *Exchange) SynchroniseWebsocketOrderbook(ctx context.Context) {
|
||||
}
|
||||
}
|
||||
case j := <-e.obm.jobs:
|
||||
err := e.processJob(ctx, j.Pair)
|
||||
if err != nil {
|
||||
log.Errorf(log.WebsocketMgr,
|
||||
"%s processing websocket orderbook error %v",
|
||||
e.Name, err)
|
||||
if err := e.processJob(ctx, j.Pair); err != nil {
|
||||
log.Errorf(log.WebsocketMgr, "%s processing websocket orderbook error: %v", e.Name, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
})
|
||||
}
|
||||
|
||||
// ProcessOrderbookUpdate processes the websocket orderbook update
|
||||
|
||||
@@ -105,9 +105,7 @@ func (e *Exchange) applyBufferUpdate(pair currency.Pair) error {
|
||||
// SynchroniseWebsocketOrderbook synchronises full orderbook for currency pair
|
||||
// asset
|
||||
func (e *Exchange) SynchroniseWebsocketOrderbook(ctx context.Context) {
|
||||
e.Websocket.Wg.Add(1)
|
||||
go func() {
|
||||
defer e.Websocket.Wg.Done()
|
||||
e.Websocket.Wg.Go(func() {
|
||||
for {
|
||||
select {
|
||||
case <-e.Websocket.ShutdownC:
|
||||
@@ -119,13 +117,12 @@ func (e *Exchange) SynchroniseWebsocketOrderbook(ctx context.Context) {
|
||||
}
|
||||
}
|
||||
case j := <-e.obm.jobs:
|
||||
err := e.processJob(ctx, j.Pair)
|
||||
if err != nil {
|
||||
log.Errorf(log.WebsocketMgr, "%s processing websocket orderbook error %v", e.Name, err)
|
||||
if err := e.processJob(ctx, j.Pair); err != nil {
|
||||
log.Errorf(log.WebsocketMgr, "%s processing websocket orderbook error: %v", e.Name, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
})
|
||||
}
|
||||
|
||||
// processJob fetches and processes orderbook updates
|
||||
|
||||
@@ -171,7 +171,7 @@ type WebsocketFuturesAmendOrder struct {
|
||||
|
||||
// WebsocketFutureOrdersList defines a websocket future orders list
|
||||
type WebsocketFutureOrdersList struct {
|
||||
Contract currency.Pair `json:"contract,omitempty"`
|
||||
Contract currency.Pair `json:"contract,omitzero"`
|
||||
Asset asset.Item `json:"-"` // Only used internally for routing
|
||||
Status string `json:"status"`
|
||||
Limit int64 `json:"limit,omitempty"`
|
||||
|
||||
@@ -72,10 +72,7 @@ func (e *Exchange) GetFuturesTickers(ctx context.Context) ([]*ticker.Price, erro
|
||||
errC <- err
|
||||
break
|
||||
}
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
wg.Go(func() {
|
||||
if tick, err2 := e.GetFuturesTicker(ctx, p.String()); err2 != nil {
|
||||
errC <- err2
|
||||
} else {
|
||||
@@ -92,7 +89,7 @@ func (e *Exchange) GetFuturesTickers(ctx context.Context) ([]*ticker.Price, erro
|
||||
AssetType: asset.Futures,
|
||||
}
|
||||
}
|
||||
}()
|
||||
})
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
|
||||
@@ -1248,9 +1248,7 @@ func (o *orderbookManager) setNeedsFetchingBook(pair currency.Pair, assetType as
|
||||
// SynchroniseWebsocketOrderbook synchronises full orderbook for currency pair
|
||||
// asset
|
||||
func (e *Exchange) SynchroniseWebsocketOrderbook(ctx context.Context) {
|
||||
e.Websocket.Wg.Add(1)
|
||||
go func() {
|
||||
defer e.Websocket.Wg.Done()
|
||||
e.Websocket.Wg.Go(func() {
|
||||
for {
|
||||
select {
|
||||
case <-e.Websocket.ShutdownC:
|
||||
@@ -1262,15 +1260,12 @@ func (e *Exchange) SynchroniseWebsocketOrderbook(ctx context.Context) {
|
||||
}
|
||||
}
|
||||
case j := <-e.obm.jobs:
|
||||
err := e.processJob(ctx, j.Pair, j.AssetType)
|
||||
if err != nil {
|
||||
log.Errorf(log.WebsocketMgr,
|
||||
"%s processing websocket orderbook error %v",
|
||||
e.Name, err)
|
||||
if err := e.processJob(ctx, j.Pair, j.AssetType); err != nil {
|
||||
log.Errorf(log.WebsocketMgr, "%s processing websocket orderbook error: %v", e.Name, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
})
|
||||
}
|
||||
|
||||
// SeedLocalCache seeds depth data
|
||||
|
||||
@@ -329,8 +329,7 @@ func TestProcessOrderbook(t *testing.T) {
|
||||
break
|
||||
}
|
||||
m.Unlock()
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
wg.Go(func() {
|
||||
newName := "Exchange" + strconv.FormatInt(rand.Int63(), 10) //nolint:gosec // no need to import crypo/rand for testing
|
||||
newPairs := currency.NewPair(currency.NewCode("BTC"+strconv.FormatInt(rand.Int63(), 10)),
|
||||
currency.NewCode("USD"+strconv.FormatInt(rand.Int63(), 10))) //nolint:gosec // no need to import crypo/rand for testing
|
||||
@@ -351,13 +350,11 @@ func TestProcessOrderbook(t *testing.T) {
|
||||
t.Error(err)
|
||||
catastrophicFailure = true
|
||||
m.Unlock()
|
||||
wg.Done()
|
||||
return
|
||||
}
|
||||
testArray = append(testArray, quick{Name: newName, P: newPairs, Bids: bids, Asks: asks})
|
||||
m.Unlock()
|
||||
wg.Done()
|
||||
}()
|
||||
})
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
|
||||
@@ -362,8 +362,7 @@ func TestProcessTicker(t *testing.T) { // non-appending function to tickers
|
||||
break
|
||||
}
|
||||
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
wg.Go(func() {
|
||||
//nolint:gosec // no need to import crypo/rand for testing
|
||||
newName := "Exchange" + strconv.FormatInt(rand.Int63(), 10)
|
||||
newPairs, err := currency.NewPairFromStrings("BTC"+strconv.FormatInt(rand.Int63(), 10), //nolint:gosec // no need to import crypo/rand for testing
|
||||
@@ -389,8 +388,7 @@ func TestProcessTicker(t *testing.T) { // non-appending function to tickers
|
||||
|
||||
testArray = append(testArray, quick{Name: newName, P: newPairs, TP: tp})
|
||||
sm.Unlock()
|
||||
wg.Done()
|
||||
}()
|
||||
})
|
||||
}
|
||||
|
||||
if catastrophicFailure {
|
||||
|
||||
Reference in New Issue
Block a user