rpcserver/exchanges: Add additional param checks plus other minor bugfixes/improvements (#652)

* deleting the unwanted file created during testing + adding more verbose errors for cli

* wip

* checking params throughout wip

* improving errors

* wip

* thrasher patch

* better err name

* whip

* testing and fixing errors WIP

* upgrades and better errors

* broken test

* wip

* adding some tests

* using tempDir

* mini improvement

* little changes

* better time check

* fixing error

* more glorious changes

* end of day wip

* shazzy changes

* checking error

* appveyor

* last changes:
This commit is contained in:
Adam
2021-03-30 13:40:01 +11:00
committed by GitHub
parent 2855e68bac
commit 08f1b5d5d3
13 changed files with 457 additions and 283 deletions

View File

@@ -232,7 +232,7 @@ func TestUpdateTicker(t *testing.T) {
t.Fatal(err)
}
cp = currency.NewPair(currency.DASH, currency.KRW)
cp = currency.NewPair(currency.BTC, currency.KRW)
_, err = b.UpdateTicker(cp, asset.Spot)
if err != nil {
t.Fatal(err)

View File

@@ -58,7 +58,7 @@ var (
// order size, order pricing, total notional values, total maximum orders etc
// for execution on an exchange.
type ExecutionLimits struct {
m map[asset.Item]map[currency.Code]map[currency.Code]*Limits
m map[asset.Item]map[*currency.Item]map[*currency.Item]*Limits
mtx sync.RWMutex
}
@@ -94,26 +94,26 @@ func (e *ExecutionLimits) LoadLimits(levels []MinMaxLevel) error {
e.mtx.Lock()
defer e.mtx.Unlock()
if e.m == nil {
e.m = make(map[asset.Item]map[currency.Code]map[currency.Code]*Limits)
e.m = make(map[asset.Item]map[*currency.Item]map[*currency.Item]*Limits)
}
for x := range levels {
m1, ok := e.m[levels[x].Asset]
if !ok {
m1 = make(map[currency.Code]map[currency.Code]*Limits)
m1 = make(map[*currency.Item]map[*currency.Item]*Limits)
e.m[levels[x].Asset] = m1
}
m2, ok := m1[levels[x].Pair.Base]
m2, ok := m1[levels[x].Pair.Base.Item]
if !ok {
m2 = make(map[currency.Code]*Limits)
m1[levels[x].Pair.Base] = m2
m2 = make(map[*currency.Item]*Limits)
m1[levels[x].Pair.Base.Item] = m2
}
limit, ok := m2[levels[x].Pair.Quote]
limit, ok := m2[levels[x].Pair.Quote.Item]
if !ok {
limit = new(Limits)
m2[levels[x].Pair.Quote] = limit
m2[levels[x].Pair.Quote.Item] = limit
}
if levels[x].MinPrice > levels[x].MaxPrice {
@@ -169,12 +169,12 @@ func (e *ExecutionLimits) GetOrderExecutionLimits(a asset.Item, cp currency.Pair
return nil, errExchangeLimitAsset
}
m2, ok := m1[cp.Base]
m2, ok := m1[cp.Base.Item]
if !ok {
return nil, errExchangeLimitBase
}
limit, ok := m2[cp.Quote]
limit, ok := m2[cp.Quote.Item]
if !ok {
return nil, errExchangeLimitQuote
}
@@ -198,12 +198,12 @@ func (e *ExecutionLimits) CheckOrderExecutionLimits(a asset.Item, cp currency.Pa
return errCannotValidateAsset
}
m2, ok := m1[cp.Base]
m2, ok := m1[cp.Base.Item]
if !ok {
return errCannotValidateBaseCurrency
}
limit, ok := m2[cp.Quote]
limit, ok := m2[cp.Quote.Item]
if !ok {
return errCannotValidateQuoteCurrency
}