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

Commit 95503d9

Browse files
authored
return an error when loading existing offers fails instead of ignoring (#336)
1 parent 3e0c240 commit 95503d9

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

trader/trader.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,12 @@ func (t *Trader) deleteAllOffers() {
155155
func (t *Trader) update() bool {
156156
var e error
157157
t.load()
158-
t.loadExistingOffers()
158+
e = t.loadExistingOffers()
159+
if e != nil {
160+
log.Println(e)
161+
t.deleteAllOffers()
162+
return false
163+
}
159164

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

287-
func (t *Trader) loadExistingOffers() {
292+
func (t *Trader) loadExistingOffers() error {
288293
offers, e := t.exchangeShim.LoadOffersHack()
289294
if e != nil {
290-
log.Println(e)
291-
return
295+
return fmt.Errorf("unable to load existing offers: %s", e)
292296
}
293297
t.sellingAOffers, t.buyingAOffers = utils.FilterOffers(offers, t.assetBase, t.assetQuote)
294298

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

0 commit comments

Comments
 (0)