|
|
@ -23,6 +23,7 @@ import org.apache.logging.log4j.Logger; |
|
|
|
|
|
|
|
|
|
|
|
/** Execution context for draining queued ibft events and applying them to a maintained state */ |
|
|
|
/** Execution context for draining queued ibft events and applying them to a maintained state */ |
|
|
|
public class IbftProcessor implements Runnable { |
|
|
|
public class IbftProcessor implements Runnable { |
|
|
|
|
|
|
|
|
|
|
|
private static final Logger LOG = LogManager.getLogger(); |
|
|
|
private static final Logger LOG = LogManager.getLogger(); |
|
|
|
|
|
|
|
|
|
|
|
private final IbftEventQueue incomingQueue; |
|
|
|
private final IbftEventQueue incomingQueue; |
|
|
@ -35,18 +36,18 @@ public class IbftProcessor implements Runnable { |
|
|
|
* Construct a new IbftProcessor |
|
|
|
* Construct a new IbftProcessor |
|
|
|
* |
|
|
|
* |
|
|
|
* @param incomingQueue The event queue from which to drain new events |
|
|
|
* @param incomingQueue The event queue from which to drain new events |
|
|
|
* @param baseRoundExpiryMillis The expiry time in milliseconds of round 0 |
|
|
|
* @param baseRoundExpirySeconds The expiry time in milliseconds of round 0 |
|
|
|
* @param stateMachine an IbftStateMachine ready to process events and maintain state |
|
|
|
* @param stateMachine an IbftStateMachine ready to process events and maintain state |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public IbftProcessor( |
|
|
|
public IbftProcessor( |
|
|
|
final IbftEventQueue incomingQueue, |
|
|
|
final IbftEventQueue incomingQueue, |
|
|
|
final int baseRoundExpiryMillis, |
|
|
|
final int baseRoundExpirySeconds, |
|
|
|
final IbftStateMachine stateMachine) { |
|
|
|
final IbftStateMachine stateMachine) { |
|
|
|
// Spawning the round timer with a single thread as we should never have more than 1 timer in
|
|
|
|
// Spawning the round timer with a single thread as we should never have more than 1 timer in
|
|
|
|
// flight at a time
|
|
|
|
// flight at a time
|
|
|
|
this( |
|
|
|
this( |
|
|
|
incomingQueue, |
|
|
|
incomingQueue, |
|
|
|
baseRoundExpiryMillis, |
|
|
|
baseRoundExpirySeconds, |
|
|
|
stateMachine, |
|
|
|
stateMachine, |
|
|
|
Executors.newSingleThreadScheduledExecutor()); |
|
|
|
Executors.newSingleThreadScheduledExecutor()); |
|
|
|
} |
|
|
|
} |
|
|
@ -54,13 +55,14 @@ public class IbftProcessor implements Runnable { |
|
|
|
@VisibleForTesting |
|
|
|
@VisibleForTesting |
|
|
|
IbftProcessor( |
|
|
|
IbftProcessor( |
|
|
|
final IbftEventQueue incomingQueue, |
|
|
|
final IbftEventQueue incomingQueue, |
|
|
|
final int baseRoundExpiryMillis, |
|
|
|
final int baseRoundExpirySeconds, |
|
|
|
final IbftStateMachine stateMachine, |
|
|
|
final IbftStateMachine stateMachine, |
|
|
|
final ScheduledExecutorService roundTimerExecutor) { |
|
|
|
final ScheduledExecutorService roundTimerExecutor) { |
|
|
|
this.incomingQueue = incomingQueue; |
|
|
|
this.incomingQueue = incomingQueue; |
|
|
|
this.roundTimerExecutor = roundTimerExecutor; |
|
|
|
this.roundTimerExecutor = roundTimerExecutor; |
|
|
|
|
|
|
|
|
|
|
|
this.roundTimer = new RoundTimer(incomingQueue, baseRoundExpiryMillis, roundTimerExecutor); |
|
|
|
this.roundTimer = |
|
|
|
|
|
|
|
new RoundTimer(incomingQueue, baseRoundExpirySeconds * 1000, roundTimerExecutor); |
|
|
|
this.stateMachine = stateMachine; |
|
|
|
this.stateMachine = stateMachine; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|