Skip to content

Commit

Permalink
fix: ensure TssStatus singleton is non-null (#16884)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Tinker <[email protected]>
  • Loading branch information
tinker-michaelj authored Dec 3, 2024
1 parent d1cbcfb commit 81b8d21
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@

package com.hedera.node.app.tss.schemas;

import static com.hedera.hapi.node.state.tss.RosterToKey.ACTIVE_ROSTER;
import static com.hedera.hapi.node.state.tss.TssKeyingStatus.WAITING_FOR_ENCRYPTION_KEYS;

import com.hedera.hapi.node.base.SemanticVersion;
import com.hedera.hapi.node.state.common.EntityNumber;
import com.hedera.hapi.node.state.tss.RosterToKey;
import com.hedera.hapi.node.state.tss.TssKeyingStatus;
import com.hedera.hapi.node.state.tss.TssStatus;
import com.hedera.hapi.services.auxiliary.tss.TssEncryptionKeyTransactionBody;
import com.hedera.pbj.runtime.io.buffer.Bytes;
Expand Down Expand Up @@ -55,13 +56,9 @@ public V0570TssBaseSchema() {

@Override
public void migrate(@NonNull final MigrationContext ctx) {
if (ctx.isGenesis()) {
final var tssStatusState = ctx.newStates().getSingleton(TSS_STATUS_KEY);
tssStatusState.put(TssStatus.newBuilder()
.ledgerId(Bytes.EMPTY)
.tssKeyingStatus(TssKeyingStatus.WAITING_FOR_ENCRYPTION_KEYS)
.rosterToKey(RosterToKey.ACTIVE_ROSTER)
.build());
final var tssStatusState = ctx.newStates().getSingleton(TSS_STATUS_KEY);
if (tssStatusState.get() == null) {
tssStatusState.put(new TssStatus(WAITING_FOR_ENCRYPTION_KEYS, ACTIVE_ROSTER, Bytes.EMPTY));
}
}

Expand Down

0 comments on commit 81b8d21

Please sign in to comment.