Skip to content

Commit

Permalink
feat: Updated handleConsensusRound to return a boolean (#17481)
Browse files Browse the repository at this point in the history
Signed-off-by: Lazar Petrovic <lpetrovic05@gmail.com>
  • Loading branch information
lpetrovic05 authored Jan 23, 2025
1 parent 829e18c commit 053a5c1
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ public void onPreHandle(
}

@Override
public void onHandleConsensusRound(
public boolean onHandleConsensusRound(
@NonNull final Round round,
@NonNull final PlatformMerkleStateRoot state,
@NonNull Consumer<ScopedSystemTransaction<StateSignatureTransaction>> stateSignatureTxnCallback) {
hedera.onHandleConsensusRound(round, state, stateSignatureTxnCallback);
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ public void onStateInitialized(
}

@Override
public void onHandleConsensusRound(
public boolean onHandleConsensusRound(
@NonNull Round round,
@NonNull CryptocurrencyDemoState state,
@NonNull Consumer<ScopedSystemTransaction<StateSignatureTransaction>> stateSignatureTransactionCallback) {
state.throwIfImmutable();
round.forEachEventTransaction(
(event, transaction) -> handleTransaction(event.getCreatorId(), transaction, state));
return true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@
public class HelloSwirldDemoStateLifecycles implements StateLifecycles<HelloSwirldDemoState> {

@Override
public void onHandleConsensusRound(
public boolean onHandleConsensusRound(
@NonNull Round round,
@NonNull HelloSwirldDemoState state,
@NonNull Consumer<ScopedSystemTransaction<StateSignatureTransaction>> stateSignatureTransactionCallback) {
state.throwIfImmutable();
round.forEachTransaction(v -> handleTransaction(v, state));
return true;
}

private void handleTransaction(final Transaction transaction, HelloSwirldDemoState state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void onStateInitialized(
}

@Override
public void onHandleConsensusRound(
public boolean onHandleConsensusRound(
@NonNull Round round,
@NonNull AddressBookTestingToolState state,
@NonNull Consumer<ScopedSystemTransaction<StateSignatureTransaction>> stateSignatureTransactionCallback) {
Expand Down Expand Up @@ -181,6 +181,7 @@ public void onHandleConsensusRound(
logger.error(EXCEPTION.getMarker(), "Test scenario {}: validation failed with errors.", testScenario);
}
}
return true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void onStateInitialized(
* Writes the round and its contents to a log on disk
*/
@Override
public void onHandleConsensusRound(
public boolean onHandleConsensusRound(
@NonNull Round round,
@NonNull ConsistencyTestingToolState state,
@NonNull Consumer<ScopedSystemTransaction<StateSignatureTransaction>> stateSignatureTransactionCallback) {
Expand All @@ -115,6 +115,7 @@ public void onHandleConsensusRound(
}

state.processTransactions(round, stateSignatureTransactionCallback);
return true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private void handleTransaction(
}

@Override
public void onHandleConsensusRound(
public boolean onHandleConsensusRound(
@NonNull Round round,
@NonNull ISSTestingToolState state,
@NonNull Consumer<ScopedSystemTransaction<StateSignatureTransaction>> stateSignatureTransactionCallback) {
Expand Down Expand Up @@ -154,6 +154,7 @@ public void onHandleConsensusRound(
}
}
}
return true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void onStateInitialized(
}

@Override
public void onHandleConsensusRound(
public boolean onHandleConsensusRound(
@NonNull Round round,
@NonNull MigrationTestingToolState state,
@NonNull Consumer<ScopedSystemTransaction<StateSignatureTransaction>> stateSignatureTransactionCallback) {
Expand All @@ -111,6 +111,7 @@ public void onHandleConsensusRound(
mTrans.applyTo(state);
}
}
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ private void preHandleTransaction(
}

@Override
public void onHandleConsensusRound(
public boolean onHandleConsensusRound(
@NonNull Round round,
@NonNull PlatformTestingToolState state,
@NonNull Consumer<ScopedSystemTransaction<StateSignatureTransaction>> stateSignatureTransactionCallback) {
Expand All @@ -760,6 +760,7 @@ public void onHandleConsensusRound(
updateTransactionCounters(state);
round.forEachEventTransaction((event, transaction) -> handleConsensusTransaction(
event, transaction, round.getRoundNum(), state, stateSignatureTransactionCallback));
return true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void onPreHandle(
}

@Override
public void onHandleConsensusRound(
public boolean onHandleConsensusRound(
@NonNull Round round,
@NonNull StatsSigningTestingToolState state,
@NonNull Consumer<ScopedSystemTransaction<StateSignatureTransaction>> stateSignatureTransactionCallback) {
Expand All @@ -137,6 +137,7 @@ public void onHandleConsensusRound(
handleTransaction(transaction, state);
}
});
return true;
}

private void handleTransaction(final ConsensusTransaction trans, final StatsSigningTestingToolState state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private void busyWait(@NonNull final Duration duration) {
}

@Override
public void onHandleConsensusRound(
public boolean onHandleConsensusRound(
@NonNull Round round,
@NonNull StressTestingToolState state,
@NonNull Consumer<ScopedSystemTransaction<StateSignatureTransaction>> stateSignatureTransactionCallback) {
Expand All @@ -115,6 +115,7 @@ public void onHandleConsensusRound(
}
});
}
return true;
}

private void handleTransaction(@NonNull final ConsensusTransaction trans, StressTestingToolState state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ public void onPreHandle(
}

@Override
public void onHandleConsensusRound(
public boolean onHandleConsensusRound(
@NonNull Round round,
@NonNull PlatformMerkleStateRoot state,
@NonNull Consumer<ScopedSystemTransaction<StateSignatureTransaction>> stateSignatureTransactionCallback) {
// no-op
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ void onPreHandle(
* @param round the round that has just reached consensus
* @param state the working state of the network
* @param stateSignatureTransactionCallback a consumer that will be used for callbacks
* @return true if the state should be hashed and signed after this round, false otherwise
*/
void onHandleConsensusRound(
boolean onHandleConsensusRound(
@NonNull Round round,
@NonNull T state,
@NonNull Consumer<ScopedSystemTransaction<StateSignatureTransaction>> stateSignatureTransactionCallback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void onPreHandle(
}

@Override
public void onHandleConsensusRound(
public boolean onHandleConsensusRound(
@NonNull Round round,
@NonNull TurtleTestingToolState turtleTestingToolState,
@NonNull Consumer<ScopedSystemTransaction<StateSignatureTransaction>> stateSignatureTransactionCallback) {
Expand All @@ -55,6 +55,7 @@ public void onHandleConsensusRound(
round.getRoundNum(),
round.getConsensusTimestamp().getNano(),
round.getConsensusTimestamp().getEpochSecond());
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,12 @@ public void onPreHandle(
}

@Override
public void onHandleConsensusRound(
public boolean onHandleConsensusRound(
@NonNull Round round,
@NonNull PlatformMerkleStateRoot state,
@NonNull Consumer<ScopedSystemTransaction<StateSignatureTransaction>> stateSignatureTransactionCallback) {
// no-op
return true;
}

@Override
Expand Down

0 comments on commit 053a5c1

Please sign in to comment.