mirror of
https://github.com/corda/corda.git
synced 2025-02-20 17:33:15 +00:00
node: Remove TransactionBuildResult.Complete, add pretty printing of ServiceToClientEvent
This commit is contained in:
parent
9cda99bbcc
commit
cfebccc495
@ -1,10 +1,7 @@
|
||||
package com.r3corda.node.services.monitor
|
||||
|
||||
import com.r3corda.core.contracts.*
|
||||
import com.r3corda.core.crypto.Party
|
||||
import com.r3corda.core.serialization.OpaqueBytes
|
||||
import com.r3corda.node.utilities.AddOrRemove
|
||||
import java.security.PublicKey
|
||||
import java.time.Instant
|
||||
import java.util.*
|
||||
|
||||
@ -12,25 +9,34 @@ import java.util.*
|
||||
* Events triggered by changes in the node, and sent to monitoring client(s).
|
||||
*/
|
||||
sealed class ServiceToClientEvent(val time: Instant) {
|
||||
class Transaction(time: Instant, val transaction: SignedTransaction) : ServiceToClientEvent(time)
|
||||
class OutputState(time: Instant, val consumed: Set<StateRef>, val produced: Set<StateAndRef<ContractState>>) : ServiceToClientEvent(time)
|
||||
class StateMachine(time: Instant, val fiberId: Long, val label: String, val addOrRemove: AddOrRemove) : ServiceToClientEvent(time)
|
||||
class Progress(time: Instant, val fiberId: Long, val message: String) : ServiceToClientEvent(time)
|
||||
class TransactionBuild(time: Instant, val id: UUID, val state: TransactionBuildResult) : ServiceToClientEvent(time)
|
||||
class Transaction(time: Instant, val transaction: SignedTransaction) : ServiceToClientEvent(time) {
|
||||
override fun toString() = "Transaction(${transaction.tx.commands})"
|
||||
}
|
||||
class OutputState(
|
||||
time: Instant,
|
||||
val consumed: Set<StateRef>,
|
||||
val produced: Set<StateAndRef<ContractState>>
|
||||
) : ServiceToClientEvent(time) {
|
||||
override fun toString() = "OutputState(consumed=$consumed, produced=${produced.map { it.state.data.javaClass.simpleName } })"
|
||||
}
|
||||
class StateMachine(
|
||||
time: Instant,
|
||||
val fiberId: Long,
|
||||
val label: String,
|
||||
val addOrRemove: AddOrRemove
|
||||
) : ServiceToClientEvent(time) {
|
||||
override fun toString() = "StateMachine(${addOrRemove.name})"
|
||||
}
|
||||
class Progress(time: Instant, val fiberId: Long, val message: String) : ServiceToClientEvent(time) {
|
||||
override fun toString() = "Progress($message)"
|
||||
}
|
||||
class TransactionBuild(time: Instant, val id: UUID, val state: TransactionBuildResult) : ServiceToClientEvent(time) {
|
||||
override fun toString() = "TransactionBuild($state)"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sealed class TransactionBuildResult {
|
||||
/**
|
||||
* State indicating the action undertaken has been completed (it was not complex enough to require a
|
||||
* state machine starting).
|
||||
*
|
||||
* @param transaction the transaction created as a result.
|
||||
*/
|
||||
// TODO: We should have a consistent "Transaction your request triggered has been built" event, rather than these
|
||||
// once-off results from a request. Unclear if that means all requests need to trigger a protocol state machine,
|
||||
// so the client sees a consistent process, or if some other solution can be found.
|
||||
class Complete(val transaction: SignedTransaction, val message: String?) : TransactionBuildResult()
|
||||
|
||||
/**
|
||||
* State indicating that a protocol is managing this request, and that the client should track protocol state machine
|
||||
* updates for further information. The monitor will separately receive notification of the state machine having been
|
||||
@ -39,11 +45,15 @@ sealed class TransactionBuildResult {
|
||||
*
|
||||
* @param transaction the transaction created as a result, in the case where the protocol has completed.
|
||||
*/
|
||||
class ProtocolStarted(val fiberId: Long, val transaction: SignedTransaction?, val message: String?) : TransactionBuildResult()
|
||||
class ProtocolStarted(val fiberId: Long, val transaction: SignedTransaction?, val message: String?) : TransactionBuildResult() {
|
||||
override fun toString() = "Started($message)"
|
||||
}
|
||||
|
||||
/**
|
||||
* State indicating the action undertaken failed, either directly (it is not something which requires a
|
||||
* state machine), or before a state machine was started.
|
||||
*/
|
||||
class Failed(val message: String?) : TransactionBuildResult()
|
||||
class Failed(val message: String?) : TransactionBuildResult() {
|
||||
override fun toString() = "Failed($message)"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user