Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
return an error when loading existing offers fails instead of ignoring (
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilsaraf authored Jan 10, 2020
1 parent 3e0c240 commit 95503d9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions trader/trader.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,12 @@ func (t *Trader) deleteAllOffers() {
func (t *Trader) update() bool {
var e error
t.load()
t.loadExistingOffers()
e = t.loadExistingOffers()
if e != nil {
log.Println(e)
t.deleteAllOffers()
return false
}

pair := &model.TradingPair{
Base: model.FromHorizonAsset(t.assetBase),
Expand Down Expand Up @@ -284,14 +289,14 @@ func (t *Trader) load() {
log.Printf("(quote) assetB=%s, maxB=%.8f, trustB=%s\n", utils.Asset2String(t.assetQuote), t.maxAssetB, trustBString)
}

func (t *Trader) loadExistingOffers() {
func (t *Trader) loadExistingOffers() error {
offers, e := t.exchangeShim.LoadOffersHack()
if e != nil {
log.Println(e)
return
return fmt.Errorf("unable to load existing offers: %s", e)
}
t.sellingAOffers, t.buyingAOffers = utils.FilterOffers(offers, t.assetBase, t.assetQuote)

sort.Sort(utils.ByPrice(t.buyingAOffers))
sort.Sort(utils.ByPrice(t.sellingAOffers)) // don't reverse since prices are inverse
return nil
}

0 comments on commit 95503d9

Please sign in to comment.