Skip to content

Commit

Permalink
Made suggested changes.
Browse files Browse the repository at this point in the history
Signed-off-by: Cody Littley <cody@swirldslabs.com>
  • Loading branch information
cody-littley committed May 10, 2023
1 parent c2114cb commit 2279708
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Expand Up @@ -28,7 +28,6 @@
import com.swirlds.common.system.NodeId;
import com.swirlds.common.threading.manager.ThreadManager;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
Expand Down Expand Up @@ -110,7 +109,7 @@ public EventStreamManager(
try {
Files.createDirectories(Paths.get(eventStreamDir));
} catch (final IOException e) {
throw new UncheckedIOException(e);
throw new IllegalStateException("Can not create directory for event stream", e);
}

streamFileWriter = new TimestampStreamFileWriter<>(
Expand Down
Expand Up @@ -359,7 +359,7 @@ public class SwirldsPlatform implements Platform, PlatformWithDeprecatedMethods,
/** Stores and passes pre-consensus events to {@link SwirldStateManager} for handling */
private final PreConsensusEventHandler preConsensusEventHandler;
/** Stores and processes consensus events including sending them to {@link SwirldStateManager} for handling */
private ConsensusRoundHandler consensusRoundHandler;
private final ConsensusRoundHandler consensusRoundHandler;
/** Handles all interaction with {@link SwirldState} */
private final SwirldStateManager swirldStateManager;
/** Checks the validity of transactions and submits valid ones to the event transaction pool */
Expand Down Expand Up @@ -535,7 +535,6 @@ public class SwirldsPlatform implements Platform, PlatformWithDeprecatedMethods,

this.shadowGraph = new ShadowGraph(syncMetrics, initialAddressBook.getSize());

this.consensusRoundHandler = null;
this.swirldId = swirldId.clone();
this.crypto = crypto;

Expand Down Expand Up @@ -655,14 +654,19 @@ public class SwirldsPlatform implements Platform, PlatformWithDeprecatedMethods,
.toString());

stateToLoad = loadedState.initialState;
consensusRoundHandler.loadDataFromSignedState(signedStateFromDisk, false);

} else {
stateToLoad = buildGenesisState(this, initialAddressBook, appVersion, genesisStateBuilder);

// if we are not starting from a saved state, don't freeze on startup
startUpEventFrozenManager.setStartUpEventFrozenEndTime(null);
}

if (stateToLoad == null) {
// this should be impossible
throw new IllegalStateException("stateToLoad is null");
}

swirldStateManager = PlatformConstructor.swirldStateManager(
platformContext,
initialAddressBook,
Expand Down Expand Up @@ -693,6 +697,10 @@ public class SwirldsPlatform implements Platform, PlatformWithDeprecatedMethods,
stateManagementComponent::roundAppliedToState,
appVersion));

if (signedStateFromDisk != null) {
consensusRoundHandler.loadDataFromSignedState(signedStateFromDisk, false);
}

final AddedEventMetrics addedEventMetrics = new AddedEventMetrics(this.selfId, metrics);
final PreconsensusEventStreamSequencer sequencer = new PreconsensusEventStreamSequencer();

Expand Down

0 comments on commit 2279708

Please sign in to comment.