mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
currency/manager: remove deadlock potential in concurrent operations (#1545)
* currency/manager: remove deadlock potential in concurrent operations * fix kucoin test, lets see what this does shalllllll weeeeee. * another fix in the deep dark depths --------- Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
This commit is contained in:
@@ -189,7 +189,7 @@ func (p *PairsManager) GetFormat(a asset.Item, request bool) (PairFormat, error)
|
||||
pFmt = p.ConfigFormat
|
||||
}
|
||||
} else {
|
||||
ps, err := p.Get(a)
|
||||
ps, err := p.getPairStoreRequiresLock(a)
|
||||
if err != nil {
|
||||
return EMPTYFORMAT, err
|
||||
}
|
||||
@@ -471,7 +471,7 @@ func (p *PairsManager) getPairStoreRequiresLock(a asset.Item) (*PairStore, error
|
||||
|
||||
pairStore, ok := p.Pairs[a]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("%w %v", ErrAssetNotFound, a)
|
||||
return nil, fmt.Errorf("%w %w %v", ErrAssetNotFound, asset.ErrNotSupported, a)
|
||||
}
|
||||
|
||||
if pairStore == nil {
|
||||
|
||||
@@ -700,7 +700,13 @@ func TestGetFeatures(t *testing.T) {
|
||||
func TestGetPairFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
_, err := new(Base).GetPairFormat(asset.Spot, true)
|
||||
b := new(Base)
|
||||
_, err := b.GetPairFormat(asset.Spot, true)
|
||||
require.ErrorIs(t, err, currency.ErrPairManagerNotInitialised)
|
||||
b.CurrencyPairs = currency.PairsManager{
|
||||
Pairs: make(currency.FullStore),
|
||||
}
|
||||
_, err = b.GetPairFormat(asset.Spot, true)
|
||||
require.ErrorIs(t, err, asset.ErrNotSupported, "Must delegate to GetFormat and error")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user