Converted sealed data types to be data classes

This commit is contained in:
Shams Asari 2017-03-31 14:42:24 +01:00
parent da92806b99
commit faef877a8d
28 changed files with 108 additions and 159 deletions

View File

@ -30,9 +30,13 @@ data class PartiallyResolvedTransaction(
val inputs: List<ObservableValue<InputResolution>>) {
val id = transaction.id
sealed class InputResolution(val stateRef: StateRef) {
class Unresolved(stateRef: StateRef) : InputResolution(stateRef)
class Resolved(val stateAndRef: StateAndRef<ContractState>) : InputResolution(stateAndRef.ref)
sealed class InputResolution {
abstract val stateRef: StateRef
data class Unresolved(override val stateRef: StateRef) : InputResolution()
data class Resolved(val stateAndRef: StateAndRef<ContractState>) : InputResolution() {
override val stateRef: StateRef get() = stateAndRef.ref
}
}
companion object {
@ -54,22 +58,13 @@ data class PartiallyResolvedTransaction(
}
}
sealed class TransactionCreateStatus(val message: String?) {
class Started(message: String?) : TransactionCreateStatus(message)
class Failed(message: String?) : TransactionCreateStatus(message)
data class FlowStatus(val status: String)
override fun toString(): String = message ?: javaClass.simpleName
}
sealed class StateMachineStatus {
abstract val stateMachineName: String
data class FlowStatus(
val status: String
)
sealed class StateMachineStatus(val stateMachineName: String) {
class Added(stateMachineName: String) : StateMachineStatus(stateMachineName)
class Removed(stateMachineName: String) : StateMachineStatus(stateMachineName)
override fun toString(): String = "${javaClass.simpleName}($stateMachineName)"
data class Added(override val stateMachineName: String) : StateMachineStatus()
data class Removed(override val stateMachineName: String) : StateMachineStatus()
}
data class StateMachineData(

View File

@ -9,9 +9,6 @@ import net.corda.core.transactions.TransactionBuilder
/** Defines transaction build & validation logic for a specific transaction type */
@CordaSerializable
sealed class TransactionType {
override fun equals(other: Any?) = other?.javaClass == javaClass
override fun hashCode() = javaClass.name.hashCode()
/**
* Check that the transaction is valid based on:
* - General platform rules
@ -63,9 +60,9 @@ sealed class TransactionType {
abstract fun verifyTransaction(tx: LedgerTransaction)
/** A general transaction type where transaction validity is determined by custom contract code */
class General : TransactionType() {
object General : TransactionType() {
/** Just uses the default [TransactionBuilder] with no special logic */
class Builder(notary: Party?) : TransactionBuilder(General(), notary) {}
class Builder(notary: Party?) : TransactionBuilder(General, notary)
override fun verifyTransaction(tx: LedgerTransaction) {
verifyNoNotaryChange(tx)
@ -141,12 +138,12 @@ sealed class TransactionType {
* A special transaction type for reassigning a notary for a state. Validation does not involve running
* any contract code, it just checks that the states are unmodified apart from the notary field.
*/
class NotaryChange : TransactionType() {
object NotaryChange : TransactionType() {
/**
* A transaction builder that automatically sets the transaction type to [NotaryChange]
* and adds the list of participants to the signers set for every input state.
*/
class Builder(notary: Party) : TransactionBuilder(NotaryChange(), notary) {
class Builder(notary: Party) : TransactionBuilder(NotaryChange, notary) {
override fun addInputState(stateAndRef: StateAndRef<*>) {
signers.addAll(stateAndRef.state.data.participants)
super.addInputState(stateAndRef)

View File

@ -47,18 +47,10 @@ sealed class CompositeKey {
}
/** The leaf node of the tree a wrapper around a [PublicKey] primitive */
class Leaf(val publicKey: PublicKey) : CompositeKey() {
data class Leaf(val publicKey: PublicKey) : CompositeKey() {
override fun isFulfilledBy(keys: Iterable<PublicKey>) = publicKey in keys
override val keys: Set<PublicKey>
get() = setOf(publicKey)
// TODO: remove once data class inheritance is enabled
override fun equals(other: Any?): Boolean {
return this === other || other is Leaf && other.publicKey == this.publicKey
}
override fun hashCode() = publicKey.hashCode()
override val keys: Set<PublicKey> get() = setOf(publicKey)
override fun toString() = publicKey.toStringShort()
}
@ -70,10 +62,7 @@ sealed class CompositeKey {
* The [threshold] specifies the minimum total weight required (in the simple case the minimum number of child
* signatures required) to satisfy the sub-tree rooted at this node.
*/
class Node(val threshold: Int,
val children: List<CompositeKey>,
val weights: List<Int>) : CompositeKey() {
data class Node(val threshold: Int, val children: List<CompositeKey>, val weights: List<Int>) : CompositeKey() {
override fun isFulfilledBy(keys: Iterable<PublicKey>): Boolean {
val totalWeight = children.mapIndexed { i, childNode ->
if (childNode.isFulfilledBy(keys)) weights[i] else 0
@ -82,35 +71,13 @@ sealed class CompositeKey {
return totalWeight >= threshold
}
override val keys: Set<PublicKey>
get() = children.flatMap { it.keys }.toSet()
// Auto-generated. TODO: remove once data class inheritance is enabled
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other?.javaClass != javaClass) return false
other as Node
if (threshold != other.threshold) return false
if (weights != other.weights) return false
if (children != other.children) return false
return true
}
override fun hashCode(): Int {
var result = threshold
result = 31 * result + weights.hashCode()
result = 31 * result + children.hashCode()
return result
}
override val keys: Set<PublicKey> get() = children.flatMap { it.keys }.toSet()
override fun toString() = "(${children.joinToString()})"
}
/** A helper class for building a [CompositeKey.Node]. */
class Builder() {
class Builder {
private val children: MutableList<CompositeKey> = mutableListOf()
private val weights: MutableList<Int> = mutableListOf()

View File

@ -11,9 +11,11 @@ import java.util.*
* signers, tx type, timestamp. Merkle Tree is kept in a recursive data structure. Building is done bottom up,
* from all leaves' hashes. If number of leaves is not a power of two, the tree is padded with zero hashes.
*/
sealed class MerkleTree(val hash: SecureHash) {
class Leaf(val value: SecureHash) : MerkleTree(value)
class Node(val value: SecureHash, val left: MerkleTree, val right: MerkleTree) : MerkleTree(value)
sealed class MerkleTree {
abstract val hash: SecureHash
data class Leaf(override val hash: SecureHash) : MerkleTree()
data class Node(override val hash: SecureHash, val left: MerkleTree, val right: MerkleTree) : MerkleTree()
companion object {
private fun isPow2(num: Int): Boolean = num and (num-1) == 0

View File

@ -54,9 +54,9 @@ class PartialMerkleTree(val root: PartialTree) {
*/
@CordaSerializable
sealed class PartialTree {
class IncludedLeaf(val hash: SecureHash) : PartialTree()
class Leaf(val hash: SecureHash) : PartialTree()
class Node(val left: PartialTree, val right: PartialTree) : PartialTree()
data class IncludedLeaf(val hash: SecureHash) : PartialTree()
data class Leaf(val hash: SecureHash) : PartialTree()
data class Node(val left: PartialTree, val right: PartialTree) : PartialTree()
}
companion object {
@ -104,10 +104,10 @@ class PartialMerkleTree(val root: PartialTree) {
): Pair<Boolean, PartialTree> {
return when (root) {
is MerkleTree.Leaf ->
if (root.value in includeHashes) {
usedHashes.add(root.value)
Pair(true, PartialTree.IncludedLeaf(root.value))
} else Pair(false, PartialTree.Leaf(root.value))
if (root.hash in includeHashes) {
usedHashes.add(root.hash)
Pair(true, PartialTree.IncludedLeaf(root.hash))
} else Pair(false, PartialTree.Leaf(root.hash))
is MerkleTree.Node -> {
val leftNode = buildPartialTree(root.left, includeHashes, usedHashes)
val rightNode = buildPartialTree(root.right, includeHashes, usedHashes)
@ -117,7 +117,7 @@ class PartialMerkleTree(val root: PartialTree) {
Pair(true, newTree)
} else {
// This node has no included leaves below. Cut the tree here and store a hash as a Leaf.
val newTree = PartialTree.Leaf(root.value)
val newTree = PartialTree.Leaf(root.hash)
Pair(false, newTree)
}
}

View File

@ -18,7 +18,7 @@ sealed class SecureHash(bytes: ByteArray) : OpaqueBytes(bytes) {
}
}
override fun toString() = BaseEncoding.base16().encode(bytes)
override fun toString(): String = BaseEncoding.base16().encode(bytes)
fun prefixChars(prefixLen: Int = 6) = toString().substring(0, prefixLen)
fun hashConcat(other: SecureHash) = (this.bytes + other.bytes).sha256()

View File

@ -26,17 +26,19 @@ data class StateMachineInfo(
val id: StateMachineRunId,
val flowLogicClassName: String,
val progressTrackerStepAndUpdates: Pair<String, Observable<String>>?
)
) {
override fun toString(): String = "${javaClass.simpleName}($id, $flowLogicClassName)"
}
@CordaSerializable
sealed class StateMachineUpdate(val id: StateMachineRunId) {
class Added(val stateMachineInfo: StateMachineInfo) : StateMachineUpdate(stateMachineInfo.id) {
override fun toString() = "Added($id, ${stateMachineInfo.flowLogicClassName})"
sealed class StateMachineUpdate {
abstract val id: StateMachineRunId
data class Added(val stateMachineInfo: StateMachineInfo) : StateMachineUpdate() {
override val id: StateMachineRunId get() = stateMachineInfo.id
}
class Removed(id: StateMachineRunId) : StateMachineUpdate(id) {
override fun toString() = "Removed($id)"
}
data class Removed(override val id: StateMachineRunId) : StateMachineUpdate()
}
/**

View File

@ -21,10 +21,12 @@ import rx.Observable
interface NetworkMapCache {
@CordaSerializable
sealed class MapChange(val node: NodeInfo) {
class Added(node: NodeInfo) : MapChange(node)
class Removed(node: NodeInfo) : MapChange(node)
class Modified(node: NodeInfo, val previousNode: NodeInfo) : MapChange(node)
sealed class MapChange {
abstract val node: NodeInfo
data class Added(override val node: NodeInfo) : MapChange()
data class Removed(override val node: NodeInfo) : MapChange()
data class Modified(override val node: NodeInfo, val previousNode: NodeInfo) : MapChange()
}
/** A list of all nodes the cache is aware of */

View File

@ -7,12 +7,13 @@ import net.corda.core.node.ServiceEntry
/**
* Holds information about a [Party], which may refer to either a specific node or a service.
*/
sealed class PartyInfo() {
sealed class PartyInfo {
abstract val party: Party
class Node(val node: NodeInfo) : PartyInfo() {
override val party = node.legalIdentity
data class Node(val node: NodeInfo) : PartyInfo() {
override val party get() = node.legalIdentity
}
class Service(val service: ServiceEntry) : PartyInfo() {
override val party = service.identity
data class Service(val service: ServiceEntry) : PartyInfo() {
override val party get() = service.identity
}
}

View File

@ -8,7 +8,7 @@ import net.corda.core.serialization.CordaSerializable
* don't need a declared service type.
*/
@CordaSerializable
sealed class ServiceType(val id: String) {
class ServiceType private constructor(val id: String) {
init {
// Enforce:
//
@ -16,9 +16,6 @@ sealed class ServiceType(val id: String) {
// * IDs can only contain alphanumeric, full stop and underscore ASCII characters
require(id.matches(Regex("[a-z][a-zA-Z0-9._]+"))) { id }
}
private class ServiceTypeImpl(baseId: String, subTypeId: String) : ServiceType("$baseId.$subTypeId")
private class ServiceTypeDirect(id: String) : ServiceType(id)
companion object {
val corda: ServiceType
@ -26,7 +23,7 @@ sealed class ServiceType(val id: String) {
val stack = Throwable().stackTrace
val caller = stack.first().className
require(caller.startsWith("net.corda.")) { "Corda ServiceType namespace is reserved for Corda core components" }
return ServiceTypeDirect("corda")
return ServiceType("corda")
}
val notary: ServiceType = corda.getSubType("notary")
@ -35,21 +32,22 @@ sealed class ServiceType(val id: String) {
fun getServiceType(namespace: String, typeId: String): ServiceType {
require(!namespace.startsWith("corda")) { "Corda namespace is protected" }
return ServiceTypeImpl(namespace, typeId)
return baseWithSubType(namespace, typeId)
}
fun parse(id: String): ServiceType = ServiceTypeDirect(id)
fun parse(id: String): ServiceType = ServiceType(id)
private fun baseWithSubType(baseId: String, subTypeId: String) = ServiceType("$baseId.$subTypeId")
}
fun getSubType(subTypeId: String): ServiceType = ServiceTypeImpl(id, subTypeId)
override operator fun equals(other: Any?): Boolean = (other is ServiceType) && (other.id == this.id)
fun getSubType(subTypeId: String): ServiceType = baseWithSubType(id, subTypeId)
fun isSubTypeOf(superType: ServiceType) = (id == superType.id) || id.startsWith(superType.id + ".")
fun isNotary() = isSubTypeOf(notary)
fun isValidatingNotary() = isNotary() && id.contains(".validating")
fun isNetworkMap() = id == networkMap.id
override fun equals(other: Any?): Boolean = other === this || other is ServiceType && other.id == this.id
override fun hashCode(): Int = id.hashCode()
override fun toString(): String = id
}

View File

@ -27,7 +27,7 @@ import java.util.*
* but for the [TransactionType.NotaryChange] transactions it is the set of all input [ContractState.participants].
*/
open class TransactionBuilder(
protected val type: TransactionType = TransactionType.General(),
protected val type: TransactionType = TransactionType.General,
var notary: Party? = null,
var lockId: UUID = (Strand.currentStrand() as? FlowStateMachine<*>)?.id?.uuid ?: UUID.randomUUID(),
protected val inputs: MutableList<StateRef> = arrayListOf(),

View File

@ -37,15 +37,15 @@ import java.util.*
class ProgressTracker(vararg steps: Step) {
@CordaSerializable
sealed class Change {
class Position(val tracker: ProgressTracker, val newStep: Step) : Change() {
data class Position(val tracker: ProgressTracker, val newStep: Step) : Change() {
override fun toString() = newStep.label
}
class Rendering(val tracker: ProgressTracker, val ofStep: Step) : Change() {
data class Rendering(val tracker: ProgressTracker, val ofStep: Step) : Change() {
override fun toString() = ofStep.label
}
class Structural(val tracker: ProgressTracker, val parent: Step) : Change() {
data class Structural(val tracker: ProgressTracker, val parent: Step) : Change() {
override fun toString() = "Structural step change in child of ${parent.label}"
}
}

View File

@ -117,7 +117,7 @@ object NotaryFlow {
private fun validateTimestamp(t: Timestamp?) {
if (t != null && !timestampChecker.isValid(t))
throw NotaryException(NotaryError.TimestampInvalid())
throw NotaryException(NotaryError.TimestampInvalid)
}
/**
@ -163,17 +163,17 @@ class NotaryException(val error: NotaryError) : FlowException("Error response fr
@CordaSerializable
sealed class NotaryError {
class Conflict(val txId: SecureHash, val conflict: SignedData<UniquenessProvider.Conflict>) : NotaryError() {
data class Conflict(val txId: SecureHash, val conflict: SignedData<UniquenessProvider.Conflict>) : NotaryError() {
override fun toString() = "One or more input states for transaction $txId have been used in another transaction"
}
/** Thrown if the time specified in the timestamp command is outside the allowed tolerance */
class TimestampInvalid : NotaryError()
object TimestampInvalid : NotaryError()
class TransactionInvalid(val msg: String) : NotaryError()
class SignaturesInvalid(val msg: String) : NotaryError()
data class TransactionInvalid(val msg: String) : NotaryError()
data class SignaturesInvalid(val msg: String) : NotaryError()
class SignaturesMissing(val cause: SignedTransaction.SignaturesMissingException) : NotaryError() {
data class SignaturesMissing(val cause: SignedTransaction.SignaturesMissingException) : NotaryError() {
override fun toString() = cause.toString()
}
}

View File

@ -31,7 +31,7 @@ class TransactionTests {
commands = emptyList(),
notary = DUMMY_NOTARY,
signers = listOf(DUMMY_KEY_1.public.composite, DUMMY_KEY_2.public.composite),
type = TransactionType.General(),
type = TransactionType.General,
timestamp = null
)
val bytes: SerializedBytes<WireTransaction> = wtx.serialized
@ -76,7 +76,7 @@ class TransactionTests {
null,
signers,
timestamp,
TransactionType.General()
TransactionType.General
)
transaction.type.verify(transaction)
@ -103,7 +103,7 @@ class TransactionTests {
DUMMY_NOTARY,
signers,
timestamp,
TransactionType.General()
TransactionType.General
)
assertFailsWith<TransactionVerificationException.DuplicateInputStates> { transaction.type.verify(transaction) }
@ -130,7 +130,7 @@ class TransactionTests {
notary,
signers,
timestamp,
TransactionType.General()
TransactionType.General
)
assertFailsWith<TransactionVerificationException.NotaryChangeInWrongTransactionType> { transaction.type.verify(transaction) }

View File

@ -226,7 +226,7 @@ class PartialMerkleTreeTest {
commands = testTx.commands,
notary = notary,
signers = listOf(MEGA_CORP_PUBKEY, DUMMY_PUBKEY_1),
type = TransactionType.General(),
type = TransactionType.General,
timestamp = timestamp
)
}

View File

@ -18,7 +18,7 @@ sealed class CashFlowCommand {
/**
* A command to initiate the Cash flow with.
*/
class IssueCash(val amount: Amount<Currency>,
data class IssueCash(val amount: Amount<Currency>,
val issueRef: OpaqueBytes,
val recipient: Party,
val notary: Party) : CashFlowCommand() {
@ -31,7 +31,7 @@ sealed class CashFlowCommand {
* @param amount the amount of currency to issue on to the ledger.
* @param recipient the party to issue the cash to.
*/
class PayCash(val amount: Amount<Currency>, val recipient: Party, val issuerConstraint: Party? = null) : CashFlowCommand() {
data class PayCash(val amount: Amount<Currency>, val recipient: Party, val issuerConstraint: Party? = null) : CashFlowCommand() {
override fun startFlow(proxy: CordaRPCOps) = proxy.startFlow(::CashPaymentFlow, amount, recipient)
}
@ -41,7 +41,7 @@ sealed class CashFlowCommand {
* @param amount the amount of currency to exit from the ledger.
* @param issueRef the reference previously specified on the issuance.
*/
class ExitCash(val amount: Amount<Currency>, val issueRef: OpaqueBytes) : CashFlowCommand() {
data class ExitCash(val amount: Amount<Currency>, val issueRef: OpaqueBytes) : CashFlowCommand() {
override fun startFlow(proxy: CordaRPCOps) = proxy.startFlow(::CashExitFlow, amount, issueRef)
}
}

View File

@ -4,13 +4,11 @@ import net.corda.contracts.asset.*
import net.corda.contracts.testing.fillWithSomeTestCash
import net.corda.core.contracts.*
import net.corda.core.crypto.Party
import net.corda.core.crypto.SecureHash
import net.corda.core.crypto.composite
import net.corda.core.days
import net.corda.core.node.services.Vault
import net.corda.core.node.services.VaultService
import net.corda.core.seconds
import net.corda.core.transactions.LedgerTransaction
import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.core.utilities.DUMMY_NOTARY_KEY
@ -38,7 +36,7 @@ interface ICommercialPaperTestTemplate {
fun getMoveCommand(): CommandData
}
class JavaCommercialPaperTest() : ICommercialPaperTestTemplate {
class JavaCommercialPaperTest : ICommercialPaperTestTemplate {
override fun getPaper(): ICommercialPaperState = JavaCommercialPaper.State(
MEGA_CORP.ref(123),
MEGA_CORP_PUBKEY,
@ -51,7 +49,7 @@ class JavaCommercialPaperTest() : ICommercialPaperTestTemplate {
override fun getMoveCommand(): CommandData = JavaCommercialPaper.Commands.Move()
}
class KotlinCommercialPaperTest() : ICommercialPaperTestTemplate {
class KotlinCommercialPaperTest : ICommercialPaperTestTemplate {
override fun getPaper(): ICommercialPaperState = CommercialPaper.State(
issuance = MEGA_CORP.ref(123),
owner = MEGA_CORP_PUBKEY,
@ -197,11 +195,6 @@ class CommercialPaperTestsGeneric {
}
}
fun cashOutputsToVault(vararg outputs: TransactionState<Cash.State>): Pair<LedgerTransaction, List<StateAndRef<Cash.State>>> {
val ltx = LedgerTransaction(emptyList(), listOf(*outputs), emptyList(), emptyList(), SecureHash.randomSHA256(), null, emptyList(), null, TransactionType.General())
return Pair(ltx, outputs.mapIndexed { index, state -> StateAndRef(state, StateRef(ltx.id, index)) })
}
/**
* Unit test requires two separate Database instances to represent each of the two
* transaction participants (enforces uniqueness of vault content in lieu of partipant identity)

View File

@ -73,7 +73,7 @@ class WiredTransactionGenerator : Generator<WireTransaction>(WireTransaction::cl
commands = commands,
notary = PartyGenerator().generate(random, status),
signers = commands.flatMap { it.signers },
type = TransactionType.General(),
type = TransactionType.General,
timestamp = TimestampGenerator().generate(random, status)
)
}

View File

@ -9,8 +9,8 @@ import java.nio.file.FileSystems
import java.nio.file.Path
sealed class ConnectionDirection {
class Inbound(val acceptorFactoryClassName: String) : ConnectionDirection()
class Outbound(
data class Inbound(val acceptorFactoryClassName: String) : ConnectionDirection()
data class Outbound(
val expectedCommonName: String? = null,
val connectorFactoryClassName: String = NettyConnectorFactory::class.java.name
) : ConnectionDirection()

View File

@ -121,7 +121,7 @@ class VaultSchemaTest {
notary,
signers,
timestamp,
TransactionType.General()
TransactionType.General
)
}
@ -153,7 +153,7 @@ class VaultSchemaTest {
notary,
signers,
timestamp,
TransactionType.General()
TransactionType.General
)
}

View File

@ -513,7 +513,7 @@ sealed class CertificateChainCheckPolicy {
}
}
class MustContainOneOf(val trustedAliases: Set<String>) : CertificateChainCheckPolicy() {
data class MustContainOneOf(val trustedAliases: Set<String>) : CertificateChainCheckPolicy() {
override fun createCheck(keyStore: KeyStore, trustStore: KeyStore): Check {
val trustedPublicKeys = trustedAliases.map { trustStore.getCertificate(it).publicKey }.toSet()
return object : Check {

View File

@ -2,7 +2,6 @@ package net.corda.node.services.statemachine
import net.corda.core.crypto.SecureHash
// TODO revisit when Kotlin 1.1 is released and data classes can extend other classes
interface FlowIORequest {
// This is used to identify where we suspended, in case of message mismatch errors and other things where we
// don't have the original stack trace because it's in a suspended fiber.

View File

@ -32,13 +32,11 @@ sealed class FlowSessionState {
abstract val sendToParty: Party
/** [otherParty] may be a specific peer or a service party */
class Initiating(val otherParty: Party) : FlowSessionState() {
data class Initiating(val otherParty: Party) : FlowSessionState() {
override val sendToParty: Party get() = otherParty
override fun toString(): String = "${javaClass.simpleName}($otherParty)"
}
class Initiated(val peerParty: Party, val peerSessionId: Long) : FlowSessionState() {
data class Initiated(val peerParty: Party, val peerSessionId: Long) : FlowSessionState() {
override val sendToParty: Party get() = peerParty
override fun toString(): String = "${javaClass.simpleName}($peerParty, $peerSessionId)"
}
}

View File

@ -51,15 +51,15 @@ object BFTSMaRt {
/** Sent from [Server] to [Client]. */
@CordaSerializable
sealed class ReplicaResponse {
class Error(val error: NotaryError) : ReplicaResponse()
class Signature(val txSignature: DigitalSignature) : ReplicaResponse()
data class Error(val error: NotaryError) : ReplicaResponse()
data class Signature(val txSignature: DigitalSignature) : ReplicaResponse()
}
/** An aggregate response from all replica ([Server]) replies sent from [Client] back to the calling application. */
@CordaSerializable
sealed class ClusterResponse {
class Error(val error: NotaryError) : ClusterResponse()
class Signatures(val txSignatures: List<DigitalSignature>) : ClusterResponse()
data class Error(val error: NotaryError) : ClusterResponse()
data class Signatures(val txSignatures: List<DigitalSignature>) : ClusterResponse()
}
class Client(val id: Int) : SingletonSerializeAsToken() {
@ -193,7 +193,7 @@ object BFTSMaRt {
protected fun validateTimestamp(t: Timestamp?) {
if (t != null && !timestampChecker.isValid(t))
throw NotaryException(NotaryError.TimestampInvalid())
throw NotaryException(NotaryError.TimestampInvalid)
}
protected fun sign(bytes: ByteArray): DigitalSignature.WithKey {

View File

@ -252,16 +252,11 @@ abstract class AbstractNetworkMapServiceTest<out S : AbstractNetworkMapService>
return network.createNode(legalName = legalName, nodeFactory = NoNMSNodeFactory)
}
sealed class Changed(val node: NodeInfo) {
override fun equals(other: Any?): Boolean = other?.javaClass == this.javaClass && (other as Changed).node == this.node
override fun hashCode(): Int = node.hashCode()
override fun toString(): String = "${javaClass.simpleName}($node)"
class Added(node: NodeInfo) : Changed(node) {
sealed class Changed {
data class Added(val node: NodeInfo) : Changed() {
constructor(node: MockNode) : this(node.info)
}
class Removed(node: NodeInfo) : Changed(node) {
data class Removed(val node: NodeInfo) : Changed() {
constructor(node: MockNode) : this(node.info)
}
}

View File

@ -164,7 +164,7 @@ class RequeryConfigurationTest {
commands = emptyList(),
notary = DUMMY_NOTARY,
signers = emptyList(),
type = TransactionType.General(),
type = TransactionType.General,
timestamp = null
)
return SignedTransaction(wtx.serialized, listOf(DigitalSignature.WithKey(NullPublicKey, ByteArray(1))))

View File

@ -153,7 +153,7 @@ class DBTransactionStorageTests {
commands = emptyList(),
notary = DUMMY_NOTARY,
signers = emptyList(),
type = TransactionType.General(),
type = TransactionType.General,
timestamp = null
)
return SignedTransaction(wtx.serialized, listOf(DigitalSignature.WithKey(NullPublicKey, ByteArray(1))))

View File

@ -68,7 +68,7 @@ data class GeneratedLedger(
commands.map { it.first },
null,
signers,
TransactionType.General(),
TransactionType.General,
null
)
val newOutputStateAndRefs = outputs.mapIndexed { i, state ->
@ -103,7 +103,7 @@ data class GeneratedLedger(
commands.map { it.first },
inputNotary,
signers,
TransactionType.General(),
TransactionType.General,
null
)
val newOutputStateAndRefs = outputs.mapIndexed { i, state ->
@ -144,7 +144,7 @@ data class GeneratedLedger(
emptyList(),
inputNotary,
signers,
TransactionType.NotaryChange(),
TransactionType.NotaryChange,
null
)
val newOutputStateAndRefs = outputs.mapIndexed { i, state ->