mirror of
https://github.com/corda/corda.git
synced 2025-06-22 17:09:00 +00:00
Rename stateMachineRunId properties to id, remove unused fiberId
This commit is contained in:
@ -86,7 +86,7 @@ class GatheredTransactionDataModel {
|
|||||||
is ServiceToClientEvent.OutputState -> {}
|
is ServiceToClientEvent.OutputState -> {}
|
||||||
is ServiceToClientEvent.StateMachine -> {
|
is ServiceToClientEvent.StateMachine -> {
|
||||||
newFiberIdTransactionStateOrModify(transactionStates, serviceToClientEvent,
|
newFiberIdTransactionStateOrModify(transactionStates, serviceToClientEvent,
|
||||||
stateMachineRunId = serviceToClientEvent.stateMachineRunId,
|
stateMachineRunId = serviceToClientEvent.id,
|
||||||
tweak = {
|
tweak = {
|
||||||
stateMachineStatus.set(when (serviceToClientEvent.addOrRemove) {
|
stateMachineStatus.set(when (serviceToClientEvent.addOrRemove) {
|
||||||
AddOrRemove.ADD -> StateMachineStatus.Added(serviceToClientEvent.label)
|
AddOrRemove.ADD -> StateMachineStatus.Added(serviceToClientEvent.label)
|
||||||
@ -97,7 +97,7 @@ class GatheredTransactionDataModel {
|
|||||||
}
|
}
|
||||||
is ServiceToClientEvent.Progress -> {
|
is ServiceToClientEvent.Progress -> {
|
||||||
newFiberIdTransactionStateOrModify(transactionStates, serviceToClientEvent,
|
newFiberIdTransactionStateOrModify(transactionStates, serviceToClientEvent,
|
||||||
stateMachineRunId = serviceToClientEvent.stateMachineRunId,
|
stateMachineRunId = serviceToClientEvent.id,
|
||||||
tweak = {
|
tweak = {
|
||||||
protocolStatus.set(ProtocolStatus(serviceToClientEvent.message))
|
protocolStatus.set(ProtocolStatus(serviceToClientEvent.message))
|
||||||
}
|
}
|
||||||
@ -108,7 +108,7 @@ class GatheredTransactionDataModel {
|
|||||||
newUuidTransactionStateOrModify(transactionStates, serviceToClientEvent,
|
newUuidTransactionStateOrModify(transactionStates, serviceToClientEvent,
|
||||||
uuid = serviceToClientEvent.id,
|
uuid = serviceToClientEvent.id,
|
||||||
stateMachineRunId = when (state) {
|
stateMachineRunId = when (state) {
|
||||||
is TransactionBuildResult.ProtocolStarted -> state.stateMachineId
|
is TransactionBuildResult.ProtocolStarted -> state.id
|
||||||
is TransactionBuildResult.Failed -> null
|
is TransactionBuildResult.Failed -> null
|
||||||
},
|
},
|
||||||
transactionId = when (state) {
|
transactionId = when (state) {
|
||||||
|
@ -35,10 +35,8 @@ interface ProtocolStateMachine<R> {
|
|||||||
val serviceHub: ServiceHub
|
val serviceHub: ServiceHub
|
||||||
val logger: Logger
|
val logger: Logger
|
||||||
|
|
||||||
/** Unique ID for this machine, valid only while it is in memory. */
|
|
||||||
val machineId: Long
|
|
||||||
/** Unique ID for this machine run, valid across restarts */
|
/** Unique ID for this machine run, valid across restarts */
|
||||||
val stateMachineRunId: StateMachineRunId
|
val id: StateMachineRunId
|
||||||
/** This future will complete when the call method returns. */
|
/** This future will complete when the call method returns. */
|
||||||
val resultFuture: ListenableFuture<R>
|
val resultFuture: ListenableFuture<R>
|
||||||
}
|
}
|
||||||
|
@ -23,13 +23,13 @@ sealed class ServiceToClientEvent(val time: Instant) {
|
|||||||
}
|
}
|
||||||
class StateMachine(
|
class StateMachine(
|
||||||
time: Instant,
|
time: Instant,
|
||||||
val stateMachineRunId: StateMachineRunId,
|
val id: StateMachineRunId,
|
||||||
val label: String,
|
val label: String,
|
||||||
val addOrRemove: AddOrRemove
|
val addOrRemove: AddOrRemove
|
||||||
) : ServiceToClientEvent(time) {
|
) : ServiceToClientEvent(time) {
|
||||||
override fun toString() = "StateMachine($label, ${addOrRemove.name})"
|
override fun toString() = "StateMachine($label, ${addOrRemove.name})"
|
||||||
}
|
}
|
||||||
class Progress(time: Instant, val stateMachineRunId: StateMachineRunId, val message: String) : ServiceToClientEvent(time) {
|
class Progress(time: Instant, val id: StateMachineRunId, val message: String) : ServiceToClientEvent(time) {
|
||||||
override fun toString() = "Progress($message)"
|
override fun toString() = "Progress($message)"
|
||||||
}
|
}
|
||||||
class TransactionBuild(time: Instant, val id: UUID, val state: TransactionBuildResult) : ServiceToClientEvent(time) {
|
class TransactionBuild(time: Instant, val id: UUID, val state: TransactionBuildResult) : ServiceToClientEvent(time) {
|
||||||
@ -47,7 +47,7 @@ sealed class TransactionBuildResult {
|
|||||||
*
|
*
|
||||||
* @param transaction the transaction created as a result, in the case where the protocol has completed.
|
* @param transaction the transaction created as a result, in the case where the protocol has completed.
|
||||||
*/
|
*/
|
||||||
class ProtocolStarted(val stateMachineId: StateMachineRunId, val transaction: LedgerTransaction?, val message: String?) : TransactionBuildResult() {
|
class ProtocolStarted(val id: StateMachineRunId, val transaction: LedgerTransaction?, val message: String?) : TransactionBuildResult() {
|
||||||
override fun toString() = "Started($message)"
|
override fun toString() = "Started($message)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,15 +64,15 @@ class NodeMonitorService(services: ServiceHubInternal, val smm: StateMachineMana
|
|||||||
services.storageService.validatedTransactions.updates.subscribe { tx -> notifyTransaction(tx.tx.toLedgerTransaction(services)) }
|
services.storageService.validatedTransactions.updates.subscribe { tx -> notifyTransaction(tx.tx.toLedgerTransaction(services)) }
|
||||||
services.vaultService.updates.subscribe { update -> notifyVaultUpdate(update) }
|
services.vaultService.updates.subscribe { update -> notifyVaultUpdate(update) }
|
||||||
smm.changes.subscribe { change ->
|
smm.changes.subscribe { change ->
|
||||||
val stateMachineRunId: StateMachineRunId = change.stateMachineRunId
|
val id: StateMachineRunId = change.id
|
||||||
val logic: ProtocolLogic<*> = change.logic
|
val logic: ProtocolLogic<*> = change.logic
|
||||||
val progressTracker = logic.progressTracker
|
val progressTracker = logic.progressTracker
|
||||||
|
|
||||||
notifyEvent(ServiceToClientEvent.StateMachine(Instant.now(), stateMachineRunId, logic.javaClass.name, change.addOrRemove))
|
notifyEvent(ServiceToClientEvent.StateMachine(Instant.now(), id, logic.javaClass.name, change.addOrRemove))
|
||||||
if (progressTracker != null) {
|
if (progressTracker != null) {
|
||||||
when (change.addOrRemove) {
|
when (change.addOrRemove) {
|
||||||
AddOrRemove.ADD -> progressTracker.changes.subscribe { progress ->
|
AddOrRemove.ADD -> progressTracker.changes.subscribe { progress ->
|
||||||
notifyEvent(ServiceToClientEvent.Progress(Instant.now(), stateMachineRunId, progress.toString()))
|
notifyEvent(ServiceToClientEvent.Progress(Instant.now(), id, progress.toString()))
|
||||||
}
|
}
|
||||||
AddOrRemove.REMOVE -> {
|
AddOrRemove.REMOVE -> {
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
@ -169,7 +169,7 @@ class NodeMonitorService(services: ServiceHubInternal, val smm: StateMachineMana
|
|||||||
val tx = builder.toSignedTransaction(checkSufficientSignatures = false)
|
val tx = builder.toSignedTransaction(checkSufficientSignatures = false)
|
||||||
val protocol = FinalityProtocol(tx, setOf(req), setOf(req.recipient))
|
val protocol = FinalityProtocol(tx, setOf(req), setOf(req.recipient))
|
||||||
return TransactionBuildResult.ProtocolStarted(
|
return TransactionBuildResult.ProtocolStarted(
|
||||||
smm.add(BroadcastTransactionProtocol.TOPIC, protocol).stateMachineRunId,
|
smm.add(BroadcastTransactionProtocol.TOPIC, protocol).id,
|
||||||
tx.tx.toLedgerTransaction(services),
|
tx.tx.toLedgerTransaction(services),
|
||||||
"Cash payment transaction generated"
|
"Cash payment transaction generated"
|
||||||
)
|
)
|
||||||
@ -203,7 +203,7 @@ class NodeMonitorService(services: ServiceHubInternal, val smm: StateMachineMana
|
|||||||
val tx = builder.toSignedTransaction(checkSufficientSignatures = false)
|
val tx = builder.toSignedTransaction(checkSufficientSignatures = false)
|
||||||
val protocol = FinalityProtocol(tx, setOf(req), participants)
|
val protocol = FinalityProtocol(tx, setOf(req), participants)
|
||||||
return TransactionBuildResult.ProtocolStarted(
|
return TransactionBuildResult.ProtocolStarted(
|
||||||
smm.add(BroadcastTransactionProtocol.TOPIC, protocol).stateMachineRunId,
|
smm.add(BroadcastTransactionProtocol.TOPIC, protocol).id,
|
||||||
tx.tx.toLedgerTransaction(services),
|
tx.tx.toLedgerTransaction(services),
|
||||||
"Cash destruction transaction generated"
|
"Cash destruction transaction generated"
|
||||||
)
|
)
|
||||||
@ -222,7 +222,7 @@ class NodeMonitorService(services: ServiceHubInternal, val smm: StateMachineMana
|
|||||||
// Issuance transactions do not need to be notarised, so we can skip directly to broadcasting it
|
// Issuance transactions do not need to be notarised, so we can skip directly to broadcasting it
|
||||||
val protocol = BroadcastTransactionProtocol(tx, setOf(req), setOf(req.recipient))
|
val protocol = BroadcastTransactionProtocol(tx, setOf(req), setOf(req.recipient))
|
||||||
return TransactionBuildResult.ProtocolStarted(
|
return TransactionBuildResult.ProtocolStarted(
|
||||||
smm.add(BroadcastTransactionProtocol.TOPIC, protocol).stateMachineRunId,
|
smm.add(BroadcastTransactionProtocol.TOPIC, protocol).id,
|
||||||
tx.tx.toLedgerTransaction(services),
|
tx.tx.toLedgerTransaction(services),
|
||||||
"Cash issuance completed"
|
"Cash issuance completed"
|
||||||
)
|
)
|
||||||
|
@ -29,7 +29,7 @@ import java.util.concurrent.ExecutionException
|
|||||||
* a protocol invokes a sub-protocol, then it will pass along the PSM to the child. The call method of the topmost
|
* a protocol invokes a sub-protocol, then it will pass along the PSM to the child. The call method of the topmost
|
||||||
* logic element gets to return the value that the entire state machine resolves to.
|
* logic element gets to return the value that the entire state machine resolves to.
|
||||||
*/
|
*/
|
||||||
class ProtocolStateMachineImpl<R>(override val stateMachineRunId: StateMachineRunId,
|
class ProtocolStateMachineImpl<R>(override val id: StateMachineRunId,
|
||||||
val logic: ProtocolLogic<R>,
|
val logic: ProtocolLogic<R>,
|
||||||
scheduler: FiberScheduler,
|
scheduler: FiberScheduler,
|
||||||
private val loggerName: String)
|
private val loggerName: String)
|
||||||
@ -59,11 +59,6 @@ class ProtocolStateMachineImpl<R>(override val stateMachineRunId: StateMachineRu
|
|||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Unique ID for the deserialized instance protocol state machine. This is NOT maintained across a state machine
|
|
||||||
* being serialized and then deserialized.
|
|
||||||
*/
|
|
||||||
override val machineId: Long get() = this.id
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
logic.psm = this
|
logic.psm = this
|
||||||
|
@ -65,7 +65,7 @@ class StateMachineManager(val serviceHub: ServiceHubInternal, tokenizableService
|
|||||||
data class Change(
|
data class Change(
|
||||||
val logic: ProtocolLogic<*>,
|
val logic: ProtocolLogic<*>,
|
||||||
val addOrRemove: AddOrRemove,
|
val addOrRemove: AddOrRemove,
|
||||||
val stateMachineRunId: StateMachineRunId
|
val id: StateMachineRunId
|
||||||
)
|
)
|
||||||
|
|
||||||
// A list of all the state machines being managed by this class. We expose snapshots of it via the stateMachines
|
// A list of all the state machines being managed by this class. We expose snapshots of it via the stateMachines
|
||||||
@ -76,7 +76,7 @@ class StateMachineManager(val serviceHub: ServiceHubInternal, tokenizableService
|
|||||||
val changesPublisher = PublishSubject.create<Change>()
|
val changesPublisher = PublishSubject.create<Change>()
|
||||||
|
|
||||||
fun notifyChangeObservers(psm: ProtocolStateMachineImpl<*>, addOrRemove: AddOrRemove) {
|
fun notifyChangeObservers(psm: ProtocolStateMachineImpl<*>, addOrRemove: AddOrRemove) {
|
||||||
changesPublisher.onNext(Change(psm.logic, addOrRemove, psm.stateMachineRunId))
|
changesPublisher.onNext(Change(psm.logic, addOrRemove, psm.id))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user