core: optimize CalculateClaimable()

Because accumulated system fee is stored for every block,
it is easy to calculate sum with just to reads.
This commit is contained in:
Evgenii Stratonikov 2020-02-27 16:48:24 +03:00
parent 258d8be1dd
commit 1b9968df67
2 changed files with 6 additions and 16 deletions

View file

@ -178,12 +178,9 @@ func TestGetTransaction(t *testing.T) {
func TestGetClaimable(t *testing.T) {
bc := newTestChain(t)
_, _, err := bc.CalculateClaimable(util.Fixed8FromInt64(1), 0, 2)
require.Error(t, err)
bc.generationAmount = []int{4, 3, 2, 1}
bc.decrementInterval = 2
_, err = bc.genBlocks(10)
_, err := bc.genBlocks(10)
require.NoError(t, err)
t.Run("first generation period", func(t *testing.T) {