mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-21 23:16:49 +00:00
* Config: Version Management * Engine: Improve visibility of TestConfigAllJsonResponse failures * Config: Update cmd/config to allow upgrades * Config: Add Version2 to rename GDAX * Config: Restructure versioning to share types This restructure allows us to share types between versions, avoids needing to import the versions, and puts the test fixtures in same package. It's a win on all fronts * Config: Fix SetNTPCheck using log Called from engine before logger is inited, and also just wrong to use log to communicate with user * Config: Improve TestMigrateConfig * Config: Drop requirement for versions to be registered in sequence Checking the versions at Deploy is much saner. * Config: Fix file encrypted but flag not set * Config: Add -edit and encryption upgrade to cmd/config This simplifies the handling for encryption prompts by moving it to a field on config, allowing us to simplify all the places were were passing around config Also moves password entry to being secure (echo-off) * Tests: Fix inconsistent should/must assertions
39 lines
1010 B
Go
39 lines
1010 B
Go
package versions
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/buger/jsonparser"
|
|
)
|
|
|
|
// Version2 is an ExchangeVersion to change the name of GDAX to CoinbasePro
|
|
type Version2 struct{}
|
|
|
|
func init() {
|
|
Manager.registerVersion(2, &Version2{})
|
|
}
|
|
|
|
const (
|
|
from = "GDAX"
|
|
to = "CoinbasePro"
|
|
)
|
|
|
|
// Exchanges returns just GDAX and CoinbasePro
|
|
func (v *Version2) Exchanges() []string { return []string{from, to} }
|
|
|
|
// UpgradeExchange will change the exchange name from GDAX to CoinbasePro
|
|
func (v *Version2) UpgradeExchange(_ context.Context, e []byte) ([]byte, error) {
|
|
if n, err := jsonparser.GetString(e, "name"); err == nil && n == from {
|
|
return jsonparser.Set(e, []byte(`"`+to+`"`), "name")
|
|
}
|
|
return e, nil
|
|
}
|
|
|
|
// DowngradeExchange will change the exchange name from CoinbasePro to GDAX
|
|
func (v *Version2) DowngradeExchange(_ context.Context, e []byte) ([]byte, error) {
|
|
if n, err := jsonparser.GetString(e, "name"); err == nil && n == to {
|
|
return jsonparser.Set(e, []byte(`"`+from+`"`), "name")
|
|
}
|
|
return e, nil
|
|
}
|