IRS demo endpoints are now parameterised for the Trade and Demo modes. Documentation fixes.

This commit is contained in:
Clinton Alexander 2016-06-06 12:30:59 +01:00
parent 0c94637685
commit 782d50958d
2 changed files with 21 additions and 8 deletions

View File

@ -58,13 +58,13 @@ Open three terminals. In the first run:
**Other**:: **Other**::
gradle installDist && ./build/install/r3prototyping/bin/irsdemo --role=NodeA ./gradlew installDist && ./build/install/r3prototyping/bin/irsdemo --role=NodeA
And in the second run: And in the second run:
**Windows**:: **Windows**::
.\build\install\r3prototyping\bin\irsdemo.bat --role=NodeB .\build\install\r3prototyping\bin\irsdemo.bat --role=NodeB
**Other**:: **Other**::

View File

@ -19,6 +19,7 @@ import com.r3corda.demos.api.InterestRateSwapAPI
import com.r3corda.demos.protocols.AutoOfferProtocol import com.r3corda.demos.protocols.AutoOfferProtocol
import com.r3corda.demos.protocols.ExitServerProtocol import com.r3corda.demos.protocols.ExitServerProtocol
import com.r3corda.demos.protocols.UpdateBusinessDayProtocol import com.r3corda.demos.protocols.UpdateBusinessDayProtocol
import com.r3corda.node.internal.AbstractNode
import joptsimple.OptionParser import joptsimple.OptionParser
import java.io.DataOutputStream import java.io.DataOutputStream
import java.net.HttpURLConnection import java.net.HttpURLConnection
@ -90,7 +91,13 @@ fun main(args: Array<String>) {
val tradeIdArgs = options.valuesOf(nonOptions) val tradeIdArgs = options.valuesOf(nonOptions)
if (tradeIdArgs.size > 0) { if (tradeIdArgs.size > 0) {
val tradeId = tradeIdArgs[0] val tradeId = tradeIdArgs[0]
if (runTrade(tradeId)) { val host = if (options.has(networkAddressArg)) {
options.valueOf(networkAddressArg)
} else {
"http://localhost:" + Node.DEFAULT_PORT + 1
}
if (runTrade(tradeId, host)) {
exitProcess(0) exitProcess(0)
} else { } else {
exitProcess(1) exitProcess(1)
@ -103,7 +110,13 @@ fun main(args: Array<String>) {
val dateStrArgs = options.valuesOf(nonOptions) val dateStrArgs = options.valuesOf(nonOptions)
if (dateStrArgs.size > 0) { if (dateStrArgs.size > 0) {
val dateStr = dateStrArgs[0] val dateStr = dateStrArgs[0]
runDateChange(dateStr) val host = if (options.has(networkAddressArg)) {
options.valueOf(networkAddressArg)
} else {
"http://localhost:" + Node.DEFAULT_PORT + 1
}
runDateChange(dateStr, host)
} else { } else {
println("Please provide a date") println("Please provide a date")
exitProcess(1) exitProcess(1)
@ -141,8 +154,8 @@ fun main(args: Array<String>) {
} }
} }
private fun runDateChange(date: String) : Boolean{ private fun runDateChange(date: String, host: String) : Boolean {
var url = URL("http://localhost:31338/api/irs/demodate") val url = URL(host + "/api/irs/demodate")
if(putJson(url, "\"" + date + "\"")) { if(putJson(url, "\"" + date + "\"")) {
println("Date changed") println("Date changed")
return true return true
@ -152,11 +165,11 @@ private fun runDateChange(date: String) : Boolean{
} }
} }
private fun runTrade(tradeId: String) : Boolean { private fun runTrade(tradeId: String, host: String) : Boolean {
println("Uploading tradeID " + tradeId) println("Uploading tradeID " + tradeId)
val fileContents = IOUtils.toString(NodeParams::class.java.getResourceAsStream("example-irs-trade.json")) val fileContents = IOUtils.toString(NodeParams::class.java.getResourceAsStream("example-irs-trade.json"))
val tradeFile = fileContents.replace("tradeXXX", tradeId) val tradeFile = fileContents.replace("tradeXXX", tradeId)
val url = URL("http://localhost:31338/api/irs/deals") val url = URL(host + "/api/irs/deals")
if(postJson(url, tradeFile)) { if(postJson(url, tradeFile)) {
println("Trade sent") println("Trade sent")
return true return true