balance calculation


   I am using Scorex-1.2.8 to build my own blocktrain. I read the source code, but I can not understand the balance calculation code in StoredState.scala:122.

def loop(hh: Int, min: Long = Long.MaxValue): Long = {
val row = accountChanges(address).get(hh)
require(Option(row).isDefined, s"accountChanges($address).get($hh) is null. lastStates.get(address)=$h")
if (hh <= requiredHeight) Math.min(row.state.balance, min)
else if (row.lastRowHeight == 0) 0L
else loop(row.lastRowHeight, Math.min(row.state.balance, min))
In my opinion, the most recent balance of an account it just the last row.state.balance? Why here need recursive traverse the blocktrain, especially why Math.min(row.state.balance, min)?

hope anyone can tell me.

Join to automatically receive all group messages.