From 08c2450baa2fd0feced596293b6b7680c451a876 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Thu, 13 Feb 2020 19:58:33 -0500 Subject: [PATCH] [util] refs #295 - Keep track of last update timestamp --- src/util/account.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/util/account.go b/src/util/account.go index 4c840b5e..2b46127f 100644 --- a/src/util/account.go +++ b/src/util/account.go @@ -17,6 +17,7 @@ const defaultUpdateInterval = 10000000 // NewBalanceSnapshot new balance snapshot with validity timeout func NewBalanceSnapshot(updInterval int64) *BalanceSnapshot { if updInterval <= 0 { + updInterval = defaultUpdateInterval } return &BalanceSnapshot{ cache: make(map[string]uint64), @@ -28,6 +29,7 @@ func NewBalanceSnapshot(updInterval int64) *BalanceSnapshot { // SetCoins update balance for a given coin token func (bs *BalanceSnapshot) SetCoins(ticker string, coins uint64) { bs.cache[ticker] = coins + bs.lastUpdate = time.Now().UnixNano() } // GetCoins retrieve balance for a given coin ticker