Skip to content

Commit

Permalink
refactor: implementation
Browse files Browse the repository at this point in the history
Signed-off-by: Mustafa Uzun <mustafa.uzun@limechain.tech>
  • Loading branch information
mustafauzunn committed Jan 10, 2025
1 parent f431ee8 commit 41599d5
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import com.hedera.hapi.node.base.SemanticVersion;
import com.hedera.hapi.platform.event.StateSignatureTransaction;
import com.hedera.pbj.runtime.ParseException;
import com.swirlds.common.constructable.ConstructableIgnored;
import com.swirlds.common.crypto.DigestType;
import com.swirlds.common.merkle.MerkleNode;
Expand Down Expand Up @@ -50,6 +51,7 @@
import com.swirlds.platform.system.events.ConsensusEvent;
import com.swirlds.platform.system.events.Event;
import com.swirlds.platform.system.transaction.ConsensusTransaction;
import com.swirlds.platform.system.transaction.Transaction;
import com.swirlds.virtualmap.VirtualMap;
import com.swirlds.virtualmap.datasource.VirtualDataSourceBuilder;
import edu.umd.cs.findbugs.annotations.NonNull;
Expand Down Expand Up @@ -286,8 +288,7 @@ public void preHandle(
@NonNull Consumer<ScopedSystemTransaction<StateSignatureTransaction>> stateSignatureTransaction) {
event.forEachTransaction(transaction -> {
if (!transaction.isSystem() && isSystemTransaction(transaction.getApplicationTransaction())) {
stateSignatureTransaction.accept(
new ScopedSystemTransaction(event.getCreatorId(), event.getSoftwareVersion(), transaction));
consumeSystemTransaction(transaction, event, stateSignatureTransaction);
}
});
}
Expand All @@ -310,8 +311,7 @@ public void handleConsensusRound(
continue;
}
if (isSystemTransaction(trans.getApplicationTransaction())) {
stateSignatureTransaction.accept(
new ScopedSystemTransaction(event.getCreatorId(), event.getSoftwareVersion(), event));
consumeSystemTransaction(trans, event, stateSignatureTransaction);
continue;
}

Expand Down Expand Up @@ -355,4 +355,18 @@ public int getVersion() {
public int getMinimumSupportedVersion() {
return ClassVersion.VIRTUAL_MAP;
}

private void consumeSystemTransaction(
final Transaction transaction,
final Event event,
final Consumer<ScopedSystemTransaction<StateSignatureTransaction>> stateSignatureTransactionCallback) {
try {
final var stateSignatureTransaction =
StateSignatureTransaction.PROTOBUF.parse(transaction.getApplicationTransaction());
stateSignatureTransactionCallback.accept(new ScopedSystemTransaction<>(
event.getCreatorId(), event.getSoftwareVersion(), stateSignatureTransaction));
} catch (final ParseException e) {
logger.error("Failed to parse StateSignatureTransaction", e);

Check warning on line 369 in platform-sdk/platform-apps/tests/MigrationTestingTool/src/main/java/com/swirlds/demo/migration/MigrationTestingToolState.java

View check run for this annotation

Codecov / codecov/patch

platform-sdk/platform-apps/tests/MigrationTestingTool/src/main/java/com/swirlds/demo/migration/MigrationTestingToolState.java#L368-L369

Added lines #L368 - L369 were not covered by tests
}
}
}

0 comments on commit 41599d5

Please sign in to comment.