Topics

balance calculation

pengmingguo@...
 

Hi
   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.

Bruno Woltzenlogel Paleo
 

Hi,

The code that you mentioned does not exist in Scorex 2 anymore.  Is there a reason why you are using Scorex-1.2.8 instead of Scorex 2 ?

Cheers,

Bruno