diff --git a/samples/attachment-demo/build.gradle b/samples/attachment-demo/build.gradle index ac78ca52c8..6a8491a923 100644 --- a/samples/attachment-demo/build.gradle +++ b/samples/attachment-demo/build.gradle @@ -37,9 +37,9 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { ext.rpcUsers = [['username': "demo", 'password': "demo", 'permissions': ["StartFlow.net.corda.attachmentdemo.AttachmentDemoFlow"]]] directory "./build/nodes" - networkMap "CN=Notary Service,O=R3,OU=corda,L=London,C=GB" + networkMap "CN=Notary Service,O=R3,OU=corda,L=Zurich,C=CH" node { - name "CN=Notary Service,O=R3,OU=corda,L=London,C=GB" + name "CN=Notary Service,O=R3,OU=corda,L=Zurich,C=CH" advertisedServices["corda.notary.validating"] p2pPort 10002 rpcPort 10003 diff --git a/samples/attachment-demo/src/main/kotlin/net/corda/attachmentdemo/AttachmentDemo.kt b/samples/attachment-demo/src/main/kotlin/net/corda/attachmentdemo/AttachmentDemo.kt index 44d392a779..4ca6ac1548 100644 --- a/samples/attachment-demo/src/main/kotlin/net/corda/attachmentdemo/AttachmentDemo.kt +++ b/samples/attachment-demo/src/main/kotlin/net/corda/attachmentdemo/AttachmentDemo.kt @@ -1,6 +1,7 @@ package net.corda.attachmentdemo import co.paralleluniverse.fibers.Suspendable +import com.google.common.util.concurrent.ListenableFuture import joptsimple.OptionParser import net.corda.client.rpc.CordaRPCClient import net.corda.core.contracts.Contract @@ -28,6 +29,7 @@ import java.io.InputStream import java.net.HttpURLConnection import java.net.URL import java.util.concurrent.Executors +import java.util.concurrent.ScheduledExecutorService import java.util.jar.JarInputStream import javax.servlet.http.HttpServletResponse.SC_OK import javax.ws.rs.core.HttpHeaders.CONTENT_DISPOSITION @@ -73,13 +75,19 @@ fun main(args: Array) { /** An in memory test zip attachment of at least numOfClearBytes size, will be used. */ fun sender(rpc: CordaRPCOps, numOfClearBytes: Int = 1024) { // default size 1K. val (inputStream, hash) = InputStreamAndHash.createInMemoryTestZip(numOfClearBytes, 0) - sender(rpc, inputStream, hash) + val executor = Executors.newScheduledThreadPool(2) + try { + sender(rpc, inputStream, hash, executor) + } finally { + executor.shutdown() + } } -fun sender(rpc: CordaRPCOps, inputStream: InputStream, hash: SecureHash.SHA256) { +private fun sender(rpc: CordaRPCOps, inputStream: InputStream, hash: SecureHash.SHA256, executor: ScheduledExecutorService) { + // Get the identity key of the other side (the recipient). - val executor = Executors.newScheduledThreadPool(1) - val otherSide: Party = poll(executor, DUMMY_BANK_B.name.toString()) { rpc.partyFromX500Name(DUMMY_BANK_B.name) }.get() + val notaryFuture: ListenableFuture = poll(executor, DUMMY_NOTARY.name.toString()) { rpc.partyFromX500Name(DUMMY_NOTARY.name) } + val otherSideFuture: ListenableFuture = poll(executor, DUMMY_BANK_B.name.toString()) { rpc.partyFromX500Name(DUMMY_BANK_B.name) } // Make sure we have the file in storage if (!rpc.attachmentExists(hash)) { @@ -90,14 +98,14 @@ fun sender(rpc: CordaRPCOps, inputStream: InputStream, hash: SecureHash.SHA256) require(rpc.attachmentExists(hash)) } - val flowHandle = rpc.startTrackedFlow(::AttachmentDemoFlow, otherSide, hash) + val flowHandle = rpc.startTrackedFlow(::AttachmentDemoFlow, otherSideFuture.get(), notaryFuture.get(), hash) flowHandle.progress.subscribe(::println) val stx = flowHandle.returnValue.getOrThrow() println("Sent ${stx.id}") } @StartableByRPC -class AttachmentDemoFlow(val otherSide: Party, val hash: SecureHash.SHA256) : FlowLogic() { +class AttachmentDemoFlow(val otherSide: Party, val notary: Party, val hash: SecureHash.SHA256) : FlowLogic() { object SIGNING : ProgressTracker.Step("Signing transaction") @@ -106,7 +114,7 @@ class AttachmentDemoFlow(val otherSide: Party, val hash: SecureHash.SHA256) : Fl @Suspendable override fun call(): SignedTransaction { // Create a trivial transaction with an output that describes the attachment, and the attachment itself - val ptx = TransactionBuilder(notary = DUMMY_NOTARY) + val ptx = TransactionBuilder(notary) ptx.addOutputState(AttachmentContract.State(hash)) ptx.addAttachment(hash) diff --git a/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/api/BankOfCordaClientApi.kt b/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/api/BankOfCordaClientApi.kt index 2f4da02b39..896c9bbcb2 100644 --- a/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/api/BankOfCordaClientApi.kt +++ b/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/api/BankOfCordaClientApi.kt @@ -10,6 +10,7 @@ import net.corda.core.utilities.OpaqueBytes import net.corda.core.transactions.SignedTransaction import net.corda.core.utilities.NetworkHostAndPort import net.corda.flows.IssuerFlow.IssuanceRequester +import net.corda.testing.DUMMY_NOTARY import net.corda.testing.http.HttpApi /** @@ -33,20 +34,22 @@ class BankOfCordaClientApi(val hostAndPort: NetworkHostAndPort) { val client = CordaRPCClient(hostAndPort) // TODO: privileged security controls required client.start("bankUser", "test").use { connection -> - val proxy = connection.proxy + val rpc = connection.proxy // Resolve parties via RPC - val issueToParty = proxy.partyFromX500Name(params.issueToPartyName) + val issueToParty = rpc.partyFromX500Name(params.issueToPartyName) ?: throw Exception("Unable to locate ${params.issueToPartyName} in Network Map Service") - val issuerBankParty = proxy.partyFromX500Name(params.issuerBankName) + val issuerBankParty = rpc.partyFromX500Name(params.issuerBankName) ?: throw Exception("Unable to locate ${params.issuerBankName} in Network Map Service") - val notaryParty = proxy.partyFromX500Name(params.notaryName) - ?: throw Exception("Unable to locate ${params.notaryName} in Network Map Service") + val notaryLegalIdentity = rpc.partyFromX500Name(params.notaryName) + ?: throw IllegalStateException("Unable to locate ${params.notaryName} in Network Map Service") + val notaryNode = rpc.nodeIdentityFromParty(notaryLegalIdentity) + ?: throw IllegalStateException("Unable to locate notary node in network map cache") val amount = Amount(params.amount, currency(params.currency)) val issuerToPartyRef = OpaqueBytes.of(params.issueToPartyRefAsString.toByte()) - return proxy.startFlow(::IssuanceRequester, amount, issueToParty, issuerToPartyRef, issuerBankParty, notaryParty, params.anonymous) + return rpc.startFlow(::IssuanceRequester, amount, issueToParty, issuerToPartyRef, issuerBankParty, notaryNode.notaryIdentity, params.anonymous) .returnValue.getOrThrow().stx } } diff --git a/samples/irs-demo/build.gradle b/samples/irs-demo/build.gradle index 05866ff070..70d42a9d19 100644 --- a/samples/irs-demo/build.gradle +++ b/samples/irs-demo/build.gradle @@ -48,9 +48,9 @@ dependencies { task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { directory "./build/nodes" - networkMap "CN=Notary Service,O=R3,OU=corda,L=London,C=GB" + networkMap "CN=Notary Service,O=R3,OU=corda,L=Zurich,C=CH" node { - name "CN=Notary Service,O=R3,OU=corda,L=London,C=GB" + name "CN=Notary Service,O=R3,OU=corda,L=Zurich,C=CH" advertisedServices = ["corda.notary.validating", "corda.interest_rates"] p2pPort 10002 rpcPort 10003 @@ -115,4 +115,4 @@ publishing { jar { from sourceSets.test.output -} \ No newline at end of file +} diff --git a/samples/simm-valuation-demo/build.gradle b/samples/simm-valuation-demo/build.gradle index 9d7a5fcc57..41deacb868 100644 --- a/samples/simm-valuation-demo/build.gradle +++ b/samples/simm-valuation-demo/build.gradle @@ -59,9 +59,9 @@ dependencies { task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { directory "./build/nodes" - networkMap "CN=Notary Service,O=R3,OU=corda,L=London,C=GB" + networkMap "CN=Notary Service,O=R3,OU=corda,L=Zurich,C=CH" node { - name "CN=Notary Service,O=R3,OU=corda,L=London,C=GB" + name "CN=Notary Service,O=R3,OU=corda,L=Zurich,C=CH" advertisedServices = ["corda.notary.validating"] p2pPort 10002 cordapps = [] diff --git a/samples/trader-demo/build.gradle b/samples/trader-demo/build.gradle index c3cd3b5060..5fc1ab4f0d 100644 --- a/samples/trader-demo/build.gradle +++ b/samples/trader-demo/build.gradle @@ -47,9 +47,9 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { directory "./build/nodes" // This name "Notary" is hard-coded into TraderDemoClientApi so if you change it here, change it there too. // In this demo the node that runs a standalone notary also acts as the network map server. - networkMap "CN=Notary Service,O=R3,OU=corda,L=London,C=GB" + networkMap "CN=Notary Service,O=R3,OU=corda,L=Zurich,C=CH" node { - name "CN=Notary Service,O=R3,OU=corda,L=London,C=GB" + name "CN=Notary Service,O=R3,OU=corda,L=Zurich,C=CH" advertisedServices = ["corda.notary.validating"] p2pPort 10002 cordapps = []