Skip to content

Commit

Permalink
feat(weaver-corda): support array of remote views, consequent user fl…
Browse files Browse the repository at this point in the history
…ow call

Signed-off-by: Sandeep Nishad <[email protected]>
  • Loading branch information
sandeepnRES committed Sep 1, 2023
1 parent f8a2131 commit 9dbb07a
Show file tree
Hide file tree
Showing 14 changed files with 505 additions and 209 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/test_weaver-data-sharing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ jobs:
TOTAL=8
# CORDA-CORDA2
./clients/build/install/clients/bin/clients request-state localhost:9081 relay-corda2:9082/Corda_Network2/corda_network2_partya_1:10003#com.cordaSimpleApplication.flow.GetStateByKey:H 1> tmp.out
./clients/build/install/clients/bin/clients request-state --key=H localhost:9081 relay-corda2:9082/Corda_Network2/corda_network2_partya_1:10003#com.cordaSimpleApplication.flow.GetStateByKey:H 1> tmp.out
cat tmp.out | grep "SimpleState(key=H, value=\[SimpleState(key=H, value=1" && COUNT=$(( COUNT + 1 )) && echo "PASS"
cat tmp.out
Expand All @@ -629,7 +629,7 @@ jobs:
# CORDA2-CORDA
NETWORK_NAME=Corda_Network2 CORDA_PORT=30006 ./clients/build/install/clients/bin/clients request-state localhost:9082 relay-corda:9081/Corda_Network/corda_partya_1:10003#com.cordaSimpleApplication.flow.GetStateByKey:C 1> tmp.out
NETWORK_NAME=Corda_Network2 CORDA_PORT=30006 ./clients/build/install/clients/bin/clients --key=C request-state localhost:9082 relay-corda:9081/Corda_Network/corda_partya_1:10003#com.cordaSimpleApplication.flow.GetStateByKey:C 1> tmp.out
cat tmp.out | grep "SimpleState(key=C, value=\[SimpleState(key=C, value=20" && COUNT=$(( COUNT + 1 )) && echo "PASS"
cat tmp.out
Expand All @@ -638,7 +638,7 @@ jobs:
cat tmp.out
# CORDA - FABRIC1
./clients/build/install/clients/bin/clients request-state localhost:9081 relay-network1:9080/network1/mychannel:simplestate:Read:a 1> tmp.out
./clients/build/install/clients/bin/clients request-state --key=a localhost:9081 relay-network1:9080/network1/mychannel:simplestate:Read:a 1> tmp.out
cat tmp.out | grep "SimpleState(key=a, value=Arcturus" && COUNT=$(( COUNT + 1 )) && echo "PASS"
cat tmp.out
Expand All @@ -647,7 +647,7 @@ jobs:
cat tmp.out
# CORDA - FABRIC2
./clients/build/install/clients/bin/clients request-state localhost:9081 relay-network2:9083/network2/mychannel:simplestate:Read:Arcturus 1> tmp.out
./clients/build/install/clients/bin/clients request-state --key=Arcturus localhost:9081 relay-network2:9083/network2/mychannel:simplestate:Read:Arcturus 1> tmp.out
cat tmp.out | grep "SimpleState(key=Arcturus, value=17.671" && COUNT=$(( COUNT + 1 )) && echo "PASS"
cat tmp.out
Expand Down Expand Up @@ -1029,7 +1029,7 @@ jobs:
TOTAL=8
# CORDA-CORDA2
./clients/build/install/clients/bin/clients request-state localhost:9081 localhost:9082/Corda_Network2/localhost:30006#com.cordaSimpleApplication.flow.GetStateByKey:H 1> tmp.out
./clients/build/install/clients/bin/clients request-state --key=H localhost:9081 localhost:9082/Corda_Network2/localhost:30006#com.cordaSimpleApplication.flow.GetStateByKey:H 1> tmp.out
cat tmp.out | grep "SimpleState(key=H, value=\[SimpleState(key=H, value=1" && COUNT=$(( COUNT + 1 )) && echo "PASS"
cat tmp.out
Expand All @@ -1039,7 +1039,7 @@ jobs:
# CORDA2-CORDA
NETWORK_NAME=Corda_Network2 CORDA_PORT=30006 ./clients/build/install/clients/bin/clients request-state localhost:9082 localhost:9081/Corda_Network/localhost:10006#com.cordaSimpleApplication.flow.GetStateByKey:C 1> tmp.out
NETWORK_NAME=Corda_Network2 CORDA_PORT=30006 ./clients/build/install/clients/bin/clients --key=C request-state localhost:9082 localhost:9081/Corda_Network/localhost:10006#com.cordaSimpleApplication.flow.GetStateByKey:C 1> tmp.out
cat tmp.out | grep "SimpleState(key=C, value=\[SimpleState(key=C, value=20" && COUNT=$(( COUNT + 1 )) && echo "PASS"
cat tmp.out
Expand All @@ -1048,7 +1048,7 @@ jobs:
cat tmp.out
# CORDA - FABRIC1
./clients/build/install/clients/bin/clients request-state localhost:9081 localhost:9080/network1/mychannel:simplestate:Read:a 1> tmp.out
./clients/build/install/clients/bin/clients request-state --key=a localhost:9081 localhost:9080/network1/mychannel:simplestate:Read:a 1> tmp.out
cat tmp.out | grep "SimpleState(key=a, value=Arcturus" && COUNT=$(( COUNT + 1 )) && echo "PASS"
cat tmp.out
Expand All @@ -1057,7 +1057,7 @@ jobs:
cat tmp.out
# CORDA - FABRIC2
./clients/build/install/clients/bin/clients request-state localhost:9081 localhost:9083/network2/mychannel:simplestate:Read:Arcturus 1> tmp.out
./clients/build/install/clients/bin/clients request-state --key=Arcturus localhost:9081 localhost:9083/network2/mychannel:simplestate:Read:Arcturus 1> tmp.out
cat tmp.out | grep "SimpleState(key=Arcturus, value=17.671" && COUNT=$(( COUNT + 1 )) && echo "PASS"
cat tmp.out
Expand Down
12 changes: 8 additions & 4 deletions weaver/core/drivers/corda-driver/src/main/kotlin/CordaDriver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import java.util.*

