mirror of
https://github.com/corda/corda.git
synced 2025-06-19 07:38:22 +00:00
Java code can now extend core FlowLogics which don't return anything (by using Void? instead of Unit)
This commit is contained in:
@ -115,8 +115,10 @@ abstract class AbstractStateReplacementFlow {
|
||||
}
|
||||
}
|
||||
|
||||
// Type parameter should ideally be Unit but that prevents Java code from subclassing it (https://youtrack.jetbrains.com/issue/KT-15964).
|
||||
// We use Void? instead of Unit? as that's what you'd use in Java.
|
||||
abstract class Acceptor<in T>(val otherSide: Party,
|
||||
override val progressTracker: ProgressTracker = tracker()) : FlowLogic<Unit>() {
|
||||
override val progressTracker: ProgressTracker = tracker()) : FlowLogic<Void?>() {
|
||||
companion object {
|
||||
object VERIFYING : ProgressTracker.Step("Verifying state replacement proposal")
|
||||
object APPROVING : ProgressTracker.Step("State replacement approved")
|
||||
@ -126,7 +128,7 @@ abstract class AbstractStateReplacementFlow {
|
||||
|
||||
@Suspendable
|
||||
@Throws(StateReplacementException::class)
|
||||
override fun call() {
|
||||
override fun call(): Void? {
|
||||
progressTracker.currentStep = VERIFYING
|
||||
val maybeProposal: UntrustworthyData<Proposal<T>> = receive(otherSide)
|
||||
val stx: SignedTransaction = maybeProposal.unwrap {
|
||||
@ -135,6 +137,7 @@ abstract class AbstractStateReplacementFlow {
|
||||
it.stx
|
||||
}
|
||||
approve(stx)
|
||||
return null
|
||||
}
|
||||
|
||||
@Suspendable
|
||||
|
@ -85,15 +85,17 @@ object NotaryFlow {
|
||||
*
|
||||
* Additional transaction validation logic can be added when implementing [receiveAndVerifyTx].
|
||||
*/
|
||||
// See AbstractStateReplacementFlow.Acceptor for why it's Void?
|
||||
abstract class Service(val otherSide: Party,
|
||||
val timestampChecker: TimestampChecker,
|
||||
val uniquenessProvider: UniquenessProvider) : FlowLogic<Unit>() {
|
||||
val uniquenessProvider: UniquenessProvider) : FlowLogic<Void?>() {
|
||||
@Suspendable
|
||||
override fun call() {
|
||||
override fun call(): Void? {
|
||||
val (id, inputs, timestamp) = receiveAndVerifyTx()
|
||||
validateTimestamp(timestamp)
|
||||
commitInputStates(inputs, id)
|
||||
signAndSendResponse(id)
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user