forked from Qortal/qortal
Change when BlockMinter decides it's ok to mint a block
Previously BlockMinter would attempt to mint if there were at least 'minBlockchainPeers' connected peers and none of them had an up-to-date block and we did. This was maybe useful for minting block 2 but possibly causes minting chain islands where a badly connected node mints by itself, even though connected to not up-to-date peers. Now BlockMinter requires 'minBlockchainPeers' up-to-date peers, not simply just connected. This should let synchronization bring the node up-to-date but does require the node to have better peers. Currently, the default for minBlockchainPeers is 10. So a node requires 10 up-to-date peers before it will consider minting. It might be possible to reduce this in the future to lessen network load.
This commit is contained in:
parent
d30d61edab
commit
79f7f68b0c
@ -137,19 +137,18 @@ public class BlockMinter extends Thread {
|
||||
// Disregard peers that have "misbehaved" recently
|
||||
peers.removeIf(Controller.hasMisbehaved);
|
||||
|
||||
// Don't mint if we don't have enough connected peers as where would the transactions/consensus come from?
|
||||
if (peers.size() < Settings.getInstance().getMinBlockchainPeers())
|
||||
continue;
|
||||
|
||||
// Disregard peers that don't have a recent block
|
||||
peers.removeIf(Controller.hasNoRecentBlock);
|
||||
|
||||
// If we have any peers with a recent block, but our latest block isn't recent
|
||||
// then we need to synchronize instead of minting.
|
||||
// Don't mint if we don't have enough up-to-date peers as where would the transactions/consensus come from?
|
||||
if (peers.size() < Settings.getInstance().getMinBlockchainPeers())
|
||||
continue;
|
||||
|
||||
// If our latest block isn't recent then we need to synchronize instead of minting.
|
||||
if (!peers.isEmpty() && lastBlockData.getTimestamp() < minLatestBlockTimestamp)
|
||||
continue;
|
||||
|
||||
// There are no peers with a recent block and/or our latest block is recent
|
||||
// There are enough peers with a recent block and our latest block is recent
|
||||
// so go ahead and mint a block if possible.
|
||||
isMintingPossible = true;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user