|
28 | 28 | import static com.hedera.node.app.state.HederaRecordCache.DuplicateCheckResult.NO_DUPLICATE;
|
29 | 29 | import static com.hedera.node.app.workflows.handle.HandleContextImpl.PrecedingTransactionCategory.LIMITED_CHILD_RECORDS;
|
30 | 30 | import static com.hedera.node.app.workflows.handle.HandleWorkflow.extraRewardReceivers;
|
31 |
| -import static java.util.Collections.emptySet; |
| 31 | +import static java.util.Collections.emptyMap; |
32 | 32 | import static java.util.Objects.requireNonNull;
|
33 | 33 |
|
34 | 34 | import com.hedera.hapi.node.base.AccountID;
|
|
104 | 104 | import edu.umd.cs.findbugs.annotations.NonNull;
|
105 | 105 | import edu.umd.cs.findbugs.annotations.Nullable;
|
106 | 106 | import java.time.Instant;
|
107 |
| -import java.util.LinkedHashSet; |
| 107 | +import java.util.LinkedHashMap; |
108 | 108 | import java.util.List;
|
| 109 | +import java.util.Map; |
109 | 110 | import java.util.Objects;
|
110 |
| -import java.util.Set; |
111 | 111 | import java.util.function.Function;
|
112 | 112 | import java.util.function.Predicate;
|
113 | 113 | import java.util.function.Supplier;
|
@@ -156,7 +156,7 @@ public class HandleContextImpl implements HandleContext, FeeContext {
|
156 | 156 | private AttributeValidator attributeValidator;
|
157 | 157 | private ExpiryValidator expiryValidator;
|
158 | 158 | private ExchangeRateInfo exchangeRateInfo;
|
159 |
| - private Set<AccountID> dispatchPaidStakerIds; |
| 159 | + private Map<AccountID, Long> dispatchPaidRewards; |
160 | 160 | private PlatformState platformState;
|
161 | 161 |
|
162 | 162 | /**
|
@@ -644,8 +644,8 @@ private <T> T doDispatchChildTransaction(
|
644 | 644 | return castRecordBuilder(childRecordBuilder, recordBuilderClass);
|
645 | 645 | }
|
646 | 646 |
|
647 |
| - public @NonNull Set<AccountID> dispatchPaidStakerIds() { |
648 |
| - return dispatchPaidStakerIds == null ? emptySet() : dispatchPaidStakerIds; |
| 647 | + public @NonNull Map<AccountID, Long> dispatchPaidRewards() { |
| 648 | + return dispatchPaidRewards == null ? emptyMap() : dispatchPaidRewards; |
649 | 649 | }
|
650 | 650 |
|
651 | 651 | private void dispatchSyntheticTxn(
|
@@ -783,36 +783,10 @@ private void dispatchSyntheticTxn(
|
783 | 783 | payer, finalizeContext, function, extraRewardReceivers(txBody, function, childRecordBuilder));
|
784 | 784 | final var paidStakingRewards = childRecordBuilder.getPaidStakingRewards();
|
785 | 785 | if (!paidStakingRewards.isEmpty()) {
|
786 |
| - if (dispatchPaidStakerIds == null) { |
787 |
| - dispatchPaidStakerIds = new LinkedHashSet<>(); |
| 786 | + if (dispatchPaidRewards == null) { |
| 787 | + dispatchPaidRewards = new LinkedHashMap<>(); |
788 | 788 | }
|
789 |
| - paidStakingRewards.forEach(aa -> dispatchPaidStakerIds.add(aa.accountIDOrThrow())); |
790 |
| - } |
791 |
| - } else { |
792 |
| - final var finalizeContext = new ChildFinalizeContextImpl( |
793 |
| - new ReadableStoreFactory(childStack), |
794 |
| - new WritableStoreFactory(childStack, TokenService.NAME), |
795 |
| - childRecordBuilder); |
796 |
| - childRecordFinalizer.finalizeChildRecord(finalizeContext, function); |
797 |
| - } |
798 |
| - // For mono-service fidelity, we need to attach staking rewards for a |
799 |
| - // triggered transaction to the record of the child here, and not the |
800 |
| - // "parent" ScheduleCreate or ScheduleSign transaction |
801 |
| - if (childCategory == SCHEDULED) { |
802 |
| - final var finalizeContext = new TriggeredFinalizeContext( |
803 |
| - new ReadableStoreFactory(childStack), |
804 |
| - new WritableStoreFactory(childStack, TokenService.NAME), |
805 |
| - childRecordBuilder, |
806 |
| - consensusNow(), |
807 |
| - configuration); |
808 |
| - parentRecordFinalizer.finalizeParentRecord( |
809 |
| - payer, finalizeContext, function, extraRewardReceivers(txBody, function, childRecordBuilder)); |
810 |
| - final var paidStakingRewards = childRecordBuilder.getPaidStakingRewards(); |
811 |
| - if (!paidStakingRewards.isEmpty()) { |
812 |
| - if (dispatchPaidStakerIds == null) { |
813 |
| - dispatchPaidStakerIds = new LinkedHashSet<>(); |
814 |
| - } |
815 |
| - paidStakingRewards.forEach(aa -> dispatchPaidStakerIds.add(aa.accountIDOrThrow())); |
| 789 | + paidStakingRewards.forEach(aa -> dispatchPaidRewards.put(aa.accountIDOrThrow(), aa.amount())); |
816 | 790 | }
|
817 | 791 | } else {
|
818 | 792 | final var finalizeContext = new ChildFinalizeContextImpl(
|
|
0 commit comments