-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1303 from hashgraph/handle-repeated-signings
Abort ScheduleSignTransitionLogic if schedule is resolved
- Loading branch information
Showing
18 changed files
with
1,794 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
hedera-node/src/main/java/com/hedera/services/txns/schedule/ScheduleExecutor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package com.hedera.services.txns.schedule; | ||
|
||
/*- | ||
* | ||
* Hedera Services Node | ||
* | ||
* Copyright (C) 2018 - 2021 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
import com.google.protobuf.InvalidProtocolBufferException; | ||
import com.hedera.services.context.TransactionContext; | ||
import com.hedera.services.store.schedule.ScheduleStore; | ||
import com.hedera.services.utils.TriggeredTxnAccessor; | ||
import com.hederahashgraph.api.proto.java.ResponseCodeEnum; | ||
import com.hederahashgraph.api.proto.java.ScheduleID; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.OK; | ||
|
||
/** | ||
* Defines a final class to handle scheduled transaction execution once the scheduled transaction is signed by the | ||
* required number of parties. | ||
* | ||
* @author Michael Tinker | ||
* @author Abhishek Pandey | ||
*/ | ||
public final class ScheduleExecutor { | ||
/** | ||
* Given a {@link ScheduleID}, {@link ScheduleStore}, {@link TransactionContext} it first checks if the underlying | ||
* transaction is already executed/deleted before attempting to execute and then returns response code after | ||
* triggering the underlying transaction. A ResponseEnumCode of OK is returned upon successful trigger of the | ||
* inner transaction. The arguments cannot be null, the return type would always be a proper ResponseEnumCode. | ||
* | ||
* @param id The non null id of the scheduled transaction. | ||
* @param store A non null object to handle scheduled entity type. | ||
* @param context A non null object to handle inner transaction specific context on a node. | ||
* @return the response code {@link ResponseCodeEnum} from executing the inner scheduled transaction | ||
*/ | ||
ResponseCodeEnum processExecution( | ||
@NotNull ScheduleID id, | ||
@NotNull ScheduleStore store, | ||
@NotNull TransactionContext context | ||
) throws | ||
InvalidProtocolBufferException, NullPointerException { | ||
final var executionStatus = store.markAsExecuted(id); | ||
if (executionStatus != OK) { | ||
return executionStatus; | ||
} | ||
|
||
final var schedule = store.get(id); | ||
final var transaction = schedule.asSignedTxn(); | ||
context.trigger( | ||
new TriggeredTxnAccessor( | ||
transaction.toByteArray(), | ||
schedule.effectivePayer().toGrpcAccountId(), | ||
id)); | ||
return OK; | ||
} | ||
} |
56 changes: 0 additions & 56 deletions
56
hedera-node/src/main/java/com/hedera/services/txns/schedule/ScheduleReadyForExecution.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.