Skip to content

Commit 114f4fc

Browse files
Updated session check functions.
1 parent 82197de commit 114f4fc

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=onixlabs-corda-core
22
group=io.onixlabs
3-
version=3.2.0
3+
version=4.0.0-rc1
44
onixlabs.development.jarsign.keystore=../lib/onixlabs.development.pkcs12
55
onixlabs.development.jarsign.password=5891f47942424d2acbe108691fdb5ba258712fca7e4762be4327241ebf3dbfa3

onixlabs-corda-core-workflow/src/main/kotlin/io/onixlabs/corda/core/workflow/Extensions.FlowLogic.Sessions.kt

+16-14
Original file line numberDiff line numberDiff line change
@@ -82,26 +82,27 @@ fun FlowLogic<*>.initiateFlows(parties: Iterable<AbstractParty>, vararg states:
8282
*
8383
* @param sessions The flow sessions that have been provided to the flow.
8484
* @param states The states that will be used as input or output states in a transaction.
85-
* @param partyProjection Provides a mechanism to project, or resolve anonymous to well-known identities.
85+
* @param projectParty Provides a mechanism to project, or resolve anonymous to well-known identities.
8686
* @throws FlowException if a required counter-party session is missing for a state participant.
8787
*/
8888
@Suspendable
8989
fun FlowLogic<*>.checkSufficientSessions(
9090
sessions: Iterable<FlowSession>,
9191
states: Iterable<ContractState>,
92-
partyProjection: (AbstractParty) -> AbstractParty = { it }
92+
projectParty: (AbstractParty) -> AbstractParty = { it }
9393
) {
94-
val stateCounterparties = states
94+
val projectedStateCounterparties = states
9595
.flatMap { it.participants }
96+
.map { projectParty(it) }
9697
.filter { it !in serviceHub.myInfo.legalIdentities }
9798
.toSet()
9899

99-
val sessionCounterparties = sessions
100-
.map { it.counterparty }
100+
val projectedSessionCounterparties = sessions
101+
.map { projectParty(it.counterparty) }
101102
.toSet()
102103

103-
stateCounterparties.map { partyProjection(it) }.forEach {
104-
if (it !in sessionCounterparties) {
104+
projectedStateCounterparties.forEach {
105+
if (it !in projectedSessionCounterparties) {
105106
throw FlowException("A flow session must be provided for the specified counter-party: $it.")
106107
}
107108
}
@@ -116,29 +117,30 @@ fun FlowLogic<*>.checkSufficientSessions(
116117
*
117118
* @param sessions The flow sessions that have been provided to the flow.
118119
* @param states The states that will be used as input or output states in a transaction.
119-
* @param partyProjection Provides a mechanism to project, or resolve anonymous to well-known identities.
120+
* @param projectParty Provides a mechanism to project, or resolve anonymous to well-known identities.
120121
* @throws FlowException if a required counter-party session is missing for a state participant.
121122
*/
122123
@Suspendable
123124
fun FlowLogic<*>.checkSufficientSessions(
124-
sessions: Iterable<FlowSession>, vararg states: ContractState,
125-
partyProjection: (AbstractParty) -> AbstractParty = { it }
126-
) = checkSufficientSessions(sessions, states.toSet(), partyProjection)
125+
sessions: Iterable<FlowSession>,
126+
vararg states: ContractState,
127+
projectParty: (AbstractParty) -> AbstractParty = { it }
128+
) = checkSufficientSessions(sessions, states.toSet(), projectParty)
127129

128130
/**
129131
* Checks that sufficient flow sessions have been provided for the specified transaction.
130132
*
131133
* @param sessions The flow sessions that have been provided to the flow.
132134
* @param transaction The transaction for which to check that sufficient flow sessions exist.
133-
* @param partyProjection Provides a mechanism to project, or resolve anonymous to well-known identities.
135+
* @param projectParty Provides a mechanism to project, or resolve anonymous to well-known identities.
134136
* @throws FlowException if a required counter-party session is missing for a state participant.
135137
*/
136138
@Suspendable
137139
fun FlowLogic<*>.checkSufficientSessions(
138140
sessions: Iterable<FlowSession>,
139141
transaction: TransactionBuilder,
140-
partyProjection: (AbstractParty) -> AbstractParty = { it }
142+
projectParty: (AbstractParty) -> AbstractParty = { it }
141143
) {
142144
val ledgerTransaction = transaction.toLedgerTransaction(serviceHub)
143-
checkSufficientSessions(sessions, ledgerTransaction.inputStates + ledgerTransaction.outputStates, partyProjection)
145+
checkSufficientSessions(sessions, ledgerTransaction.inputStates + ledgerTransaction.outputStates, projectParty)
144146
}

0 commit comments

Comments
 (0)