Rename TransactionKeyFlow to SwapIdentitiesFlow (#1499)

This commit is contained in:
Ross Nicoll
2017-09-13 15:01:42 +01:00
committed by GitHub
parent 1ef4cec0cd
commit 024285b007
6 changed files with 10 additions and 14 deletions

View File

@ -15,7 +15,7 @@ import net.corda.core.utilities.unwrap
*/ */
@StartableByRPC @StartableByRPC
@InitiatingFlow @InitiatingFlow
class TransactionKeyFlow(val otherSide: Party, class SwapIdentitiesFlow(val otherSide: Party,
val revocationEnabled: Boolean, val revocationEnabled: Boolean,
override val progressTracker: ProgressTracker) : FlowLogic<LinkedHashMap<Party, AnonymousParty>>() { override val progressTracker: ProgressTracker) : FlowLogic<LinkedHashMap<Party, AnonymousParty>>() {
constructor(otherSide: Party) : this(otherSide, false, tracker()) constructor(otherSide: Party) : this(otherSide, false, tracker())

View File

@ -14,7 +14,7 @@ import kotlin.test.assertFalse
import kotlin.test.assertNotEquals import kotlin.test.assertNotEquals
import kotlin.test.assertTrue import kotlin.test.assertTrue
class TransactionKeyFlowTests { class SwapIdentitiesFlowTests {
@Test @Test
fun `issue key`() { fun `issue key`() {
// We run this in parallel threads to help catch any race conditions that may exist. // We run this in parallel threads to help catch any race conditions that may exist.
@ -28,7 +28,7 @@ class TransactionKeyFlowTests {
val bob: Party = bobNode.services.myInfo.legalIdentity val bob: Party = bobNode.services.myInfo.legalIdentity
// Run the flows // Run the flows
val requesterFlow = aliceNode.services.startFlow(TransactionKeyFlow(bob)) val requesterFlow = aliceNode.services.startFlow(SwapIdentitiesFlow(bob))
// Get the results // Get the results
val actual: Map<Party, AnonymousParty> = requesterFlow.resultFuture.getOrThrow().toMap() val actual: Map<Party, AnonymousParty> = requesterFlow.resultFuture.getOrThrow().toMap()

View File

@ -4,7 +4,7 @@ import co.paralleluniverse.fibers.Suspendable
import net.corda.core.contracts.Amount import net.corda.core.contracts.Amount
import net.corda.core.contracts.InsufficientBalanceException import net.corda.core.contracts.InsufficientBalanceException
import net.corda.core.flows.StartableByRPC import net.corda.core.flows.StartableByRPC
import net.corda.core.flows.TransactionKeyFlow import net.corda.core.flows.SwapIdentitiesFlow
import net.corda.core.identity.AnonymousParty import net.corda.core.identity.AnonymousParty
import net.corda.core.identity.Party import net.corda.core.identity.Party
import net.corda.core.serialization.CordaSerializable import net.corda.core.serialization.CordaSerializable
@ -39,7 +39,7 @@ open class CashPaymentFlow(
override fun call(): AbstractCashFlow.Result { override fun call(): AbstractCashFlow.Result {
progressTracker.currentStep = GENERATING_ID progressTracker.currentStep = GENERATING_ID
val txIdentities = if (anonymous) { val txIdentities = if (anonymous) {
subFlow(TransactionKeyFlow(recipient)) subFlow(SwapIdentitiesFlow(recipient))
} else { } else {
emptyMap<Party, AnonymousParty>() emptyMap<Party, AnonymousParty>()
} }

View File

@ -53,7 +53,7 @@ object TwoPartyDealFlow {
@Suspendable override fun call(): SignedTransaction { @Suspendable override fun call(): SignedTransaction {
progressTracker.currentStep = GENERATING_ID progressTracker.currentStep = GENERATING_ID
val txIdentities = subFlow(TransactionKeyFlow(otherParty)) val txIdentities = subFlow(SwapIdentitiesFlow(otherParty))
val anonymousMe = txIdentities.get(serviceHub.myInfo.legalIdentity) ?: serviceHub.myInfo.legalIdentity.anonymise() val anonymousMe = txIdentities.get(serviceHub.myInfo.legalIdentity) ?: serviceHub.myInfo.legalIdentity.anonymise()
val anonymousCounterparty = txIdentities.get(otherParty) ?: otherParty.anonymise() val anonymousCounterparty = txIdentities.get(otherParty) ?: otherParty.anonymise()
progressTracker.currentStep = SENDING_PROPOSAL progressTracker.currentStep = SENDING_PROPOSAL

View File

@ -35,7 +35,7 @@ import net.corda.node.internal.cordapp.CordappLoader
import net.corda.node.internal.classloading.requireAnnotation import net.corda.node.internal.classloading.requireAnnotation
import net.corda.node.services.NotaryChangeHandler import net.corda.node.services.NotaryChangeHandler
import net.corda.node.services.NotifyTransactionHandler import net.corda.node.services.NotifyTransactionHandler
import net.corda.node.services.TransactionKeyHandler import net.corda.node.services.SwapIdentitiesHandler
import net.corda.node.services.api.* import net.corda.node.services.api.*
import net.corda.node.services.config.NodeConfiguration import net.corda.node.services.config.NodeConfiguration
import net.corda.node.services.config.configureWithDevSSLCertificate import net.corda.node.services.config.configureWithDevSSLCertificate
@ -343,7 +343,7 @@ abstract class AbstractNode(open val configuration: NodeConfiguration,
installCoreFlow(BroadcastTransactionFlow::class, ::NotifyTransactionHandler) installCoreFlow(BroadcastTransactionFlow::class, ::NotifyTransactionHandler)
installCoreFlow(NotaryChangeFlow::class, ::NotaryChangeHandler) installCoreFlow(NotaryChangeFlow::class, ::NotaryChangeHandler)
installCoreFlow(ContractUpgradeFlow.Initiator::class, ::Acceptor) installCoreFlow(ContractUpgradeFlow.Initiator::class, ::Acceptor)
installCoreFlow(TransactionKeyFlow::class, ::TransactionKeyHandler) installCoreFlow(SwapIdentitiesFlow::class, ::SwapIdentitiesHandler)
} }
/** /**

View File

@ -1,10 +1,6 @@
package net.corda.node.services package net.corda.node.services
import co.paralleluniverse.fibers.Suspendable import co.paralleluniverse.fibers.Suspendable
import net.corda.core.contracts.ContractState
import net.corda.core.contracts.UpgradeCommand
import net.corda.core.contracts.UpgradedContract
import net.corda.core.contracts.requireThat
import net.corda.core.flows.* import net.corda.core.flows.*
import net.corda.core.identity.PartyAndCertificate import net.corda.core.identity.PartyAndCertificate
import net.corda.core.identity.Party import net.corda.core.identity.Party
@ -49,7 +45,7 @@ class NotaryChangeHandler(otherSide: Party) : AbstractStateReplacementFlow.Accep
} }
} }
class TransactionKeyHandler(val otherSide: Party, val revocationEnabled: Boolean) : FlowLogic<Unit>() { class SwapIdentitiesHandler(val otherSide: Party, val revocationEnabled: Boolean) : FlowLogic<Unit>() {
constructor(otherSide: Party) : this(otherSide, false) constructor(otherSide: Party) : this(otherSide, false)
companion object { companion object {
object SENDING_KEY : ProgressTracker.Step("Sending key") object SENDING_KEY : ProgressTracker.Step("Sending key")
@ -63,7 +59,7 @@ class TransactionKeyHandler(val otherSide: Party, val revocationEnabled: Boolean
progressTracker.currentStep = SENDING_KEY progressTracker.currentStep = SENDING_KEY
val legalIdentityAnonymous = serviceHub.keyManagementService.freshKeyAndCert(serviceHub.myInfo.legalIdentityAndCert, revocationEnabled) val legalIdentityAnonymous = serviceHub.keyManagementService.freshKeyAndCert(serviceHub.myInfo.legalIdentityAndCert, revocationEnabled)
sendAndReceive<PartyAndCertificate>(otherSide, legalIdentityAnonymous).unwrap { confidentialIdentity -> sendAndReceive<PartyAndCertificate>(otherSide, legalIdentityAnonymous).unwrap { confidentialIdentity ->
TransactionKeyFlow.validateAndRegisterIdentity(serviceHub.identityService, otherSide, confidentialIdentity) SwapIdentitiesFlow.validateAndRegisterIdentity(serviceHub.identityService, otherSide, confidentialIdentity)
} }
} }
} }