mirror of
https://github.com/corda/corda.git
synced 2025-02-20 17:33:15 +00:00
Rename stateMachineRunId properties to id, remove unused fiberId
This commit is contained in:
parent
cfa5878ea2
commit
7e7bf08062
@ -86,7 +86,7 @@ class GatheredTransactionDataModel {
|
||||
is ServiceToClientEvent.OutputState -> {}
|
||||
is ServiceToClientEvent.StateMachine -> {
|
||||
newFiberIdTransactionStateOrModify(transactionStates, serviceToClientEvent,
|
||||
stateMachineRunId = serviceToClientEvent.stateMachineRunId,
|
||||
stateMachineRunId = serviceToClientEvent.id,
|
||||
tweak = {
|
||||
stateMachineStatus.set(when (serviceToClientEvent.addOrRemove) {
|
||||
AddOrRemove.ADD -> StateMachineStatus.Added(serviceToClientEvent.label)
|
||||
@ -97,7 +97,7 @@ class GatheredTransactionDataModel {
|
||||
}
|
||||
is ServiceToClientEvent.Progress -> {
|
||||
newFiberIdTransactionStateOrModify(transactionStates, serviceToClientEvent,
|
||||
stateMachineRunId = serviceToClientEvent.stateMachineRunId,
|
||||
stateMachineRunId = serviceToClientEvent.id,
|
||||
tweak = {
|
||||
protocolStatus.set(ProtocolStatus(serviceToClientEvent.message))
|
||||
}
|
||||
@ -108,7 +108,7 @@ class GatheredTransactionDataModel {
|
||||
newUuidTransactionStateOrModify(transactionStates, serviceToClientEvent,
|
||||
uuid = serviceToClientEvent.id,
|
||||
stateMachineRunId = when (state) {
|
||||
is TransactionBuildResult.ProtocolStarted -> state.stateMachineId
|
||||
is TransactionBuildResult.ProtocolStarted -> state.id
|
||||
is TransactionBuildResult.Failed -> null
|
||||
},
|
||||
transactionId = when (state) {
|
||||
|
@ -35,10 +35,8 @@ interface ProtocolStateMachine<R> {
|
||||
val serviceHub: ServiceHub
|
||||
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 */
|
||||
val stateMachineRunId: StateMachineRunId
|
||||
val id: StateMachineRunId
|
||||
/** This future will complete when the call method returns. */
|
||||
val resultFuture: ListenableFuture<R>
|
||||
}
|
||||
|
@ -23,13 +23,13 @@ sealed class ServiceToClientEvent(val time: Instant) {
|
||||
}
|
||||
class StateMachine(
|
||||
time: Instant,
|
||||
val stateMachineRunId: StateMachineRunId,
|
||||
val id: StateMachineRunId,
|
||||
val label: String,
|
||||
val addOrRemove: AddOrRemove
|
||||
) : ServiceToClientEvent(time) {
|
||||
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)"
|
||||
}
|
||||
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.
|
||||
*/
|
||||
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)"
|
||||
}
|
||||
|
||||
|
@ -64,15 +64,15 @@ class NodeMonitorService(services: ServiceHubInternal, val smm: StateMachineMana
|
||||
services.storageService.validatedTransactions.updates.subscribe { tx -> notifyTransaction(tx.tx.toLedgerTransaction(services)) }
|
||||
services.vaultService.updates.subscribe { update -> notifyVaultUpdate(update) }
|
||||
smm.changes.subscribe { change ->
|
||||
val stateMachineRunId: StateMachineRunId = change.stateMachineRunId
|
||||
val id: StateMachineRunId = change.id
|
||||
val logic: ProtocolLogic<*> = change.logic
|
||||
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) {
|
||||
when (change.addOrRemove) {
|
||||
AddOrRemove.ADD -> progressTracker.changes.subscribe { progress ->
|
||||
notifyEvent(ServiceToClientEvent.Progress(Instant.now(), stateMachineRunId, progress.toString()))
|
||||
notifyEvent(ServiceToClientEvent.Progress(Instant.now(), id, progress.toString()))
|
||||
}
|
||||
AddOrRemove.REMOVE -> {
|
||||
// Nothing to do
|
||||
@ -169,7 +169,7 @@ class NodeMonitorService(services: ServiceHubInternal, val smm: StateMachineMana
|
||||
val tx = builder.toSignedTransaction(checkSufficientSignatures = false)
|
||||
val protocol = FinalityProtocol(tx, setOf(req), setOf(req.recipient))
|
||||
return TransactionBuildResult.ProtocolStarted(
|
||||
smm.add(BroadcastTransactionProtocol.TOPIC, protocol).stateMachineRunId,
|
||||
smm.add(BroadcastTransactionProtocol.TOPIC, protocol).id,
|
||||
tx.tx.toLedgerTransaction(services),
|
||||
"Cash payment transaction generated"
|
||||
)
|
||||
@ -203,7 +203,7 @@ class NodeMonitorService(services: ServiceHubInternal, val smm: StateMachineMana
|
||||
val tx = builder.toSignedTransaction(checkSufficientSignatures = false)
|
||||
val protocol = FinalityProtocol(tx, setOf(req), participants)
|
||||
return TransactionBuildResult.ProtocolStarted(
|
||||
smm.add(BroadcastTransactionProtocol.TOPIC, protocol).stateMachineRunId,
|
||||
smm.add(BroadcastTransactionProtocol.TOPIC, protocol).id,
|
||||
tx.tx.toLedgerTransaction(services),
|
||||
"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
|
||||
val protocol = BroadcastTransactionProtocol(tx, setOf(req), setOf(req.recipient))
|
||||
return TransactionBuildResult.ProtocolStarted(
|
||||
smm.add(BroadcastTransactionProtocol.TOPIC, protocol).stateMachineRunId,
|
||||
smm.add(BroadcastTransactionProtocol.TOPIC, protocol).id,
|
||||
tx.tx.toLedgerTransaction(services),
|
||||
"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
|
||||
* 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>,
|
||||
scheduler: FiberScheduler,
|
||||
private val loggerName: String)
|
||||
@ -59,11 +59,6 @@ class ProtocolStateMachineImpl<R>(override val stateMachineRunId: StateMachineRu
|
||||
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 {
|
||||
logic.psm = this
|
||||
|
@ -65,7 +65,7 @@ class StateMachineManager(val serviceHub: ServiceHubInternal, tokenizableService
|
||||
data class Change(
|
||||
val logic: ProtocolLogic<*>,
|
||||
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
|
||||
@ -76,7 +76,7 @@ class StateMachineManager(val serviceHub: ServiceHubInternal, tokenizableService
|
||||
val changesPublisher = PublishSubject.create<Change>()
|
||||
|
||||
fun notifyChangeObservers(psm: ProtocolStateMachineImpl<*>, addOrRemove: AddOrRemove) {
|
||||
changesPublisher.onNext(Change(psm.logic, addOrRemove, psm.stateMachineRunId))
|
||||
changesPublisher.onNext(Change(psm.logic, addOrRemove, psm.id))
|
||||
}
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user