mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-09 15:11:10 +00:00
Coinbase: Update exchange implementation (#1480)
* Slight enhance of Coinbase tests Continual enhance of Coinbase tests The revamp continues Oh jeez the Orderbook part's unfinished don't look Coinbase revamp, Orderbook still unfinished * Coinbase revamp; CreateReport is still WIP * More coinbase improvements; onto sandbox testing * Coinbase revamp continues * Coinbase revamp continues * Coinbasepro revamp is ceaseless * Coinbase revamp, starting on advanced trade API * Coinbase Advanced Trade Starts in Ernest V3 done, onto V2 Coinbase revamp nears completion Coinbase revamp nears completion Test commit should fail Coinbase revamp nears completion * Coinbase revamp stage wrapper * Coinbase wrapper coherence continues * Coinbase wrapper continues writhing * Coinbase wrapper & codebase cleanup * Coinbase updates & wrap progress * More Coinbase wrapper progress * Wrapper is wrapped, kinda * Test & type checking * Coinbase REST revamp finished * Post-merge fix * WS revamp begins * WS Main Revamp Done? * CB websocket tidying up * Coinbase WS wrapperupperer * Coinbase revamp done?? * Linter progress * Continued lint cleanup * Further lint cleanup * Increased lint coverage * Does this fix all sloppy reassigns & shadowing? * Undoing retry policy change * Documentation regeneration * Coinbase code improvements * Providing warning about known issue * Updating an error to new format * Making gocritic happy * Review adherence * Endpoints moved to V3 & nil pointer fixes * Removing seemingly superfluous constant * Glorious improvements * Removing unused error * Partial public endpoint addition * Slight improvements * Wrapper improvements; still a few errors left in other packages * A lil Coinbase progress * Json cleaning * Lint appeasement * Config repair * Config fix (real) * Little fix * New public endpoint incorporation * Additional fixes * Improvements & Appeasements * LineSaver * Additional fixes * Another fix * Fixing picked nits * Quick fixies * Lil fixes * Subscriptions: Add List.Enabled * CoinbasePro: Add subscription templating * fixup! CoinbasePro: Add subscription templating * fixup! CoinbasePro: Add subscription templating * Comment fix * Subsequent fixes * Issues hopefully fixed * Lint fix * Glorious fixes * Json formatting * ShazNits * (L/N)i(n/)t * Adding a test * Tiny test improvement * Template patch testing * Fixes * Further shaznits * Lint nit * JWT move and other fixes * Small nits * Shaznit, singular * Post-merge fix * Post-merge fixes * Typo fix * Some glorious nits * Required changes * Stop going * Alias attempt * Alias fix & test cleanup * Test fix * GetDepositAddress logic improvement * Status update: Fixed * Lint fix * Happy birthday to PR 1480 * Cleanups * Necessary nit corrections * Fixing sillybug * As per request * Programming progress * Order fixes * Further fixies * Test fix * Pre-merge fixes * More shaznits * Context * Sonic error handling * Import fix * Better Sonic error handling * Perfect Sonic error handling? * F purge * Coinbase improvements * API Update Conformity * Coinbase continuation * Coinbase order improvements * Coinbase order improvements * CreateOrderConfig improvements * Managing API updates * Coinbase API update progression * jwt rename * Comment link fix * Coinbase v2 cleanup * Post-merge fixes * Review fixes * GK's suggestions * Linter fix * Minor gbjk fixes * Nit fixes * Merge fix * Lint fixes * Coinbase rename stage 1 * Coinbase rename stage 2 * Coinbase rename stage 3 * Coinbase rename stage 4 * Coinbase rename final fix * Coinbase: PoC on converting to request structs * Applying requested changes * Many review fixes, handled * Thrashed by nits * More minor modifications * The last nit!? --------- Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>
This commit is contained in:
@@ -3,7 +3,6 @@ package engine
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"maps"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -23,9 +22,12 @@ var (
|
||||
// DepositAddressManager manages the exchange deposit address store
|
||||
type DepositAddressManager struct {
|
||||
m sync.RWMutex
|
||||
store map[string]map[string][]deposit.Address
|
||||
store map[string]ExchangeDepositAddresses
|
||||
}
|
||||
|
||||
// ExchangeDepositAddresses is a map of currencies to their deposit addresses
|
||||
type ExchangeDepositAddresses map[string][]deposit.Address
|
||||
|
||||
// IsSynced returns whether or not the deposit address store has synced its data
|
||||
func (m *DepositAddressManager) IsSynced() bool {
|
||||
if m.store == nil {
|
||||
@@ -39,7 +41,7 @@ func (m *DepositAddressManager) IsSynced() bool {
|
||||
// SetupDepositAddressManager returns a DepositAddressManager
|
||||
func SetupDepositAddressManager() *DepositAddressManager {
|
||||
return &DepositAddressManager{
|
||||
store: make(map[string]map[string][]deposit.Address),
|
||||
store: make(map[string]ExchangeDepositAddresses),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +88,7 @@ func (m *DepositAddressManager) GetDepositAddressByExchangeAndCurrency(exchName,
|
||||
|
||||
// GetDepositAddressesByExchange returns a list of cryptocurrency addresses for the specified
|
||||
// exchange if they exist
|
||||
func (m *DepositAddressManager) GetDepositAddressesByExchange(exchName string) (map[string][]deposit.Address, error) {
|
||||
func (m *DepositAddressManager) GetDepositAddressesByExchange(exchName string) (ExchangeDepositAddresses, error) {
|
||||
m.m.RLock()
|
||||
defer m.m.RUnlock()
|
||||
|
||||
@@ -99,15 +101,15 @@ func (m *DepositAddressManager) GetDepositAddressesByExchange(exchName string) (
|
||||
return nil, ErrDepositAddressNotFound
|
||||
}
|
||||
|
||||
cpy := maps.Clone(r)
|
||||
for k, v := range cpy {
|
||||
cpy := make(ExchangeDepositAddresses, len(r))
|
||||
for k, v := range r {
|
||||
cpy[k] = slices.Clone(v)
|
||||
}
|
||||
return cpy, nil
|
||||
}
|
||||
|
||||
// Sync synchronises all deposit addresses
|
||||
func (m *DepositAddressManager) Sync(addresses map[string]map[string][]deposit.Address) error {
|
||||
func (m *DepositAddressManager) Sync(addresses map[string]ExchangeDepositAddresses) error {
|
||||
if m == nil {
|
||||
return fmt.Errorf("deposit address manager %w", ErrNilSubsystem)
|
||||
}
|
||||
@@ -118,7 +120,7 @@ func (m *DepositAddressManager) Sync(addresses map[string]map[string][]deposit.A
|
||||
}
|
||||
|
||||
for k, v := range addresses {
|
||||
r := make(map[string][]deposit.Address)
|
||||
r := make(ExchangeDepositAddresses)
|
||||
for w, x := range v {
|
||||
r[strings.ToUpper(w)] = x
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user