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

Commit

Permalink
conditionally reset cached balances and liabilities to reduce network…
Browse files Browse the repository at this point in the history
… calls, closes #561 (#562)
  • Loading branch information
nikhilsaraf authored Oct 25, 2020
1 parent 7a15ab6 commit 162cffc
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions trader/trader.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,19 +400,19 @@ func (t *Trader) update() bool {
t.deleteAllOffers(false)
return false
}
}

// TODO 2 streamline the request data instead of caching
// reset cache of balances for this update cycle to reduce redundant requests to calculate asset balances
t.sdex.IEIF().ResetCachedBalances()
// reset and recompute cached liabilities for this update cycle
e = t.sdex.IEIF().ResetCachedLiabilities(t.assetBase, t.assetQuote)
log.Printf("liabilities after resetting\n")
t.sdex.IEIF().LogAllLiabilities(t.assetBase, t.assetQuote)
if e != nil {
log.Println(e)
t.deleteAllOffers(false)
return false
// TODO 2 streamline the request data instead of caching - may not need this since result of PruneOps is async
// reset cache of balances for this update cycle to reduce redundant requests to calculate asset balances
t.sdex.IEIF().ResetCachedBalances()
// reset and recompute cached liabilities for this update cycle
e = t.sdex.IEIF().ResetCachedLiabilities(t.assetBase, t.assetQuote)
log.Printf("liabilities after resetting\n")
t.sdex.IEIF().LogAllLiabilities(t.assetBase, t.assetQuote)
if e != nil {
log.Println(e)
t.deleteAllOffers(false)
return false
}
}

opsOld, e := t.strategy.UpdateWithOps(t.buyingAOffers, t.sellingAOffers)
Expand Down

0 comments on commit 162cffc

Please sign in to comment.