import org.hyperledger.cacti.weaver.imodule.corda.flows.HandleExternalRequest
import org.hyperledger.cacti.weaver.sdk.corda.InteroperableHelper
import org.hyperledger.cacti.weaver.sdk.corda.RelayOptions
import org.hyperledger.cacti.weaver.protos.common.query.QueryOuterClass
import org.hyperledger.cacti.weaver.protos.common.state.State
import org.hyperledger.cacti.weaver.protos.corda.ViewDataOuterClass
Expand Down Expand Up @@ -143,13 +144,16 @@ fun createAggregatedCordaView(views: List<State.View>) : Either<Error, State.Vie
fun createGrpcConnection(address: String) = try {
parseRelayAddress(address).map { relayAddresses ->
// TODO: if the first relay address fails, retry with other relay addresses in the list.
val relayOptions = RelayOptions(
useTlsForRelay = System.getenv("RELAY_TLS")?.toBoolean() ?: false,
relayTlsTrustStorePath = System.getenv("RELAY_TLSCA_TRUST_STORE")?.toString() ?: "",
relayTlsTrustStorePassword = System.getenv("RELAY_TLSCA_TRUST_STORE_PASSWORD")?.toString() ?: "",
tlsCACertPathsForRelay = System.getenv("RELAY_TLSCA_CERT_PATHS")?.toString() ?: ""
)
val channel = InteroperableHelper.getChannelToRelay(
relayAddresses[0].host,
relayAddresses[0].port,
System.getenv("RELAY_TLS")?.toBoolean() ?: false,
System.getenv("RELAY_TLSCA_TRUST_STORE")?.toString() ?: "",
System.getenv("RELAY_TLSCA_TRUST_STORE_PASSWORD")?.toString() ?: "",
System.getenv("RELAY_TLSCA_CERT_PATHS")?.toString() ?: "")
relayOptions)
GrpcClient(channel)
}
} catch (e: Exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import net.corda.core.contracts.BelongsToContract
import net.corda.core.contracts.LinearState
import net.corda.core.contracts.UniqueIdentifier
import net.corda.core.identity.Party
import net.corda.core.serialization.CordaSerializable

/**
* A representation of state and proof retrieved from an external network.
Expand All @@ -27,3 +28,11 @@ data class ExternalState(
override val linearId: UniqueIdentifier = UniqueIdentifier(),
override val participants: List<Party> = listOf()
) : LinearState

@CordaSerializable
data class InvocationSpec(
val disableInvocation: Boolean = true,
val invokeFlowName: String = "",
val invokeFlowArgs: List<Any> = listOf(),
val interopArgsIndex: Int = -1
)
Loading

0 comments on commit 9dbb07a

Please sign in to comment.