forked from Qortal/qortal
Replace throwing IllegalStateException with more defensive log & null in Block/BlockMinter
This commit is contained in:
parent
44e8b3e6e7
commit
e5cf76f3e0
@ -304,8 +304,10 @@ public class Block {
|
|||||||
|
|
||||||
// Fetch our list of online accounts
|
// Fetch our list of online accounts
|
||||||
List<OnlineAccountData> onlineAccounts = Controller.getInstance().getOnlineAccounts();
|
List<OnlineAccountData> onlineAccounts = Controller.getInstance().getOnlineAccounts();
|
||||||
if (onlineAccounts.isEmpty())
|
if (onlineAccounts.isEmpty()) {
|
||||||
throw new IllegalStateException("No online accounts - not even our own?");
|
LOGGER.error("No online accounts - not even our own?");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// Find newest online accounts timestamp
|
// Find newest online accounts timestamp
|
||||||
long onlineAccountsTimestamp = 0;
|
long onlineAccountsTimestamp = 0;
|
||||||
@ -350,8 +352,10 @@ public class Block {
|
|||||||
|
|
||||||
// Qortal: minter is always a reward-share, so find actual minter and get their effective minting level
|
// Qortal: minter is always a reward-share, so find actual minter and get their effective minting level
|
||||||
int minterLevel = Account.getRewardShareEffectiveMintingLevel(repository, minter.getPublicKey());
|
int minterLevel = Account.getRewardShareEffectiveMintingLevel(repository, minter.getPublicKey());
|
||||||
if (minterLevel == 0)
|
if (minterLevel == 0) {
|
||||||
throw new IllegalStateException("Minter effective level returned zero?");
|
LOGGER.error("Minter effective level returned zero?");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
long timestamp = calcTimestamp(parentBlockData, minter.getPublicKey(), minterLevel);
|
long timestamp = calcTimestamp(parentBlockData, minter.getPublicKey(), minterLevel);
|
||||||
|
|
||||||
@ -419,8 +423,10 @@ public class Block {
|
|||||||
|
|
||||||
// Qortal: minter is always a reward-share, so find actual minter and get their effective minting level
|
// Qortal: minter is always a reward-share, so find actual minter and get their effective minting level
|
||||||
int minterLevel = Account.getRewardShareEffectiveMintingLevel(repository, minter.getPublicKey());
|
int minterLevel = Account.getRewardShareEffectiveMintingLevel(repository, minter.getPublicKey());
|
||||||
if (minterLevel == 0)
|
if (minterLevel == 0){
|
||||||
throw new IllegalStateException("Minter effective level returned zero?");
|
LOGGER.error("Minter effective level returned zero?");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
long timestamp = calcTimestamp(parentBlockData, minter.getPublicKey(), minterLevel);
|
long timestamp = calcTimestamp(parentBlockData, minter.getPublicKey(), minterLevel);
|
||||||
|
|
||||||
|
@ -163,10 +163,18 @@ public class BlockMinter extends Thread {
|
|||||||
// First block does the AT heavy-lifting
|
// First block does the AT heavy-lifting
|
||||||
if (newBlocks.isEmpty()) {
|
if (newBlocks.isEmpty()) {
|
||||||
Block newBlock = Block.mint(repository, previousBlock.getBlockData(), mintingAccount);
|
Block newBlock = Block.mint(repository, previousBlock.getBlockData(), mintingAccount);
|
||||||
|
if (newBlock == null)
|
||||||
|
// For some reason we can't mint right now
|
||||||
|
continue;
|
||||||
|
|
||||||
newBlocks.add(newBlock);
|
newBlocks.add(newBlock);
|
||||||
} else {
|
} else {
|
||||||
// The blocks for other minters require less effort...
|
// The blocks for other minters require less effort...
|
||||||
Block newBlock = newBlocks.get(0);
|
Block newBlock = newBlocks.get(0);
|
||||||
|
if (newBlock == null)
|
||||||
|
// For some reason we can't mint right now
|
||||||
|
continue;
|
||||||
|
|
||||||
newBlocks.add(newBlock.remint(mintingAccount));
|
newBlocks.add(newBlock.remint(mintingAccount));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user