Rework block rewards to be faster and only reward *online* founders.

Now we sum generic block reward + transaction fees before performing
distribution only once.

Added Map to collate account-balance changes during block reward
distribution so the final changes can be applied in one batch,
reducing DB load.

Some other optimizations like a faster ExpandedAccount.getShareBin().

Passes test EXCEPT RewardTests.testLegacyQoraReward(), pending decision
on how to reallocate 'unspent' block reward.
This commit is contained in:
catbref
2020-06-01 16:50:28 +01:00
parent 2493d5f7a8
commit b5512dfa91
3 changed files with 228 additions and 138 deletions

View File

@@ -241,15 +241,15 @@ public class RewardTests extends Common {
BlockMinter.mintTestingBlock(repository, mintingAndOnlineAccounts.toArray(new PrivateKeyAccount[0]));
// 3 founders (online or not) so blockReward divided by 3
int founderCount = 3;
// 2 founders online so blockReward divided by 2
int founderCount = 2;
long perFounderReward = blockReward / founderCount;
// Alice simple self-share so her reward is perFounderReward
AccountUtils.assertBalance(repository, "alice", Asset.QORT, perFounderReward);
// Bob not online so his reward is simply perFounderReward
AccountUtils.assertBalance(repository, "bob", Asset.QORT, perFounderReward);
// Bob not online so his reward is zero
AccountUtils.assertBalance(repository, "bob", Asset.QORT, 0L);
// Chloe has two reward-shares, so her reward is divided by 2
int chloeSharesCount = 2;