Skip to content

Commit

Permalink
feat: log roster history at start of platform (#17182)
Browse files Browse the repository at this point in the history
Signed-off-by: Edward Wertz <edward@swirldslabs.com>
  • Loading branch information
edward-swirldslabs authored Jan 8, 2025
1 parent e539da5 commit 70c450e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024 Hedera Hashgraph, LLC
* Copyright (C) 2024-2025 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -211,6 +211,7 @@ public SwirldsPlatform(@NonNull final PlatformComponentBuilder builder) {
initialPcesFiles = blocks.initialPcesFiles();
notificationEngine = blocks.notificationEngine();

logger.info(STARTUP.getMarker(), "Starting with roster history:\n{}", blocks.rosterHistory());
currentRoster = blocks.rosterHistory().getCurrentRoster();

platformWiring = new PlatformWiring(platformContext, blocks.model(), blocks.applicationCallbacks());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024 Hedera Hashgraph, LLC
* Copyright (C) 2024-2025 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -85,4 +85,30 @@ public Roster getRosterForRound(final long roundNumber) {
}
return null;
}

/**
* Returns the roster history in a JSON compatible format.
*
* @return a JSON representation of the roster history
*/
@Override
@NonNull
public String toString() {
final boolean previousExists = history.size() > 1;

final StringBuilder sb = new StringBuilder();
sb.append("RosterHistory[ currentRosterRound: ")
.append(history.getFirst().roundNumber())
.append(" ][ ");
if (previousExists) {
sb.append("previousRosterRound: ").append(history.get(1).roundNumber());
} else {
sb.append("no previous roster set");
}
sb.append(" ]\nCurrent Roster: ").append(Roster.JSON.toJSON(getCurrentRoster()));
if (previousExists) {
sb.append("\nPrevious Roster: ").append(Roster.JSON.toJSON(getPreviousRoster()));
}
return sb.toString();
}
}

0 comments on commit 70c450e

Please sign in to comment.