@ -346,20 +346,24 @@ public class Block {
int version = parentBlock . getNextBlockVersion ( ) ;
byte [ ] reference = parentBlockData . getSignature ( ) ;
// Qortal: minter is always a reward-share, so find actual minter and get their effective minting level
int minterLevel = Account . getRewardShareEffectiveMintingLevel ( repository , minter . getPublicKey ( ) ) ;
if ( minterLevel = = 0 ) {
LOGGER . error ( "Minter effective level returned zero?" ) ;
return null ;
}
long timestamp = calcTimestamp ( parentBlockData , minter . getPublicKey ( ) , minterLevel ) ;
long onlineAccountsTimestamp = OnlineAccountsManager . toOnlineAccountTimestamp ( timestamp ) ;
// Fetch our list of online accounts
List < OnlineAccountData > onlineAccounts = OnlineAccountsManager . getInstance ( ) . getOnlineAccounts ( ) ;
List < OnlineAccountData > onlineAccounts = OnlineAccountsManager . getInstance ( ) . getOnlineAccounts ( onlineAccountsTimestamp ) ;
if ( onlineAccounts . isEmpty ( ) ) {
LOGGER . error ( "No online accounts - not even our own?" ) ;
return null ;
}
// Find newest online accounts timestamp
long onlineAccountsTimestamp = 0 ;
for ( OnlineAccountData onlineAccountData : onlineAccounts ) {
if ( onlineAccountData . getTimestamp ( ) > onlineAccountsTimestamp )
onlineAccountsTimestamp = onlineAccountData . getTimestamp ( ) ;
}
// Load sorted list of reward share public keys into memory, so that the indexes can be obtained.
// This is up to 100x faster than querying each index separately. For 4150 reward share keys, it
// was taking around 5000ms to query individually, vs 50ms using this approach.
@ -368,10 +372,6 @@ public class Block {
// Map using index into sorted list of reward-shares as key
Map < Integer , OnlineAccountData > indexedOnlineAccounts = new HashMap < > ( ) ;
for ( OnlineAccountData onlineAccountData : onlineAccounts ) {
// Disregard online accounts with different timestamps
if ( onlineAccountData . getTimestamp ( ) ! = onlineAccountsTimestamp )
continue ;
Integer accountIndex = getRewardShareIndex ( onlineAccountData . getPublicKey ( ) , allRewardSharePublicKeys ) ;
if ( accountIndex = = null )
// Online account (reward-share) with current timestamp but reward-share cancelled
@ -399,15 +399,6 @@ public class Block {
byte [ ] minterSignature = minter . sign ( BlockTransformer . getBytesForMinterSignature ( parentBlockData ,
minter . getPublicKey ( ) , encodedOnlineAccounts ) ) ;
// Qortal: minter is always a reward-share, so find actual minter and get their effective minting level
int minterLevel = Account . getRewardShareEffectiveMintingLevel ( repository , minter . getPublicKey ( ) ) ;
if ( minterLevel = = 0 ) {
LOGGER . error ( "Minter effective level returned zero?" ) ;
return null ;
}
long timestamp = calcTimestamp ( parentBlockData , minter . getPublicKey ( ) , minterLevel ) ;
int transactionCount = 0 ;
byte [ ] transactionsSignature = null ;
int height = parentBlockData . getHeight ( ) + 1 ;