forked from Qortal/qortal
OnlineAccountsManager:
Bump v3 min peer version from 3.2.203 to 3.3.203 No need for toOnlineAccountTimestamp(long) as we only ever use getCurrentOnlineAccountTimestamp(). Latter now returns Long and does the call to NTP.getTime() on behalf of caller, removing duplicated NTP.getTime() calls and null checks in multiple callers. Add aggregate-signature feature-trigger timestamp threshold checks where needed, near sign() and verify() calls. Improve logging - but some logging will need to be removed / reduced before merging.
This commit is contained in:
parent
a4e2aedde1
commit
8f58da4f52
@ -128,12 +128,15 @@ public class OnlineAccountsManager {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
byte[] timestampBytes = Longs.toByteArray(onlineAccountsTimestamp);
|
byte[] timestampBytes = Longs.toByteArray(onlineAccountsTimestamp);
|
||||||
|
final boolean useAggregateCompatibleSignature = onlineAccountsTimestamp >= BlockChain.getInstance().getAggregateSignatureTimestamp();
|
||||||
|
|
||||||
Set<OnlineAccountData> replacementAccounts = new HashSet<>();
|
Set<OnlineAccountData> replacementAccounts = new HashSet<>();
|
||||||
for (PrivateKeyAccount onlineAccount : onlineAccounts) {
|
for (PrivateKeyAccount onlineAccount : onlineAccounts) {
|
||||||
// Check mintingAccount is actually reward-share?
|
// Check mintingAccount is actually reward-share?
|
||||||
|
|
||||||
byte[] signature = onlineAccount.sign(timestampBytes);
|
byte[] signature = useAggregateCompatibleSignature
|
||||||
|
? Qortal25519Extras.signForAggregation(onlineAccount.getPrivateKey(), timestampBytes)
|
||||||
|
: onlineAccount.sign(timestampBytes);
|
||||||
byte[] publicKey = onlineAccount.getPublicKey();
|
byte[] publicKey = onlineAccount.getPublicKey();
|
||||||
|
|
||||||
OnlineAccountData ourOnlineAccountData = new OnlineAccountData(onlineAccountsTimestamp, signature, publicKey);
|
OnlineAccountData ourOnlineAccountData = new OnlineAccountData(onlineAccountsTimestamp, signature, publicKey);
|
||||||
@ -275,6 +278,8 @@ public class OnlineAccountsManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOGGER.info(String.format("we have online accounts for timestamps: %s", String.join(", ", this.currentOnlineAccounts.keySet().stream().map(l -> Long.toString(l)).collect(Collectors.joining(", ")))));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,6 +451,8 @@ public class OnlineAccountsManager {
|
|||||||
*/
|
*/
|
||||||
// Block::mint() - only wants online accounts with (online) timestamp that matches block's (online) timestamp so they can be added to new block
|
// Block::mint() - only wants online accounts with (online) timestamp that matches block's (online) timestamp so they can be added to new block
|
||||||
public List<OnlineAccountData> getOnlineAccounts(long onlineTimestamp) {
|
public List<OnlineAccountData> getOnlineAccounts(long onlineTimestamp) {
|
||||||
|
LOGGER.info(String.format("caller's timestamp: %d, our timestamps: %s", onlineTimestamp, String.join(", ", this.currentOnlineAccounts.keySet().stream().map(l -> Long.toString(l)).collect(Collectors.joining(", ")))));
|
||||||
|
|
||||||
return new ArrayList<>(Set.copyOf(this.currentOnlineAccounts.getOrDefault(onlineTimestamp, Collections.emptySet())));
|
return new ArrayList<>(Set.copyOf(this.currentOnlineAccounts.getOrDefault(onlineTimestamp, Collections.emptySet())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user