Skip to content

Commit

Permalink
[util] refs #295 - Keep track of last update timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
olemis committed Feb 14, 2020
1 parent 796baac commit 08c2450
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/util/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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
Expand Down

0 comments on commit 08c2450

Please sign in to comment.