bithumb: Add websocket support (#745)

* bithumb: Add websocket support (WIP)

* bithumb: cont impl.

* bithumb: finish, issues with orderbook needs review

* linter issues

* bithumb: move to separate file

* bithumb: change to pointer for book

* bithumb: Add tests

* bithumb: Address nits

* websocket: Export subscription error and wrap returns

* bithumb: cleanup/ fix tests

* gctrpc/bithumb: fix misspelling

* bithumb: gofmt

* readme: update support table, regen doc

* tradesReadme: update

* readme: update template
This commit is contained in:
Ryan O'Hara-Reid
2021-08-16 16:53:23 +10:00
committed by GitHub
parent e77baf3ad4
commit 736c92a99b
20 changed files with 3034 additions and 2112 deletions

View File

@@ -23,7 +23,11 @@ const (
defaultTrafficPeriod = time.Second
)
var errClosedConnection = errors.New("use of closed network connection")
var (
errClosedConnection = errors.New("use of closed network connection")
// ErrSubscriptionFailure defines an error when a subscription fails
ErrSubscriptionFailure = errors.New("subscription failure")
)
// New initialises the websocket struct
func New() *Websocket {
@@ -210,7 +214,7 @@ func (w *Websocket) Connect() error {
if len(w.subscriptions) != 0 {
err = w.Subscriber(w.subscriptions)
if err != nil {
return fmt.Errorf("%v Error subscribing %s", w.exchangeName, err)
return fmt.Errorf("%v %w: %v", w.exchangeName, ErrSubscriptionFailure, err)
}
}
@@ -836,7 +840,11 @@ func (w *Websocket) SubscribeToChannels(channels []ChannelSubscription) error {
}
}
}
return w.Subscriber(channels)
err := w.Subscriber(channels)
if err != nil {
return fmt.Errorf("%v %w: %v", w.exchangeName, ErrSubscriptionFailure, err)
}
return nil
}
// AddSuccessfulSubscriptions adds subscriptions to the subscription lists that