(Exchange Interface) Convert Fetch & Update orderbook/ticker methods to return pointers (#398)

* moved order and ticker fetching to return a pointer

* return nil instead of empty struct

* fixed incorrect nil

* general cleanup
This commit is contained in:
Andrew
2019-12-17 15:54:09 +11:00
committed by Adrian Gallagher
parent 44aa1e306c
commit 75ac5ee791
42 changed files with 320 additions and 348 deletions

View File

@@ -15,12 +15,12 @@ import (
// Get checks and returns the orderbook given an exchange name and currency pair
// if it exists
func Get(exchange string, p currency.Pair, a asset.Item) (Base, error) {
func Get(exchange string, p currency.Pair, a asset.Item) (*Base, error) {
o, err := service.Retrieve(exchange, p, a)
if err != nil {
return Base{}, err
return nil, err
}
return *o, nil
return o, nil
}
// SubscribeOrderbook subcribes to an orderbook and returns a communication

View File

@@ -395,7 +395,7 @@ func TestProcessOrderbook(t *testing.T) {
t.Error("Process() error", err)
}
result, err = Get("Blah", c, "quarterly")
_, err = Get("Blah", c, "quarterly")
if err != nil {
t.Fatal("TestProcessOrderbook failed to create new orderbook")
}