From 7265614d5cc70f80db4200ea738de2a2dbaa0f50 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Thu, 17 Nov 2016 18:50:03 +0100 Subject: [PATCH] Samples: trader-demo can now be run from the command line with gradle --- .../Trader_Demo__Run_Buyer.xml | 15 +++++ .../Trader_Demo__Run_Nodes.xml | 15 +++++ .../Trader_Demo__Run_Seller.xml | 15 +++++ docs/source/running-the-demos.rst | 16 +++++ samples/trader-demo/README.md | 63 +------------------ samples/trader-demo/build.gradle | 4 +- 6 files changed, 65 insertions(+), 63 deletions(-) create mode 100644 .idea/runConfigurations/Trader_Demo__Run_Buyer.xml create mode 100644 .idea/runConfigurations/Trader_Demo__Run_Nodes.xml create mode 100644 .idea/runConfigurations/Trader_Demo__Run_Seller.xml diff --git a/.idea/runConfigurations/Trader_Demo__Run_Buyer.xml b/.idea/runConfigurations/Trader_Demo__Run_Buyer.xml new file mode 100644 index 0000000000..166781bed1 --- /dev/null +++ b/.idea/runConfigurations/Trader_Demo__Run_Buyer.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/.idea/runConfigurations/Trader_Demo__Run_Nodes.xml b/.idea/runConfigurations/Trader_Demo__Run_Nodes.xml new file mode 100644 index 0000000000..bf383f618f --- /dev/null +++ b/.idea/runConfigurations/Trader_Demo__Run_Nodes.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/.idea/runConfigurations/Trader_Demo__Run_Seller.xml b/.idea/runConfigurations/Trader_Demo__Run_Seller.xml new file mode 100644 index 0000000000..3412483e66 --- /dev/null +++ b/.idea/runConfigurations/Trader_Demo__Run_Seller.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/docs/source/running-the-demos.rst b/docs/source/running-the-demos.rst index e6a75b6766..b95882149f 100644 --- a/docs/source/running-the-demos.rst +++ b/docs/source/running-the-demos.rst @@ -20,6 +20,22 @@ so far. We have: Trader demo ----------- +This demo brings up three nodes: Bank A, Bank B and a notary/network map node that they both use. Bank A will +be the buyer, and self-issues some cash in order to acquire the commercial paper from Bank B, the seller. + +This can be run either from the command line (recommended for Mac/Linux/BSD users), or from inside IntelliJ. + +To run from the command line: + +1. Run ``./gradlew samples:trader-demo:deployNodes`` to create a set of configs and installs under ``samples/trader-demo/build/nodes`` +2. Run ``./samples/trader-demo/build/nodes/runnodes`` to open up three new terminal tabs/windows with the three nodes. +3. Run ``./gradlew samples:trader-demo:runBuyer`` to set up the buyer node with some self-issued cash. This step + is not expected to print much. +4. Run ``./gradlew samples:trader-demo:runSeller`` to trigger the transaction. You can see both sides of the + trade print their progress and final transaction state in the bank node tabs/windows. + +To run from IntelliJ: + 1. Open the Corda project in IntelliJ and run the "Install" configuration 2. Open the Corda samples project in IntelliJ and run the "Trader Demo: Run Nodes" configuration 3. Run "Trader Demo: Run Buyer" diff --git a/samples/trader-demo/README.md b/samples/trader-demo/README.md index 9edc752ba6..b2ef48efa0 100644 --- a/samples/trader-demo/README.md +++ b/samples/trader-demo/README.md @@ -1,64 +1,5 @@ # Trader Demo -Please see docs/build/html/running-the-demos.html +This demo shows a couple of nodes doing an atomic asset swap: cash for commercial paper. -This program is a simple driver for exercising the two party trading protocol. Until Corda has a unified node server -programs like this are required to wire up the pieces and run a demo scenario end to end. - -If you are creating a new scenario, you can use this program as a template for creating your own driver. Make sure to -copy/paste the right parts of the build.gradle file to make sure it gets a script to run it deposited in -build/install/r3prototyping/bin - -In this scenario, a buyer wants to purchase some commercial paper by swapping his cash for the CP. The seller learns -that the buyer exists, and sends them a message to kick off the trade. The seller, having obtained his CP, then quits -and the buyer goes back to waiting. The buyer will sell as much CP as he can! - -The different roles in the scenario this program can adopt are: - -This template contains the build system and an example application required to get started with [Corda](http://todo.todo). - -## Prerequisites - -You will need to have [JDK 8](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) -installed and available on your path. - -## Getting Started - -First clone this repository and the Corda repository locally. Then open a terminal window in the Corda directory and run: - -Unix: - - ./gradlew publishToMavenLocal - -Windows: - - gradle.bat publishToMavenLocal - -This will publish a copy of Corda to your local Maven repository for your Cordapp to use. Next open a terminal window -in your Cordapp directory (this one) and run: - -Unix: - - ./gradlew deployNodes - -Windows: - - gradlew.bat deployNodes - -This command will create several nodes in `build/nodes` that you can now run with: - -Unix: - - cd build/nodes - ./runnodes - -Windows: - - cd build/nodes - ruunnodes.bat - -This will now have nodes running on your machine running this Cordapp. You can now begin developing your Cordapp. - -## Further Reading - -Tutorials and developer docs for Cordapps and Corda are [here](https://docs.corda.r3cev.com). \ No newline at end of file +Please see docs/build/html/running-the-demos.html to learn how to use this demo. \ No newline at end of file diff --git a/samples/trader-demo/build.gradle b/samples/trader-demo/build.gradle index 1220251062..33843314e6 100644 --- a/samples/trader-demo/build.gradle +++ b/samples/trader-demo/build.gradle @@ -95,7 +95,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: [':install']) { cordapps = [] } node { - name "NodeA" + name "Bank A" dirName "nodea" nearestCity "London" advertisedServices = [] @@ -104,7 +104,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: [':install']) { cordapps = [] } node { - name "NodeB" + name "Bank B" dirName "nodeb" nearestCity "New York" advertisedServices = []