mirror of
https://github.com/corda/corda.git
synced 2025-02-12 05:35:50 +00:00
Minor: eliminate compiler warnings
This commit is contained in:
parent
1da7b4bf01
commit
f3863ac5ef
@ -453,7 +453,6 @@ class InterestRateSwap() : Contract {
|
|||||||
val calculation: Calculation,
|
val calculation: Calculation,
|
||||||
val common: Common
|
val common: Common
|
||||||
) : FixableDealState {
|
) : FixableDealState {
|
||||||
|
|
||||||
override val programRef = IRS_PROGRAM_ID
|
override val programRef = IRS_PROGRAM_ID
|
||||||
override val thread = SecureHash.sha256(common.tradeID)
|
override val thread = SecureHash.sha256(common.tradeID)
|
||||||
override val ref = common.tradeID
|
override val ref = common.tradeID
|
||||||
@ -465,7 +464,8 @@ class InterestRateSwap() : Contract {
|
|||||||
override val parties: Array<Party>
|
override val parties: Array<Party>
|
||||||
get() = arrayOf(fixedLeg.fixedRatePayer, floatingLeg.floatingRatePayer)
|
get() = arrayOf(fixedLeg.fixedRatePayer, floatingLeg.floatingRatePayer)
|
||||||
|
|
||||||
override fun withPublicKey(before: Party, after: PublicKey): State {
|
// TODO: This changing of the public key violates the assumption that Party is a fixed identity key.
|
||||||
|
override fun withPublicKey(before: Party, after: PublicKey): DealState {
|
||||||
val newParty = Party(before.name, after)
|
val newParty = Party(before.name, after)
|
||||||
if (before == fixedLeg.fixedRatePayer) {
|
if (before == fixedLeg.fixedRatePayer) {
|
||||||
val deal = copy()
|
val deal = copy()
|
||||||
|
@ -45,8 +45,8 @@ open class PercentageRatioUnit(percentageAsString: String) : RatioUnit(BigDecima
|
|||||||
val String.percent: PercentageRatioUnit get() = PercentageRatioUnit(this)
|
val String.percent: PercentageRatioUnit get() = PercentageRatioUnit(this)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface representing an agreement that exposes various attributes that are common and allow
|
* Interface representing an agreement that exposes various attributes that are common. Implementing it simplifies
|
||||||
* implementation of general protocols that manipulate many agreement types
|
* implementation of general protocols that manipulate many agreement types.
|
||||||
*/
|
*/
|
||||||
interface DealState : LinearState {
|
interface DealState : LinearState {
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ interface DealState : LinearState {
|
|||||||
/** Exposes the Parties involved in a generic way */
|
/** Exposes the Parties involved in a generic way */
|
||||||
val parties: Array<Party>
|
val parties: Array<Party>
|
||||||
|
|
||||||
/** Allow swapping in of potentially transaction specific public keys prior to signing */
|
// TODO: This works by editing the keys used by a Party which is invalid.
|
||||||
fun withPublicKey(before: Party, after: PublicKey): DealState
|
fun withPublicKey(before: Party, after: PublicKey): DealState
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,7 +18,6 @@ import java.io.OutputStream
|
|||||||
import java.security.PublicKey
|
import java.security.PublicKey
|
||||||
import java.time.Duration
|
import java.time.Duration
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
import java.time.LocalDate
|
|
||||||
import java.util.jar.JarInputStream
|
import java.util.jar.JarInputStream
|
||||||
|
|
||||||
/** Implemented by anything that can be named by a secure hash value (e.g. transactions, attachments). */
|
/** Implemented by anything that can be named by a secure hash value (e.g. transactions, attachments). */
|
||||||
@ -75,6 +74,11 @@ data class StateRef(val txhash: SecureHash, val index: Int) {
|
|||||||
/** A StateAndRef is simply a (state, ref) pair. For instance, a wallet (which holds available assets) contains these. */
|
/** A StateAndRef is simply a (state, ref) pair. For instance, a wallet (which holds available assets) contains these. */
|
||||||
data class StateAndRef<out T : ContractState>(val state: T, val ref: StateRef)
|
data class StateAndRef<out T : ContractState>(val state: T, val ref: StateRef)
|
||||||
|
|
||||||
|
/** Filters a list of [StateAndRef] objects according to the type of the states */
|
||||||
|
inline fun <reified T : ContractState> List<StateAndRef<ContractState>>.filterStatesOfType(): List<StateAndRef<T>> {
|
||||||
|
return mapNotNull { if (it.state is T) StateAndRef(it.state, it.ref) else null }
|
||||||
|
}
|
||||||
|
|
||||||
/** A [Party] is well known (name, pubkey) pair. In a real system this would probably be an X.509 certificate. */
|
/** A [Party] is well known (name, pubkey) pair. In a real system this would probably be an X.509 certificate. */
|
||||||
data class Party(val name: String, val owningKey: PublicKey) {
|
data class Party(val name: String, val owningKey: PublicKey) {
|
||||||
override fun toString() = name
|
override fun toString() = name
|
||||||
|
@ -2,10 +2,14 @@ package api
|
|||||||
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture
|
import com.google.common.util.concurrent.ListenableFuture
|
||||||
import contracts.DealState
|
import contracts.DealState
|
||||||
import core.*
|
import core.ContractState
|
||||||
|
import core.SignedTransaction
|
||||||
|
import core.StateRef
|
||||||
|
import core.WireTransaction
|
||||||
import core.crypto.DigitalSignature
|
import core.crypto.DigitalSignature
|
||||||
import core.crypto.SecureHash
|
import core.crypto.SecureHash
|
||||||
import core.node.AbstractNode
|
import core.node.AbstractNode
|
||||||
|
import core.node.services.linearHeadsOfType
|
||||||
import core.protocols.ProtocolLogic
|
import core.protocols.ProtocolLogic
|
||||||
import core.serialization.SerializedBytes
|
import core.serialization.SerializedBytes
|
||||||
import core.utilities.ANSIProgressRenderer
|
import core.utilities.ANSIProgressRenderer
|
||||||
@ -28,8 +32,8 @@ class APIServerImpl(val node: AbstractNode): APIServer {
|
|||||||
return states.values.map { it.ref }
|
return states.values.map { it.ref }
|
||||||
}
|
}
|
||||||
else if (query.criteria is StatesQuery.Criteria.Deal) {
|
else if (query.criteria is StatesQuery.Criteria.Deal) {
|
||||||
val states = node.services.walletService.linearHeadsInstanceOf(DealState::class.java) {
|
val states = node.services.walletService.linearHeadsOfType<DealState>().filterValues {
|
||||||
it.ref == query.criteria.ref
|
it.state.ref == query.criteria.ref
|
||||||
}
|
}
|
||||||
return states.values.map { it.ref }
|
return states.values.map { it.ref }
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ class NodeWalletService(private val services: ServiceHub) : WalletService {
|
|||||||
*/
|
*/
|
||||||
override val linearHeads: Map<SecureHash, StateAndRef<LinearState>>
|
override val linearHeads: Map<SecureHash, StateAndRef<LinearState>>
|
||||||
get() = mutex.locked { wallet }.let { wallet ->
|
get() = mutex.locked { wallet }.let { wallet ->
|
||||||
wallet.states.filter { it.state is LinearState }.associateBy { (it.state as LinearState).thread }.mapValues { it.value as StateAndRef<LinearState> }
|
wallet.states.filterStatesOfType<LinearState>().associateBy { it.state.thread }.mapValues { it.value }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun notifyAll(txns: Iterable<WireTransaction>): Wallet {
|
override fun notifyAll(txns: Iterable<WireTransaction>): Wallet {
|
||||||
|
@ -72,8 +72,12 @@ interface WalletService {
|
|||||||
*/
|
*/
|
||||||
val linearHeads: Map<SecureHash, StateAndRef<LinearState>>
|
val linearHeads: Map<SecureHash, StateAndRef<LinearState>>
|
||||||
|
|
||||||
fun <T : LinearState> linearHeadsInstanceOf(clazz: Class<T>, predicate: (T) -> Boolean = { true } ): Map<SecureHash, StateAndRef<T>> {
|
// TODO: When KT-10399 is fixed, rename this and remove the inline version below.
|
||||||
return linearHeads.filterValues { clazz.isInstance(it.state) }.filterValues { predicate(it.state as T) }.mapValues { StateAndRef(it.value.state as T, it.value.ref) }
|
|
||||||
|
/** Returns the [linearHeads] only when the type of the state would be considered an 'instanceof' the given type. */
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
fun <T : LinearState> linearHeadsOfType_(stateType: Class<T>): Map<SecureHash, StateAndRef<T>> {
|
||||||
|
return linearHeads.filterValues { stateType.isInstance(it.state) }.mapValues { StateAndRef(it.value.state as T, it.value.ref) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun statesForRefs(refs: List<StateRef>): Map<StateRef, ContractState?> {
|
fun statesForRefs(refs: List<StateRef>): Map<StateRef, ContractState?> {
|
||||||
@ -95,17 +99,7 @@ interface WalletService {
|
|||||||
fun notify(tx: WireTransaction): Wallet = notifyAll(listOf(tx))
|
fun notify(tx: WireTransaction): Wallet = notifyAll(listOf(tx))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Document this
|
inline fun <reified T : LinearState> WalletService.linearHeadsOfType() = linearHeadsOfType_(T::class.java)
|
||||||
@Suppress("UNCHECKED_CAST")
|
|
||||||
inline fun <reified T : LinearState> WalletService.linearHeadsOfType(): Map<SecureHash, StateAndRef<T>> {
|
|
||||||
return linearHeads.mapNotNull {
|
|
||||||
val s = it.value.state
|
|
||||||
if (s is T)
|
|
||||||
Pair(it.key, it.value as StateAndRef<T>)
|
|
||||||
else
|
|
||||||
null
|
|
||||||
}.toMap()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The KMS is responsible for storing and using private keys to sign things. An implementation of this may, for example,
|
* The KMS is responsible for storing and using private keys to sign things. An implementation of this may, for example,
|
||||||
|
@ -16,12 +16,13 @@ open class StorageServiceImpl(attachments: AttachmentStorage,
|
|||||||
// This parameter is for unit tests that want to observe operation details.
|
// This parameter is for unit tests that want to observe operation details.
|
||||||
val recordingAs: (String) -> String = { tableName -> "" })
|
val recordingAs: (String) -> String = { tableName -> "" })
|
||||||
: StorageService {
|
: StorageService {
|
||||||
protected val tables = HashMap<String, MutableMap<Any, Any>>()
|
protected val tables = HashMap<String, MutableMap<*, *>>()
|
||||||
|
|
||||||
private fun <K, V> getMapOriginal(tableName: String): MutableMap<K, V> {
|
private fun <K, V> getMapOriginal(tableName: String): MutableMap<K, V> {
|
||||||
synchronized(tables) {
|
synchronized(tables) {
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
return tables.getOrPut(tableName) {
|
return tables.getOrPut(tableName) {
|
||||||
recorderWrap(Collections.synchronizedMap(HashMap<Any, Any>()), tableName);
|
recorderWrap(Collections.synchronizedMap(HashMap<K, V>()), tableName)
|
||||||
} as MutableMap<K, V>
|
} as MutableMap<K, V>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,15 +89,15 @@ class InMemoryMessagingNetwork {
|
|||||||
if (calc != null && recipients is SingleMessageRecipient) {
|
if (calc != null && recipients is SingleMessageRecipient) {
|
||||||
// Inject some artificial latency.
|
// Inject some artificial latency.
|
||||||
timer.schedule(calc.between(from.myAddress, recipients).toMillis()) {
|
timer.schedule(calc.between(from.myAddress, recipients).toMillis()) {
|
||||||
msgSendInternal(from, message, recipients)
|
msgSendInternal(message, recipients)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
msgSendInternal(from, message, recipients)
|
msgSendInternal(message, recipients)
|
||||||
}
|
}
|
||||||
_allMessages.onNext(Triple(from.myAddress, message, recipients))
|
_allMessages.onNext(Triple(from.myAddress, message, recipients))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun msgSendInternal(from: InMemoryMessaging, message: Message, recipients: MessageRecipients) {
|
private fun msgSendInternal(message: Message, recipients: MessageRecipients) {
|
||||||
when (recipients) {
|
when (recipients) {
|
||||||
is Handle -> getQueueForHandle(recipients).add(message)
|
is Handle -> getQueueForHandle(recipients).add(message)
|
||||||
|
|
||||||
|
@ -16,14 +16,14 @@ import core.node.Node
|
|||||||
import core.node.NodeConfiguration
|
import core.node.NodeConfiguration
|
||||||
import core.node.NodeConfigurationFromConfig
|
import core.node.NodeConfigurationFromConfig
|
||||||
import core.node.services.ArtemisMessagingService
|
import core.node.services.ArtemisMessagingService
|
||||||
import core.node.services.NodeInfo
|
|
||||||
import core.node.services.MockNetworkMapCache
|
import core.node.services.MockNetworkMapCache
|
||||||
|
import core.node.services.NodeInfo
|
||||||
import core.serialization.deserialize
|
import core.serialization.deserialize
|
||||||
import core.utilities.BriefLogFormatter
|
import core.utilities.BriefLogFormatter
|
||||||
import joptsimple.OptionParser
|
|
||||||
import demos.protocols.AutoOfferProtocol
|
import demos.protocols.AutoOfferProtocol
|
||||||
import demos.protocols.ExitServerProtocol
|
import demos.protocols.ExitServerProtocol
|
||||||
import demos.protocols.UpdateBusinessDayProtocol
|
import demos.protocols.UpdateBusinessDayProtocol
|
||||||
|
import joptsimple.OptionParser
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
@ -122,8 +122,10 @@ fun main(args: Array<String>) {
|
|||||||
UpdateBusinessDayProtocol.Handler.register(node)
|
UpdateBusinessDayProtocol.Handler.register(node)
|
||||||
ExitServerProtocol.Handler.register(node)
|
ExitServerProtocol.Handler.register(node)
|
||||||
|
|
||||||
while(true) {
|
try {
|
||||||
Thread.sleep(1000L)
|
while (true) Thread.sleep(Long.MAX_VALUE)
|
||||||
|
} catch(e: InterruptedException) {
|
||||||
|
node.stop()
|
||||||
}
|
}
|
||||||
exitProcess(0)
|
exitProcess(0)
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@ package demos.protocols
|
|||||||
import co.paralleluniverse.fibers.Suspendable
|
import co.paralleluniverse.fibers.Suspendable
|
||||||
import co.paralleluniverse.strands.Strand
|
import co.paralleluniverse.strands.Strand
|
||||||
import core.node.Node
|
import core.node.Node
|
||||||
import core.node.services.NodeInfo
|
|
||||||
import core.node.services.MockNetworkMapCache
|
import core.node.services.MockNetworkMapCache
|
||||||
|
import core.node.services.NodeInfo
|
||||||
import core.protocols.ProtocolLogic
|
import core.protocols.ProtocolLogic
|
||||||
import core.serialization.deserialize
|
import core.serialization.deserialize
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
@ -37,7 +37,7 @@ object ExitServerProtocol {
|
|||||||
* This takes a Java Integer rather than Kotlin Int as that is what we end up with in the calling map and currently
|
* This takes a Java Integer rather than Kotlin Int as that is what we end up with in the calling map and currently
|
||||||
* we do not support coercing numeric types in the reflective search for matching constructors
|
* we do not support coercing numeric types in the reflective search for matching constructors
|
||||||
*/
|
*/
|
||||||
class Broadcast(val exitCode: Integer) : ProtocolLogic<Boolean>() {
|
class Broadcast(@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") val exitCode: Integer) : ProtocolLogic<Boolean>() {
|
||||||
|
|
||||||
@Suspendable
|
@Suspendable
|
||||||
override fun call(): Boolean {
|
override fun call(): Boolean {
|
||||||
|
@ -6,8 +6,9 @@ import contracts.DealState
|
|||||||
import contracts.InterestRateSwap
|
import contracts.InterestRateSwap
|
||||||
import core.StateAndRef
|
import core.StateAndRef
|
||||||
import core.node.Node
|
import core.node.Node
|
||||||
import core.node.services.NodeInfo
|
|
||||||
import core.node.services.MockNetworkMapCache
|
import core.node.services.MockNetworkMapCache
|
||||||
|
import core.node.services.NodeInfo
|
||||||
|
import core.node.services.linearHeadsOfType
|
||||||
import core.protocols.ProtocolLogic
|
import core.protocols.ProtocolLogic
|
||||||
import core.random63BitValue
|
import core.random63BitValue
|
||||||
import core.serialization.deserialize
|
import core.serialization.deserialize
|
||||||
@ -41,7 +42,7 @@ object UpdateBusinessDayProtocol {
|
|||||||
override fun call(): Boolean {
|
override fun call(): Boolean {
|
||||||
// Get deals
|
// Get deals
|
||||||
progressTracker.currentStep = FETCHING
|
progressTracker.currentStep = FETCHING
|
||||||
val dealStateRefs = serviceHub.walletService.linearHeadsInstanceOf(DealState::class.java)
|
val dealStateRefs = serviceHub.walletService.linearHeadsOfType<DealState>()
|
||||||
val otherPartyToDeals = dealStateRefs.values.groupBy { otherParty(it.state) }
|
val otherPartyToDeals = dealStateRefs.values.groupBy { otherParty(it.state) }
|
||||||
|
|
||||||
// TODO we need to process these in parallel to stop there being an ordering problem across more than two nodes
|
// TODO we need to process these in parallel to stop there being an ordering problem across more than two nodes
|
||||||
@ -65,8 +66,9 @@ object UpdateBusinessDayProtocol {
|
|||||||
// TODO we should make this more object oriented when we can ask a state for it's contract
|
// TODO we should make this more object oriented when we can ask a state for it's contract
|
||||||
@Suspendable
|
@Suspendable
|
||||||
fun processDeal(party: NodeInfo, deal: StateAndRef<DealState>, date: LocalDate, sessionID: Long) {
|
fun processDeal(party: NodeInfo, deal: StateAndRef<DealState>, date: LocalDate, sessionID: Long) {
|
||||||
when(deal.state) {
|
val s = deal.state
|
||||||
is InterestRateSwap.State -> processInterestRateSwap(party, StateAndRef(deal.state as InterestRateSwap.State, deal.ref), date, sessionID)
|
when (s) {
|
||||||
|
is InterestRateSwap.State -> processInterestRateSwap(party, StateAndRef(s, deal.ref), date, sessionID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ object TwoPartyDealProtocol {
|
|||||||
private fun receiveAndValidateHandshake(): Handshake<U> {
|
private fun receiveAndValidateHandshake(): Handshake<U> {
|
||||||
progressTracker.currentStep = RECEIVING
|
progressTracker.currentStep = RECEIVING
|
||||||
// Wait for a trade request to come in on our pre-provided session ID.
|
// Wait for a trade request to come in on our pre-provided session ID.
|
||||||
val handshake = receive(DEAL_TOPIC, sessionID, Handshake::class.java)
|
val handshake = receive<Handshake<U>>(DEAL_TOPIC, sessionID)
|
||||||
|
|
||||||
progressTracker.currentStep = VERIFYING
|
progressTracker.currentStep = VERIFYING
|
||||||
handshake.validate {
|
handshake.validate {
|
||||||
@ -267,7 +267,7 @@ object TwoPartyDealProtocol {
|
|||||||
return ptx.toSignedTransaction(checkSufficientSignatures = false)
|
return ptx.toSignedTransaction(checkSufficientSignatures = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suspendable protected abstract fun validateHandshake(handshake: Handshake<*>): Handshake<U>
|
@Suspendable protected abstract fun validateHandshake(handshake: Handshake<U>): Handshake<U>
|
||||||
@Suspendable protected abstract fun assembleSharedTX(handshake: Handshake<U>): Pair<TransactionBuilder, List<PublicKey>>
|
@Suspendable protected abstract fun assembleSharedTX(handshake: Handshake<U>): Pair<TransactionBuilder, List<PublicKey>>
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,10 +291,10 @@ object TwoPartyDealProtocol {
|
|||||||
override val progressTracker: ProgressTracker = Secondary.tracker()) : Secondary<T>(otherSide, timestampingAuthority, sessionID) {
|
override val progressTracker: ProgressTracker = Secondary.tracker()) : Secondary<T>(otherSide, timestampingAuthority, sessionID) {
|
||||||
|
|
||||||
@Suspendable
|
@Suspendable
|
||||||
override fun validateHandshake(handshake: Handshake<*>): Handshake<T> {
|
override fun validateHandshake(handshake: Handshake<T>): Handshake<T> {
|
||||||
with(handshake as Handshake<T>) {
|
with(handshake) {
|
||||||
// What is the seller trying to sell us?
|
// What is the seller trying to sell us?
|
||||||
val deal = handshake.payload
|
val deal: T = handshake.payload
|
||||||
val otherKey = handshake.publicKey
|
val otherKey = handshake.publicKey
|
||||||
logger.trace { "Got deal request for: ${handshake.payload}" }
|
logger.trace { "Got deal request for: ${handshake.payload}" }
|
||||||
|
|
||||||
@ -308,7 +308,10 @@ object TwoPartyDealProtocol {
|
|||||||
val myOldParty = deal.parties.single { it.name == myName }
|
val myOldParty = deal.parties.single { it.name == myName }
|
||||||
val theirOldParty = deal.parties.single { it.name != myName }
|
val theirOldParty = deal.parties.single { it.name != myName }
|
||||||
|
|
||||||
val newDeal = deal.withPublicKey(myOldParty, serviceHub.keyManagementService.freshKey().public).withPublicKey(theirOldParty, otherKey) as T
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
val newDeal = deal.
|
||||||
|
withPublicKey(myOldParty, serviceHub.keyManagementService.freshKey().public).
|
||||||
|
withPublicKey(theirOldParty, otherKey) as T
|
||||||
|
|
||||||
return handshake.copy(payload = newDeal)
|
return handshake.copy(payload = newDeal)
|
||||||
}
|
}
|
||||||
@ -341,8 +344,8 @@ object TwoPartyDealProtocol {
|
|||||||
override val progressTracker: ProgressTracker = Secondary.tracker()) : Secondary<StateRef>(otherSide, timestampingAuthority, sessionID) {
|
override val progressTracker: ProgressTracker = Secondary.tracker()) : Secondary<StateRef>(otherSide, timestampingAuthority, sessionID) {
|
||||||
|
|
||||||
@Suspendable
|
@Suspendable
|
||||||
override fun validateHandshake(handshake: Handshake<*>): Handshake<StateRef> {
|
override fun validateHandshake(handshake: Handshake<StateRef>): Handshake<StateRef> {
|
||||||
with(handshake as Handshake<StateRef>) {
|
with(handshake) {
|
||||||
logger.trace { "Got fixing request for: ${dealToFix.state}" }
|
logger.trace { "Got fixing request for: ${dealToFix.state}" }
|
||||||
|
|
||||||
// Check the start message for acceptability.
|
// Check the start message for acceptability.
|
||||||
@ -363,11 +366,12 @@ object TwoPartyDealProtocol {
|
|||||||
|
|
||||||
// TODO Do we need/want to substitute in new public keys for the Parties?
|
// TODO Do we need/want to substitute in new public keys for the Parties?
|
||||||
val myName = serviceHub.storageService.myLegalIdentity.name
|
val myName = serviceHub.storageService.myLegalIdentity.name
|
||||||
val deal = dealToFix.state
|
val deal: T = dealToFix.state
|
||||||
val myOldParty = deal.parties.single { it.name == myName }
|
val myOldParty = deal.parties.single { it.name == myName }
|
||||||
val theirOldParty = deal.parties.single { it.name != myName }
|
val theirOldParty = deal.parties.single { it.name != myName }
|
||||||
val myNewKey = serviceHub.keyManagementService.freshKey().public
|
val myNewKey = serviceHub.keyManagementService.freshKey().public
|
||||||
|
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
val newDeal = deal.withPublicKey(myOldParty, myNewKey).withPublicKey(theirOldParty, handshake.publicKey) as T
|
val newDeal = deal.withPublicKey(myOldParty, myNewKey).withPublicKey(theirOldParty, handshake.publicKey) as T
|
||||||
val oldRef = dealToFix.ref
|
val oldRef = dealToFix.ref
|
||||||
|
|
||||||
|
@ -326,19 +326,9 @@ class IRSTests {
|
|||||||
assert(100 * r1 == 5)
|
assert(100 * r1 == 5)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `more rate tests`() {
|
|
||||||
val r1 = FixedRate(PercentageRatioUnit("10"))
|
|
||||||
val r2 = FixedRate(PercentageRatioUnit("10"))
|
|
||||||
|
|
||||||
// TODO: r1+r2 ? Do we want to allow these.
|
|
||||||
// TODO: r1*r2 ?
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `expression calculation testing`() {
|
fun `expression calculation testing`() {
|
||||||
val dummyIRS = singleIRS()
|
val dummyIRS = singleIRS()
|
||||||
val v = FixedRate(PercentageRatioUnit("4.5"))
|
|
||||||
val stuffToPrint: ArrayList<String> = arrayListOf(
|
val stuffToPrint: ArrayList<String> = arrayListOf(
|
||||||
"fixedLeg.notional.pennies",
|
"fixedLeg.notional.pennies",
|
||||||
"fixedLeg.fixedRate.ratioUnit",
|
"fixedLeg.fixedRate.ratioUnit",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user