forked from Qortal/qortal
Speed up syncing blocks in the range of 1-12 hours ago by caching the valid online accounts.
This commit is contained in:
parent
510328db47
commit
30cd56165a
@ -1075,6 +1075,9 @@ public class Block {
|
||||
if (!OnlineAccountsManager.getInstance().verifyMemoryPoW(onlineAccount))
|
||||
return ValidationResult.ONLINE_ACCOUNT_NONCE_INCORRECT;
|
||||
|
||||
// Cache the valid online accounts as they will likely be needed for the next block
|
||||
OnlineAccountsManager.getInstance().addBlocksOnlineAccounts(onlineAccounts, onlineTimestamp);
|
||||
|
||||
// Extract online accounts' timestamp signatures from block data. Only one signature if aggregated.
|
||||
List<byte[]> onlineAccountsSignatures = BlockTransformer.decodeTimestampSignatures(encodedOnlineAccountSignatures);
|
||||
|
||||
|
@ -737,11 +737,12 @@ public class OnlineAccountsManager {
|
||||
* Typically called by {@link Block#areOnlineAccountsValid()}
|
||||
*/
|
||||
public void addBlocksOnlineAccounts(Set<OnlineAccountData> blocksOnlineAccounts, Long timestamp) {
|
||||
// We want to add to 'current' in preference if possible
|
||||
if (this.currentOnlineAccounts.containsKey(timestamp)) {
|
||||
addAccounts(blocksOnlineAccounts);
|
||||
// If these are current accounts, then there is no need to cache them, and should instead rely
|
||||
// on the more complete entries we already have in self.currentOnlineAccounts.
|
||||
// Note: since sig-agg, we no longer have individual signatures included in blocks, so we
|
||||
// mustn't add anything to currentOnlineAccounts from here.
|
||||
if (this.currentOnlineAccounts.containsKey(timestamp))
|
||||
return;
|
||||
}
|
||||
|
||||
// Add to block cache instead
|
||||
this.latestBlocksOnlineAccounts.computeIfAbsent(timestamp, k -> ConcurrentHashMap.newKeySet())
|
||||
|
Loading…
Reference in New Issue
Block a user