Fix the wrong 'Identifier' and 'Synchronizer' usage (#7252)

* fix the synchronizer usage

Signed-off-by: Leni <leniram159@gmail.com>

* fix Identifier usage

Signed-off-by: Leni <leniram159@gmail.com>

---------

Signed-off-by: Leni <leniram159@gmail.com>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
pull/7264/head
leniram159 5 months ago committed by GitHub
parent 7e840ab640
commit db33b03f8d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/events/BlockTimerExpiry.java
  2. 18
      consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/statemachine/BaseBftController.java
  3. 6
      consensus/common/src/test/java/org/hyperledger/besu/consensus/common/bft/BlockTimerTest.java
  4. 6
      consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftController.java
  5. 6
      consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftController.java

@ -41,9 +41,9 @@ public final class BlockTimerExpiry implements BftEvent {
/** /**
* Gets round identifier. * Gets round identifier.
* *
* @return the round indentifier * @return the round Identifier
*/ */
public ConsensusRoundIdentifier getRoundIndentifier() { public ConsensusRoundIdentifier getRoundIdentifier() {
return roundIdentifier; return roundIdentifier;
} }

@ -44,7 +44,7 @@ public abstract class BaseBftController implements BftEventHandler {
private final FutureMessageBuffer futureMessageBuffer; private final FutureMessageBuffer futureMessageBuffer;
private final Gossiper gossiper; private final Gossiper gossiper;
private final MessageTracker duplicateMessageTracker; private final MessageTracker duplicateMessageTracker;
private final SynchronizerUpdater sychronizerUpdater; private final SynchronizerUpdater synchronizerUpdater;
private final AtomicBoolean started = new AtomicBoolean(false); private final AtomicBoolean started = new AtomicBoolean(false);
@ -56,7 +56,7 @@ public abstract class BaseBftController implements BftEventHandler {
* @param gossiper the gossiper * @param gossiper the gossiper
* @param duplicateMessageTracker the duplicate message tracker * @param duplicateMessageTracker the duplicate message tracker
* @param futureMessageBuffer the future message buffer * @param futureMessageBuffer the future message buffer
* @param sychronizerUpdater the synchronizer updater * @param synchronizerUpdater the synchronizer updater
*/ */
protected BaseBftController( protected BaseBftController(
final Blockchain blockchain, final Blockchain blockchain,
@ -64,13 +64,13 @@ public abstract class BaseBftController implements BftEventHandler {
final Gossiper gossiper, final Gossiper gossiper,
final MessageTracker duplicateMessageTracker, final MessageTracker duplicateMessageTracker,
final FutureMessageBuffer futureMessageBuffer, final FutureMessageBuffer futureMessageBuffer,
final SynchronizerUpdater sychronizerUpdater) { final SynchronizerUpdater synchronizerUpdater) {
this.blockchain = blockchain; this.blockchain = blockchain;
this.bftFinalState = bftFinalState; this.bftFinalState = bftFinalState;
this.futureMessageBuffer = futureMessageBuffer; this.futureMessageBuffer = futureMessageBuffer;
this.gossiper = gossiper; this.gossiper = gossiper;
this.duplicateMessageTracker = duplicateMessageTracker; this.duplicateMessageTracker = duplicateMessageTracker;
this.sychronizerUpdater = sychronizerUpdater; this.synchronizerUpdater = synchronizerUpdater;
} }
@Override @Override
@ -162,14 +162,14 @@ public abstract class BaseBftController implements BftEventHandler {
@Override @Override
public void handleBlockTimerExpiry(final BlockTimerExpiry blockTimerExpiry) { public void handleBlockTimerExpiry(final BlockTimerExpiry blockTimerExpiry) {
final ConsensusRoundIdentifier roundIndentifier = blockTimerExpiry.getRoundIndentifier(); final ConsensusRoundIdentifier roundIdentifier = blockTimerExpiry.getRoundIdentifier();
if (isMsgForCurrentHeight(roundIndentifier)) { if (isMsgForCurrentHeight(roundIdentifier)) {
getCurrentHeightManager().handleBlockTimerExpiry(roundIndentifier); getCurrentHeightManager().handleBlockTimerExpiry(roundIdentifier);
} else { } else {
LOG.trace( LOG.trace(
"Block timer event discarded as it is not for current block height chainHeight={} eventHeight={}", "Block timer event discarded as it is not for current block height chainHeight={} eventHeight={}",
getCurrentHeightManager().getChainHeight(), getCurrentHeightManager().getChainHeight(),
roundIndentifier.getSequenceNumber()); roundIdentifier.getSequenceNumber());
} }
} }
@ -221,7 +221,7 @@ public abstract class BaseBftController implements BftEventHandler {
futureMessageBuffer.addMessage(msgRoundIdentifier.getSequenceNumber(), rawMsg); futureMessageBuffer.addMessage(msgRoundIdentifier.getSequenceNumber(), rawMsg);
// Notify the synchronizer the transmitting peer must have the parent block to the received // Notify the synchronizer the transmitting peer must have the parent block to the received
// message's target height. // message's target height.
sychronizerUpdater.updatePeerChainState( synchronizerUpdater.updatePeerChainState(
msgRoundIdentifier.getSequenceNumber() - 1L, rawMsg.getConnection()); msgRoundIdentifier.getSequenceNumber() - 1L, rawMsg.getConnection());
} else { } else {
LOG.trace( LOG.trace(

@ -141,7 +141,7 @@ public class BlockTimerTest {
assertThat(eventQueue.size()).isEqualTo(1); assertThat(eventQueue.size()).isEqualTo(1);
final BftEvent queuedEvent = eventQueue.poll(0, TimeUnit.SECONDS); final BftEvent queuedEvent = eventQueue.poll(0, TimeUnit.SECONDS);
assertThat(queuedEvent).isInstanceOf(BlockTimerExpiry.class); assertThat(queuedEvent).isInstanceOf(BlockTimerExpiry.class);
assertThat(((BlockTimerExpiry) queuedEvent).getRoundIndentifier()) assertThat(((BlockTimerExpiry) queuedEvent).getRoundIdentifier())
.usingRecursiveComparison() .usingRecursiveComparison()
.isEqualTo(round); .isEqualTo(round);
} }
@ -171,7 +171,7 @@ public class BlockTimerTest {
verify(mockQueue).add(bftEventCaptor.capture()); verify(mockQueue).add(bftEventCaptor.capture());
assertThat(bftEventCaptor.getValue() instanceof BlockTimerExpiry).isTrue(); assertThat(bftEventCaptor.getValue() instanceof BlockTimerExpiry).isTrue();
assertThat(((BlockTimerExpiry) bftEventCaptor.getValue()).getRoundIndentifier()) assertThat(((BlockTimerExpiry) bftEventCaptor.getValue()).getRoundIdentifier())
.usingRecursiveComparison() .usingRecursiveComparison()
.isEqualTo(round); .isEqualTo(round);
} }
@ -201,7 +201,7 @@ public class BlockTimerTest {
verify(mockQueue).add(bftEventCaptor.capture()); verify(mockQueue).add(bftEventCaptor.capture());
assertThat(bftEventCaptor.getValue() instanceof BlockTimerExpiry).isTrue(); assertThat(bftEventCaptor.getValue() instanceof BlockTimerExpiry).isTrue();
assertThat(((BlockTimerExpiry) bftEventCaptor.getValue()).getRoundIndentifier()) assertThat(((BlockTimerExpiry) bftEventCaptor.getValue()).getRoundIdentifier())
.usingRecursiveComparison() .usingRecursiveComparison()
.isEqualTo(round); .isEqualTo(round);
} }

@ -46,7 +46,7 @@ public class IbftController extends BaseBftController {
* @param gossiper the gossiper * @param gossiper the gossiper
* @param duplicateMessageTracker the duplicate message tracker * @param duplicateMessageTracker the duplicate message tracker
* @param futureMessageBuffer the future message buffer * @param futureMessageBuffer the future message buffer
* @param sychronizerUpdater the synchronizer updater * @param synchronizerUpdater the synchronizer updater
*/ */
public IbftController( public IbftController(
final Blockchain blockchain, final Blockchain blockchain,
@ -55,7 +55,7 @@ public class IbftController extends BaseBftController {
final Gossiper gossiper, final Gossiper gossiper,
final MessageTracker duplicateMessageTracker, final MessageTracker duplicateMessageTracker,
final FutureMessageBuffer futureMessageBuffer, final FutureMessageBuffer futureMessageBuffer,
final SynchronizerUpdater sychronizerUpdater) { final SynchronizerUpdater synchronizerUpdater) {
super( super(
blockchain, blockchain,
@ -63,7 +63,7 @@ public class IbftController extends BaseBftController {
gossiper, gossiper,
duplicateMessageTracker, duplicateMessageTracker,
futureMessageBuffer, futureMessageBuffer,
sychronizerUpdater); synchronizerUpdater);
this.ibftBlockHeightManagerFactory = ibftBlockHeightManagerFactory; this.ibftBlockHeightManagerFactory = ibftBlockHeightManagerFactory;
} }

@ -48,7 +48,7 @@ public class QbftController extends BaseBftController {
* @param gossiper the gossiper * @param gossiper the gossiper
* @param duplicateMessageTracker the duplicate message tracker * @param duplicateMessageTracker the duplicate message tracker
* @param futureMessageBuffer the future message buffer * @param futureMessageBuffer the future message buffer
* @param sychronizerUpdater the synchronizer updater * @param synchronizerUpdater the synchronizer updater
* @param bftExtraDataCodec the bft extra data codec * @param bftExtraDataCodec the bft extra data codec
*/ */
public QbftController( public QbftController(
@ -58,7 +58,7 @@ public class QbftController extends BaseBftController {
final Gossiper gossiper, final Gossiper gossiper,
final MessageTracker duplicateMessageTracker, final MessageTracker duplicateMessageTracker,
final FutureMessageBuffer futureMessageBuffer, final FutureMessageBuffer futureMessageBuffer,
final SynchronizerUpdater sychronizerUpdater, final SynchronizerUpdater synchronizerUpdater,
final BftExtraDataCodec bftExtraDataCodec) { final BftExtraDataCodec bftExtraDataCodec) {
super( super(
@ -67,7 +67,7 @@ public class QbftController extends BaseBftController {
gossiper, gossiper,
duplicateMessageTracker, duplicateMessageTracker,
futureMessageBuffer, futureMessageBuffer,
sychronizerUpdater); synchronizerUpdater);
this.qbftBlockHeightManagerFactory = qbftBlockHeightManagerFactory; this.qbftBlockHeightManagerFactory = qbftBlockHeightManagerFactory;
this.bftExtraDataCodec = bftExtraDataCodec; this.bftExtraDataCodec = bftExtraDataCodec;
} }

Loading…
Cancel
Save