Skip to content

Commit

Permalink
Put EOP memo on record not synth txn
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Tinker <michael.tinker@swirldslabs.com>
  • Loading branch information
tinker-michaelj committed Dec 16, 2023
1 parent 9d89905 commit 3792ee0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,25 +225,26 @@ public void updateNodes(@NonNull final TokenContext context) {
final long reservedStakingRewards = stakingRewardsStore.pendingRewards();
final long unreservedStakingRewardBalance = rewardAccountBalance - reservedStakingRewards;
final var syntheticNodeStakeUpdateTxn = newNodeStakeUpdateBuilder(
lastInstantOfPreviousPeriodFor(consensusTime),
finalNodeStakes,
stakingConfig,
totalStakedRewardStart,
perHbarRate,
reservedStakingRewards,
unreservedStakingRewardBalance,
stakingConfig.rewardBalanceThreshold(),
stakingConfig.maxStakeRewarded())
.memo("End of staking period calculation record");
lastInstantOfPreviousPeriodFor(consensusTime),
finalNodeStakes,
stakingConfig,
totalStakedRewardStart,
perHbarRate,
reservedStakingRewards,
unreservedStakingRewardBalance,
stakingConfig.rewardBalanceThreshold(),
stakingConfig.maxStakeRewarded());
log.info("Exporting:\n{}", finalNodeStakes);
// We don't want to fail adding the preceding child record for the node stake update that happens every
// midnight. So, we add the preceding child record builder as unchecked, that doesn't fail with
// MAX_CHILD_RECORDS_EXCEEDED
final var nodeStakeUpdateBuilder =
context.addUncheckedPrecedingChildRecordBuilder(NodeStakeUpdateRecordBuilder.class);
nodeStakeUpdateBuilder.transaction(Transaction.newBuilder()
.body(syntheticNodeStakeUpdateTxn.build())
.build());
nodeStakeUpdateBuilder
.transaction(Transaction.newBuilder()
.body(syntheticNodeStakeUpdateTxn.build())
.build())
.memo("End of staking period calculation record");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class FakeNodeStakeUpdateRecordBuilder {

public NodeStakeUpdateRecordBuilder create() {
return new NodeStakeUpdateRecordBuilder() {
private String memo;
private Transaction txn;

@NotNull
Expand All @@ -32,6 +33,13 @@ public NodeStakeUpdateRecordBuilder transaction(@NotNull final Transaction txn)
this.txn = txn;
return this;
}

@NotNull
@Override
public NodeStakeUpdateRecordBuilder memo(@NotNull String memo) {
this.memo = memo;
return this;
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,13 @@ public interface NodeStakeUpdateRecordBuilder {
*/
@NonNull
NodeStakeUpdateRecordBuilder transaction(@NonNull final Transaction transaction);

/**
* Sets the record's memo.
*
* @param memo the memo
* @return the builder
*/
@NonNull
NodeStakeUpdateRecordBuilder memo(@NonNull final String memo);
}

0 comments on commit 3792ee0

Please sign in to comment.