diff --git a/core/src/main/kotlin/com/r3corda/protocols/TwoPartyDealProtocol.kt b/core/src/main/kotlin/com/r3corda/protocols/TwoPartyDealProtocol.kt index 5dcf644404..448d937d3d 100644 --- a/core/src/main/kotlin/com/r3corda/protocols/TwoPartyDealProtocol.kt +++ b/core/src/main/kotlin/com/r3corda/protocols/TwoPartyDealProtocol.kt @@ -381,7 +381,8 @@ object TwoPartyDealProtocol { * is just the "side" of the protocol run by the party with the floating leg as a way of deciding who * does what in the protocol. */ - class Floater(override val payload: StateRef, + class Floater(override val otherParty: Party, + override val payload: StateRef, override val progressTracker: ProgressTracker = Primary.tracker()) : Primary() { @Suppress("UNCHECKED_CAST") internal val dealToFix: StateAndRef by TransientProperty { @@ -395,12 +396,6 @@ object TwoPartyDealProtocol { return serviceHub.keyManagementService.toKeyPair(publicKey) } - override val otherParty: Party get() { - // TODO otherParty is sortedParties[1] from FixingRoleDecider.call and so can be passed in as a c'tor param - val myName = serviceHub.storageService.myLegalIdentity.name - return dealToFix.state.data.parties.filter { it.name != myName }.single() - } - override val notaryNode: NodeInfo get() = serviceHub.networkMapCache.notaryNodes.filter { it.identity == dealToFix.state.notary }.single() } @@ -451,7 +446,7 @@ object TwoPartyDealProtocol { send(sortedParties[1], initation) // Then start the other side of the fixing protocol. - subProtocol(Floater(ref), inheritParentSessions = true) + subProtocol(Floater(sortedParties[1], ref), inheritParentSessions = true) } } } diff --git a/src/main/kotlin/com/r3corda/demos/protocols/AutoOfferProtocol.kt b/src/main/kotlin/com/r3corda/demos/protocols/AutoOfferProtocol.kt index af037af66b..be9ce87cde 100644 --- a/src/main/kotlin/com/r3corda/demos/protocols/AutoOfferProtocol.kt +++ b/src/main/kotlin/com/r3corda/demos/protocols/AutoOfferProtocol.kt @@ -15,6 +15,7 @@ import com.r3corda.protocols.HandshakeMessage import com.r3corda.protocols.TwoPartyDealProtocol import com.r3corda.protocols.TwoPartyDealProtocol.Acceptor import com.r3corda.protocols.TwoPartyDealProtocol.DEAL_TOPIC +import com.r3corda.protocols.TwoPartyDealProtocol.Instigator /** * This whole class is really part of a demo just to initiate the agreement of a deal with a simple @@ -40,7 +41,7 @@ object AutoOfferProtocol { class Service(services: ServiceHubInternal) : AbstractNodeService(services) { object DEALING : ProgressTracker.Step("Starting the deal protocol") { - override fun childProgressTracker(): ProgressTracker = TwoPartyDealProtocol.Primary.tracker() + override fun childProgressTracker(): ProgressTracker = TwoPartyDealProtocol.Secondary.tracker() } fun tracker() = ProgressTracker(DEALING) @@ -60,11 +61,10 @@ object AutoOfferProtocol { val progressTracker = tracker() // Put the deal onto the ledger progressTracker.currentStep = DEALING - TwoPartyDealProtocol.Instigator( + Acceptor( autoOfferMessage.replyToParty, autoOfferMessage.notary, autoOfferMessage.dealBeingOffered, - services.keyManagementService.freshKey(), progressTracker.getChildProgressTracker(DEALING)!! ) } @@ -78,7 +78,7 @@ object AutoOfferProtocol { object RECEIVED : ProgressTracker.Step("Received API call") object ANNOUNCING : ProgressTracker.Step("Announcing to the peer node") object DEALING : ProgressTracker.Step("Starting the deal protocol") { - override fun childProgressTracker(): ProgressTracker = TwoPartyDealProtocol.Secondary.tracker() + override fun childProgressTracker(): ProgressTracker = TwoPartyDealProtocol.Primary.tracker() } // We vend a progress tracker that already knows there's going to be a TwoPartyTradingProtocol involved at some @@ -103,9 +103,14 @@ object AutoOfferProtocol { progressTracker.currentStep = ANNOUNCING send(otherParty, AutoOfferMessage(notary, dealToBeOffered, serviceHub.storageService.myLegalIdentity)) progressTracker.currentStep = DEALING - val stx = subProtocol( - Acceptor(otherParty, notary, dealToBeOffered, progressTracker.getChildProgressTracker(DEALING)!!), - inheritParentSessions = true) + val instigator = Instigator( + otherParty, + notary, + dealToBeOffered, + serviceHub.keyManagementService.freshKey(), + progressTracker.getChildProgressTracker(DEALING)!! + ) + val stx = subProtocol(instigator, inheritParentSessions = true) return stx }