forked from Qortal/qortal
Add support for testing with multiple online accounts
This commit is contained in:
parent
95cb5f607b
commit
873a9d0cee
@ -341,17 +341,19 @@ public class BlockMinter extends Thread {
|
|||||||
this.interrupt();
|
this.interrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void mintTestingBlock(Repository repository, PrivateKeyAccount mintingAccount) throws DataException {
|
public static void mintTestingBlock(Repository repository, PrivateKeyAccount... mintingAndOnlineAccounts) throws DataException {
|
||||||
if (!BlockChain.getInstance().isTestChain()) {
|
if (!BlockChain.getInstance().isTestChain()) {
|
||||||
LOGGER.warn("Ignoring attempt to mint testing block for non-test chain!");
|
LOGGER.warn("Ignoring attempt to mint testing block for non-test chain!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure mintingAccount is 'online' so blocks can be minted
|
// Ensure mintingAccount is 'online' so blocks can be minted
|
||||||
Controller.getInstance().ensureTestingAccountOnline(mintingAccount);
|
Controller.getInstance().ensureTestingAccountsOnline(mintingAndOnlineAccounts);
|
||||||
|
|
||||||
BlockData previousBlockData = repository.getBlockRepository().getLastBlock();
|
BlockData previousBlockData = repository.getBlockRepository().getLastBlock();
|
||||||
|
|
||||||
|
PrivateKeyAccount mintingAccount = mintingAndOnlineAccounts[0];
|
||||||
|
|
||||||
Block newBlock = Block.mint(repository, previousBlockData, mintingAccount);
|
Block newBlock = Block.mint(repository, previousBlockData, mintingAccount);
|
||||||
|
|
||||||
// Make sure we're the only thread modifying the blockchain
|
// Make sure we're the only thread modifying the blockchain
|
||||||
|
@ -1342,7 +1342,7 @@ public class Controller extends Thread {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ensureTestingAccountOnline(PrivateKeyAccount mintingAccount) {
|
public void ensureTestingAccountsOnline(PrivateKeyAccount... onlineAccounts) {
|
||||||
if (!BlockChain.getInstance().isTestChain()) {
|
if (!BlockChain.getInstance().isTestChain()) {
|
||||||
LOGGER.warn("Ignoring attempt to ensure test account is online for non-test chain!");
|
LOGGER.warn("Ignoring attempt to ensure test account is online for non-test chain!");
|
||||||
return;
|
return;
|
||||||
@ -1352,19 +1352,21 @@ public class Controller extends Thread {
|
|||||||
if (now == null)
|
if (now == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Check mintingAccount is actually reward-share?
|
|
||||||
|
|
||||||
// Add reward-share & timestamp to online accounts
|
|
||||||
final long onlineAccountsTimestamp = Controller.toOnlineAccountTimestamp(now);
|
final long onlineAccountsTimestamp = Controller.toOnlineAccountTimestamp(now);
|
||||||
byte[] timestampBytes = Longs.toByteArray(onlineAccountsTimestamp);
|
byte[] timestampBytes = Longs.toByteArray(onlineAccountsTimestamp);
|
||||||
|
|
||||||
byte[] signature = mintingAccount.sign(timestampBytes);
|
|
||||||
byte[] publicKey = mintingAccount.getPublicKey();
|
|
||||||
|
|
||||||
OnlineAccountData ourOnlineAccountData = new OnlineAccountData(onlineAccountsTimestamp, signature, publicKey);
|
|
||||||
synchronized (this.onlineAccounts) {
|
synchronized (this.onlineAccounts) {
|
||||||
this.onlineAccounts.clear();
|
this.onlineAccounts.clear();
|
||||||
this.onlineAccounts.add(ourOnlineAccountData);
|
|
||||||
|
for (PrivateKeyAccount onlineAccount : onlineAccounts) {
|
||||||
|
// Check mintingAccount is actually reward-share?
|
||||||
|
|
||||||
|
byte[] signature = onlineAccount.sign(timestampBytes);
|
||||||
|
byte[] publicKey = onlineAccount.getPublicKey();
|
||||||
|
|
||||||
|
OnlineAccountData ourOnlineAccountData = new OnlineAccountData(onlineAccountsTimestamp, signature, publicKey);
|
||||||
|
this.onlineAccounts.add(ourOnlineAccountData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user