Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interface SchedulableState : ContractState {
- /**
- * Indicate whether there is some activity to be performed at some future point in time with respect to this
- * [ContractState], what that activity is and at what point in time it should be initiated.
- * This can be used to implement deadlines for payment or processing of financial instruments according to a schedule.
- *
- * The state has no reference to it's own StateRef, so supply that for use as input to any FlowLogic constructed.
- *
- * @return null if there is no activity to schedule.
- */
- fun nextScheduledActivity(thisStateRef: StateRef, flowLogicRefFactory: FlowLogicRefFactory): ScheduledActivity?
- }
- class ExampleState(val initiator: Party,
- val requestTime: Instant,
- val delay: Long) : SchedulableState {
- override val contract: Contract get() = DUMMY_PROGRAM_ID
- override val participants: List<AbstractParty> get() = listOf(initiator)
- override fun nextScheduledActivity(thisStateRef: StateRef, flowLogicRefFactory: FlowLogicRefFactory): ScheduledActivity? {
- val responseTime = requestTime.plusSeconds(delay)
- val flowRef = flowLogicRefFactory.create(FlowToStart::class.java)
- return ScheduledActivity(flowRef, responseTime)
- }
- }
- @InitiatingFlow
- @SchedulableFlow
- class FlowToStart : FlowLogic<Unit>() {
- @Suspendable
- override fun call() {
- // Do stuff.
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement