diff --git a/node/src/main/kotlin/com/r3corda/node/internal/Node.kt b/node/src/main/kotlin/com/r3corda/node/internal/Node.kt index 205ffc736e..75b217bc62 100644 --- a/node/src/main/kotlin/com/r3corda/node/internal/Node.kt +++ b/node/src/main/kotlin/com/r3corda/node/internal/Node.kt @@ -47,9 +47,6 @@ class ConfigurationException(message: String) : Exception(message) * network map service, while bootstrapping a network. * @param advertisedServices The services this node advertises. This must be a subset of the services it runs, * but nodes are not required to advertise services they run (hence subset). - * @param clientAPIs A list of JAX-RS annotated classes to register - * which will be used to register any extra client web interfaces the node requires for demos to use. - * Listed clientAPI classes are assumed to have to take a single APIServer constructor parameter. * @param clock The clock used within the node and by all protocols etc. */ class Node(dir: Path, val p2pAddr: HostAndPort, val webServerAddr: HostAndPort, configuration: NodeConfiguration, @@ -177,8 +174,8 @@ class Node(dir: Path, val p2pAddr: HostAndPort, val webServerAddr: HostAndPort, val f = RandomAccessFile(file, "rw") val l = f.channel.tryLock() if (l == null) { - println("It appears there is already a node running with the specified data directory $dir") - println("Shut that other node down and try again. It may have process ID ${file.readText()}") + log.error("It appears there is already a node running with the specified data directory $dir") + log.error("Shut that other node down and try again. It may have process ID ${file.readText()}") System.exit(1) } diff --git a/scripts/example.rates.txt b/scripts/example.rates.txt new file mode 100644 index 0000000000..cb49751d27 --- /dev/null +++ b/scripts/example.rates.txt @@ -0,0 +1,227 @@ +# Some pretend noddy rate fixes, for the interest rate oracles. + +ICE LIBOR 2016-03-16 1M = 0.678 +ICE LIBOR 2016-03-16 2M = 0.655 +EURIBOR 2016-03-15 1M = 0.123 +EURIBOR 2016-03-15 2M = 0.111 + +ICE LIBOR 2016-03-06 3M = 0.0063515 +ICE LIBOR 2016-03-07 3M = 0.0063516 +ICE LIBOR 2016-03-08 3M = 0.0063517 +ICE LIBOR 2016-03-09 3M = 0.0063518 +ICE LIBOR 2016-03-10 3M = 0.0063519 +ICE LIBOR 2016-06-06 3M = 0.0063520 +ICE LIBOR 2016-06-07 3M = 0.0063521 +ICE LIBOR 2016-06-08 3M = 0.0063522 +ICE LIBOR 2016-06-09 3M = 0.0063523 +ICE LIBOR 2016-06-10 3M = 0.0063524 +ICE LIBOR 2016-09-06 3M = 0.0063525 +ICE LIBOR 2016-09-07 3M = 0.0063526 +ICE LIBOR 2016-09-08 3M = 0.0063527 +ICE LIBOR 2016-09-09 3M = 0.0063528 +ICE LIBOR 2016-09-10 3M = 0.0063529 +ICE LIBOR 2016-12-06 3M = 0.0063530 +ICE LIBOR 2016-12-07 3M = 0.0063531 +ICE LIBOR 2016-12-08 3M = 0.0063532 +ICE LIBOR 2016-12-09 3M = 0.0063533 +ICE LIBOR 2016-12-10 3M = 0.0063534 +ICE LIBOR 2017-03-06 3M = 0.0063535 +ICE LIBOR 2017-03-07 3M = 0.0063536 +ICE LIBOR 2017-03-08 3M = 0.0063537 +ICE LIBOR 2017-03-09 3M = 0.0063538 +ICE LIBOR 2017-03-10 3M = 0.0063539 +ICE LIBOR 2017-06-06 3M = 0.0063540 +ICE LIBOR 2017-06-07 3M = 0.0063541 +ICE LIBOR 2017-06-08 3M = 0.0063542 +ICE LIBOR 2017-06-09 3M = 0.0063543 +ICE LIBOR 2017-06-10 3M = 0.0063544 +ICE LIBOR 2017-09-06 3M = 0.0063545 +ICE LIBOR 2017-09-07 3M = 0.0063546 +ICE LIBOR 2017-09-08 3M = 0.0063547 +ICE LIBOR 2017-09-09 3M = 0.0063548 +ICE LIBOR 2017-09-10 3M = 0.0063549 +ICE LIBOR 2017-12-06 3M = 0.0063550 +ICE LIBOR 2017-12-07 3M = 0.0063551 +ICE LIBOR 2017-12-08 3M = 0.0063552 +ICE LIBOR 2017-12-09 3M = 0.0063553 +ICE LIBOR 2017-12-10 3M = 0.0063554 +ICE LIBOR 2018-03-06 3M = 0.0063555 +ICE LIBOR 2018-03-07 3M = 0.0063556 +ICE LIBOR 2018-03-08 3M = 0.0063557 +ICE LIBOR 2018-03-09 3M = 0.0063558 +ICE LIBOR 2018-03-10 3M = 0.0063559 +ICE LIBOR 2018-06-06 3M = 0.0063560 +ICE LIBOR 2018-06-07 3M = 0.0063561 +ICE LIBOR 2018-06-08 3M = 0.0063562 +ICE LIBOR 2018-06-09 3M = 0.0063563 +ICE LIBOR 2018-06-10 3M = 0.0063564 +ICE LIBOR 2018-09-06 3M = 0.0063565 +ICE LIBOR 2018-09-07 3M = 0.0063566 +ICE LIBOR 2018-09-08 3M = 0.0063567 +ICE LIBOR 2018-09-09 3M = 0.0063568 +ICE LIBOR 2018-09-10 3M = 0.0063569 +ICE LIBOR 2018-12-06 3M = 0.0063570 +ICE LIBOR 2018-12-07 3M = 0.0063571 +ICE LIBOR 2018-12-08 3M = 0.0063572 +ICE LIBOR 2018-12-09 3M = 0.0063573 +ICE LIBOR 2018-12-10 3M = 0.0063574 +ICE LIBOR 2019-03-06 3M = 0.0063575 +ICE LIBOR 2019-03-07 3M = 0.0063576 +ICE LIBOR 2019-03-08 3M = 0.0063577 +ICE LIBOR 2019-03-09 3M = 0.0063578 +ICE LIBOR 2019-03-10 3M = 0.0063579 +ICE LIBOR 2019-06-06 3M = 0.0063580 +ICE LIBOR 2019-06-07 3M = 0.0063581 +ICE LIBOR 2019-06-08 3M = 0.0063582 +ICE LIBOR 2019-06-09 3M = 0.0063583 +ICE LIBOR 2019-06-10 3M = 0.0063584 +ICE LIBOR 2019-09-06 3M = 0.0063585 +ICE LIBOR 2019-09-07 3M = 0.0063586 +ICE LIBOR 2019-09-08 3M = 0.0063587 +ICE LIBOR 2019-09-09 3M = 0.0063588 +ICE LIBOR 2019-09-10 3M = 0.0063589 +ICE LIBOR 2019-12-06 3M = 0.0063590 +ICE LIBOR 2019-12-07 3M = 0.0063591 +ICE LIBOR 2019-12-08 3M = 0.0063592 +ICE LIBOR 2019-12-09 3M = 0.0063593 +ICE LIBOR 2019-12-10 3M = 0.0063594 +ICE LIBOR 2020-03-06 3M = 0.0063595 +ICE LIBOR 2020-03-07 3M = 0.0063596 +ICE LIBOR 2020-03-08 3M = 0.0063597 +ICE LIBOR 2020-03-09 3M = 0.0063598 +ICE LIBOR 2020-03-10 3M = 0.0063599 +ICE LIBOR 2020-06-06 3M = 0.0063600 +ICE LIBOR 2020-06-07 3M = 0.0063601 +ICE LIBOR 2020-06-08 3M = 0.0063602 +ICE LIBOR 2020-06-09 3M = 0.0063603 +ICE LIBOR 2020-06-10 3M = 0.0063604 +ICE LIBOR 2020-09-06 3M = 0.0063605 +ICE LIBOR 2020-09-07 3M = 0.0063606 +ICE LIBOR 2020-09-08 3M = 0.0063607 +ICE LIBOR 2020-09-09 3M = 0.0063608 +ICE LIBOR 2020-09-10 3M = 0.0063609 +ICE LIBOR 2020-12-06 3M = 0.0063610 +ICE LIBOR 2020-12-07 3M = 0.0063611 +ICE LIBOR 2020-12-08 3M = 0.0063612 +ICE LIBOR 2020-12-09 3M = 0.0063613 +ICE LIBOR 2020-12-10 3M = 0.0063614 +ICE LIBOR 2021-03-06 3M = 0.0063615 +ICE LIBOR 2021-03-07 3M = 0.0063616 +ICE LIBOR 2021-03-08 3M = 0.0063617 +ICE LIBOR 2021-03-09 3M = 0.0063618 +ICE LIBOR 2021-03-10 3M = 0.0063619 +ICE LIBOR 2021-06-06 3M = 0.0063620 +ICE LIBOR 2021-06-07 3M = 0.0063621 +ICE LIBOR 2021-06-08 3M = 0.0063622 +ICE LIBOR 2021-06-09 3M = 0.0063623 +ICE LIBOR 2021-06-10 3M = 0.0063624 +ICE LIBOR 2021-09-06 3M = 0.0063625 +ICE LIBOR 2021-09-07 3M = 0.0063626 +ICE LIBOR 2021-09-08 3M = 0.0063627 +ICE LIBOR 2021-09-09 3M = 0.0063628 +ICE LIBOR 2021-09-10 3M = 0.0063629 +ICE LIBOR 2021-12-06 3M = 0.0063630 +ICE LIBOR 2021-12-07 3M = 0.0063631 +ICE LIBOR 2021-12-08 3M = 0.0063632 +ICE LIBOR 2021-12-09 3M = 0.0063633 +ICE LIBOR 2021-12-10 3M = 0.0063634 +ICE LIBOR 2022-03-06 3M = 0.0063635 +ICE LIBOR 2022-03-07 3M = 0.0063636 +ICE LIBOR 2022-03-08 3M = 0.0063637 +ICE LIBOR 2022-03-09 3M = 0.0063638 +ICE LIBOR 2022-03-10 3M = 0.0063639 +ICE LIBOR 2022-06-06 3M = 0.0063640 +ICE LIBOR 2022-06-07 3M = 0.0063641 +ICE LIBOR 2022-06-08 3M = 0.0063642 +ICE LIBOR 2022-06-09 3M = 0.0063643 +ICE LIBOR 2022-06-10 3M = 0.0063644 +ICE LIBOR 2022-09-06 3M = 0.0063645 +ICE LIBOR 2022-09-07 3M = 0.0063646 +ICE LIBOR 2022-09-08 3M = 0.0063647 +ICE LIBOR 2022-09-09 3M = 0.0063648 +ICE LIBOR 2022-09-10 3M = 0.0063649 +ICE LIBOR 2022-12-06 3M = 0.0063650 +ICE LIBOR 2022-12-07 3M = 0.0063651 +ICE LIBOR 2022-12-08 3M = 0.0063652 +ICE LIBOR 2022-12-09 3M = 0.0063653 +ICE LIBOR 2022-12-10 3M = 0.0063654 +ICE LIBOR 2023-03-06 3M = 0.0063655 +ICE LIBOR 2023-03-07 3M = 0.0063656 +ICE LIBOR 2023-03-08 3M = 0.0063657 +ICE LIBOR 2023-03-09 3M = 0.0063658 +ICE LIBOR 2023-03-10 3M = 0.0063659 +ICE LIBOR 2023-06-06 3M = 0.0063660 +ICE LIBOR 2023-06-07 3M = 0.0063661 +ICE LIBOR 2023-06-08 3M = 0.0063662 +ICE LIBOR 2023-06-09 3M = 0.0063663 +ICE LIBOR 2023-06-10 3M = 0.0063664 +ICE LIBOR 2023-09-06 3M = 0.0063665 +ICE LIBOR 2023-09-07 3M = 0.0063666 +ICE LIBOR 2023-09-08 3M = 0.0063667 +ICE LIBOR 2023-09-09 3M = 0.0063668 +ICE LIBOR 2023-09-10 3M = 0.0063669 +ICE LIBOR 2023-12-06 3M = 0.0063670 +ICE LIBOR 2023-12-07 3M = 0.0063671 +ICE LIBOR 2023-12-08 3M = 0.0063672 +ICE LIBOR 2023-12-09 3M = 0.0063673 +ICE LIBOR 2023-12-10 3M = 0.0063674 +ICE LIBOR 2024-03-06 3M = 0.0063675 +ICE LIBOR 2024-03-07 3M = 0.0063676 +ICE LIBOR 2024-03-08 3M = 0.0063677 +ICE LIBOR 2024-03-09 3M = 0.0063678 +ICE LIBOR 2024-03-10 3M = 0.0063679 +ICE LIBOR 2024-06-06 3M = 0.0063680 +ICE LIBOR 2024-06-07 3M = 0.0063681 +ICE LIBOR 2024-06-08 3M = 0.0063682 +ICE LIBOR 2024-06-09 3M = 0.0063683 +ICE LIBOR 2024-06-10 3M = 0.0063684 +ICE LIBOR 2024-09-06 3M = 0.0063685 +ICE LIBOR 2024-09-07 3M = 0.0063686 +ICE LIBOR 2024-09-08 3M = 0.0063687 +ICE LIBOR 2024-09-09 3M = 0.0063688 +ICE LIBOR 2024-09-10 3M = 0.0063689 +ICE LIBOR 2024-12-06 3M = 0.0063690 +ICE LIBOR 2024-12-07 3M = 0.0063691 +ICE LIBOR 2024-12-08 3M = 0.0063692 +ICE LIBOR 2024-12-09 3M = 0.0063693 +ICE LIBOR 2024-12-10 3M = 0.0063694 +ICE LIBOR 2025-03-06 3M = 0.0063695 +ICE LIBOR 2025-03-07 3M = 0.0063696 +ICE LIBOR 2025-03-08 3M = 0.0063697 +ICE LIBOR 2025-03-09 3M = 0.0063698 +ICE LIBOR 2025-03-10 3M = 0.0063699 +ICE LIBOR 2025-06-06 3M = 0.0063700 +ICE LIBOR 2025-06-07 3M = 0.0063701 +ICE LIBOR 2025-06-08 3M = 0.0063702 +ICE LIBOR 2025-06-09 3M = 0.0063703 +ICE LIBOR 2025-06-10 3M = 0.0063704 +ICE LIBOR 2025-09-06 3M = 0.0063705 +ICE LIBOR 2025-09-07 3M = 0.0063706 +ICE LIBOR 2025-09-08 3M = 0.0063707 +ICE LIBOR 2025-09-09 3M = 0.0063708 +ICE LIBOR 2025-09-10 3M = 0.0063709 +ICE LIBOR 2025-12-06 3M = 0.0063710 +ICE LIBOR 2025-12-07 3M = 0.0063711 +ICE LIBOR 2025-12-08 3M = 0.0063712 +ICE LIBOR 2025-12-09 3M = 0.0063713 +ICE LIBOR 2025-12-10 3M = 0.0063714 +ICE LIBOR 2026-03-06 3M = 0.0063715 +ICE LIBOR 2026-03-07 3M = 0.0063716 +ICE LIBOR 2026-03-08 3M = 0.0063717 +ICE LIBOR 2026-03-09 3M = 0.0063718 +ICE LIBOR 2026-03-10 3M = 0.0063719 +ICE LIBOR 2026-06-06 3M = 0.0063720 +ICE LIBOR 2026-06-07 3M = 0.0063721 +ICE LIBOR 2026-06-08 3M = 0.0063722 +ICE LIBOR 2026-06-09 3M = 0.0063723 +ICE LIBOR 2026-06-10 3M = 0.0063724 +ICE LIBOR 2026-09-06 3M = 0.0063725 +ICE LIBOR 2026-09-07 3M = 0.0063726 +ICE LIBOR 2026-09-08 3M = 0.0063727 +ICE LIBOR 2026-09-09 3M = 0.0063728 +ICE LIBOR 2026-09-10 3M = 0.0063729 +ICE LIBOR 2026-12-06 3M = 0.0063730 +ICE LIBOR 2026-12-07 3M = 0.0063731 +ICE LIBOR 2026-12-08 3M = 0.0063732 +ICE LIBOR 2026-12-09 3M = 0.0063733 +ICE LIBOR 2026-12-10 3M = 0.0063734 \ No newline at end of file diff --git a/scripts/get-rate-fix.sh b/scripts/get-rate-fix.sh index 504649224c..53e30facd0 100755 --- a/scripts/get-rate-fix.sh +++ b/scripts/get-rate-fix.sh @@ -13,7 +13,7 @@ if [ ! -e $bin ]; then ./gradlew installDist fi -if [ ! -e buyer/identity-public ]; then +if [ ! -e build/trader-demo/buyer/identity-public ]; then echo "You must run scripts/trade-demo.sh buyer before running this script (and keep it running)" exit 1 fi @@ -21,4 +21,4 @@ fi # Upload the rates to the buyer node curl -F rates=@scripts/example.rates.txt http://localhost:31338/upload/interest-rates -$bin --network-address=localhost:31300 --oracle=localhost --oracle-identity-file=buyer/identity-public \ No newline at end of file +$bin --network-address=localhost:31300 --directory=build/trader-demo/rates-fix --network-map=localhost:31337 --network-map-identity-file=build/trader-demo/buyer/identity-public --oracle=localhost --oracle-identity-file=build/trader-demo/buyer/identity-public \ No newline at end of file diff --git a/src/main/kotlin/com/r3corda/demos/IRSDemo.kt b/src/main/kotlin/com/r3corda/demos/IRSDemo.kt index 4056eea3d7..58afaae302 100644 --- a/src/main/kotlin/com/r3corda/demos/IRSDemo.kt +++ b/src/main/kotlin/com/r3corda/demos/IRSDemo.kt @@ -37,6 +37,8 @@ import java.util.* import kotlin.concurrent.fixedRateTimer import kotlin.system.exitProcess import com.r3corda.demos.utilities.* +import org.slf4j.Logger +import org.slf4j.LoggerFactory // IRS DEMO // @@ -268,6 +270,8 @@ private class NotSetupException: Throwable { constructor(message: String): super(message) {} } +private val log: Logger = LoggerFactory.getLogger("IRSDemo") + fun main(args: Array) { exitProcess(runIRSDemo(args)) } @@ -276,7 +280,7 @@ fun runIRSDemo(args: Array): Int { val cliParams = try { CliParams.parse(CliParamsSpec.parser.parse(*args)) } catch (e: Exception) { - println(e) + log.error(e.message) printHelp(CliParamsSpec.parser) return 1 } @@ -343,7 +347,7 @@ private fun runNode(cliParams: CliParams.RunNode): Int { node.stop() } } catch (e: NotSetupException) { - println(e.message) + log.error(e.message) return 1 } @@ -351,28 +355,28 @@ private fun runNode(cliParams: CliParams.RunNode): Int { } private fun runDateChange(cliParams: CliParams.DateChange): Int { - println("Changing date to " + cliParams.dateString) + log.info("Changing date to " + cliParams.dateString) val url = URL("http://${cliParams.apiAddress}/api/irs/demodate") if (putJson(url, "\"" + cliParams.dateString + "\"")) { - println("Date changed") + log.info("Date changed") return 0 } else { - println("Date failed to change") + log.error("Date failed to change") return 1 } } private fun runTrade(cliParams: CliParams.Trade): Int { - println("Uploading tradeID " + cliParams.tradeId) + log.info("Uploading tradeID " + cliParams.tradeId) // Note: the getResourceAsStream is an ugly hack to get the jvm to search in the right location val fileContents = IOUtils.toString(CliParams::class.java.getResourceAsStream("example-irs-trade.json")) val tradeFile = fileContents.replace("tradeXXX", cliParams.tradeId) val url = URL("http://${cliParams.apiAddress}/api/irs/deals") if (postJson(url, tradeFile)) { - println("Trade sent") + log.info("Trade sent") return 0 } else { - println("Trade failed to send") + log.error("Trade failed to send") return 1 } } @@ -397,7 +401,7 @@ private fun startNode(params: CliParams.RunNode, networkMap: SingleMessageRecipi } } - val node = logElapsedTime("Node startup") { + val node = logElapsedTime("Node startup", log) { Node(params.dir, params.networkAddress, params.apiAddress, config, networkMapId, advertisedServices, DemoClock()).start() } @@ -417,7 +421,7 @@ private fun nodeInfo(recipient: SingleMessageRecipient, identityFile: Path, adve val party = parsePartyFromFile(identityFile) return NodeInfo(recipient, party, advertisedServices) } catch (e: Exception) { - println("Could not find identify file $identityFile.") + log.error("Could not find identify file $identityFile.") throw e } } @@ -431,12 +435,12 @@ private fun runUploadRates(host: HostAndPort) { val url = URL("http://${host.toString()}/upload/interest-rates") if (uploadFile(url, fileContents)) { timer!!.cancel() - println("Rates uploaded successfully") + log.info("Rates uploaded successfully") } else { - print("Could not upload rates. Retrying in 5 seconds. ") + log.error("Could not upload rates. Retrying in 5 seconds. ") } } catch (e: Exception) { - println("Could not upload rates due to exception. Retrying in 5 seconds") + log.error("Could not upload rates due to exception. Retrying in 5 seconds") } }) } @@ -457,7 +461,7 @@ private fun getNodeConfig(cliParams: CliParams.RunNode): NodeConfiguration { private fun loadConfigFile(configFile: File, defaultLegalName: String): NodeConfiguration { if (!configFile.exists()) { createDefaultConfigFile(configFile, defaultLegalName) - println("Default config created at $configFile.") + log.warn("Default config created at $configFile.") } val config = ConfigFactory.parseFile(configFile).withFallback(ConfigFactory.load()) diff --git a/src/main/kotlin/com/r3corda/demos/RateFixDemo.kt b/src/main/kotlin/com/r3corda/demos/RateFixDemo.kt index 1374c58dd4..08960dbfa2 100644 --- a/src/main/kotlin/com/r3corda/demos/RateFixDemo.kt +++ b/src/main/kotlin/com/r3corda/demos/RateFixDemo.kt @@ -11,18 +11,23 @@ import com.r3corda.core.node.services.ServiceType import com.r3corda.core.serialization.deserialize import com.r3corda.core.utilities.BriefLogFormatter import com.r3corda.core.utilities.Emoji -import com.r3corda.demos.api.InterestRateSwapAPI import com.r3corda.node.internal.Node import com.r3corda.node.services.clientapi.NodeInterestRates import com.r3corda.node.services.config.NodeConfiguration import com.r3corda.node.services.messaging.ArtemisMessagingService +import com.r3corda.node.services.network.NetworkMapService +import com.r3corda.node.services.transactions.NotaryService import com.r3corda.protocols.RatesFixProtocol import joptsimple.OptionParser +import org.slf4j.Logger +import org.slf4j.LoggerFactory import java.math.BigDecimal import java.nio.file.Files import java.nio.file.Paths import kotlin.system.exitProcess +private val log: Logger = LoggerFactory.getLogger("RatesFixDemo") + /** * Creates a dummy transaction that requires a rate fix within a certain range, and gets it signed by an oracle * service. @@ -36,14 +41,14 @@ fun main(args: Array) { val oracleAddrArg = parser.accepts("oracle").withRequiredArg().required() val oracleIdentityArg = parser.accepts("oracle-identity-file").withRequiredArg().required() - val fixOfArg = parser.accepts("fix-of").withRequiredArg().defaultsTo("LIBOR 2016-03-16 1M") + val fixOfArg = parser.accepts("fix-of").withRequiredArg().defaultsTo("ICE LIBOR 2016-03-16 1M") val expectedRateArg = parser.accepts("expected-rate").withRequiredArg().defaultsTo("0.67") val rateToleranceArg = parser.accepts("rate-tolerance").withRequiredArg().defaultsTo("0.1") val options = try { parser.parse(*args) } catch (e: Exception) { - println(e.message) + log.error(e.message) exitProcess(1) } @@ -53,7 +58,7 @@ fun main(args: Array) { val dir = Paths.get(options.valueOf(dirArg)) val networkMapAddr = ArtemisMessagingService.makeRecipient(options.valueOf(networkMapAddrArg)) val networkMapIdentity = Files.readAllBytes(Paths.get(options.valueOf(networkMapIdentityArg))).deserialize() - val networkMapAddress = NodeInfo(networkMapAddr, networkMapIdentity) + val networkMapAddress = NodeInfo(networkMapAddr, networkMapIdentity, setOf(NetworkMapService.Type, NotaryService.Type)) // Load oracle stuff (in lieu of having a network map service) val oracleAddr = ArtemisMessagingService.makeRecipient(options.valueOf(oracleAddrArg)) @@ -77,7 +82,7 @@ fun main(args: Array) { val node = logElapsedTime("Node startup") { Node(dir, myNetAddr, apiAddr, config, networkMapAddress, advertisedServices, DemoClock()).setup().start() } - + node.networkMapRegistrationFuture.get() val notary = node.services.networkMapCache.notaryNodes[0] // Make a garbage transaction that includes a rate fix. @@ -88,8 +93,7 @@ fun main(args: Array) { node.stop() // Show the user the output. - println("Got rate fix") - println() + log.info("Got rate fix\n") print(Emoji.renderIfSupported(tx.toWireTransaction())) - println(tx.toSignedTransaction().sigs) + println(tx.toSignedTransaction().sigs.toString()) } diff --git a/src/main/kotlin/com/r3corda/demos/TraderDemo.kt b/src/main/kotlin/com/r3corda/demos/TraderDemo.kt index 04d9f8871a..ca2c357cfe 100644 --- a/src/main/kotlin/com/r3corda/demos/TraderDemo.kt +++ b/src/main/kotlin/com/r3corda/demos/TraderDemo.kt @@ -31,6 +31,8 @@ import com.r3corda.protocols.NotaryProtocol import com.r3corda.protocols.TwoPartyTradeProtocol import com.typesafe.config.ConfigFactory import joptsimple.OptionParser +import org.slf4j.Logger +import org.slf4j.LoggerFactory import java.nio.file.Files import java.nio.file.Path import java.nio.file.Paths @@ -67,6 +69,8 @@ enum class Role { // which holds things like checkpoints, keys, databases, message logs etc. val DEFAULT_BASE_DIRECTORY = "./build/trader-demo" +private val log: Logger = LoggerFactory.getLogger("TraderDemo") + fun main(args: Array) { exitProcess(runTraderDemo(args)) } @@ -83,7 +87,7 @@ fun runTraderDemo(args: Array): Int { val options = try { parser.parse(*args) } catch (e: Exception) { - println(e.message) + log.error(e.message) printHelp(parser) return 1 } @@ -113,7 +117,7 @@ fun runTraderDemo(args: Array): Int { BriefLogFormatter.initVerbose("+demo.buyer", "+demo.seller", "-org.apache.activemq") val directory = Paths.get(baseDirectory, role.name.toLowerCase()) - println("Using base demo directory $directory") + log.info("Using base demo directory $directory") // Override the default config file (which you can find in the file "reference.conf") to give each node a name. val config = run { @@ -148,7 +152,7 @@ fun runTraderDemo(args: Array): Int { } // And now construct then start the node object. It takes a little while. - val node = logElapsedTime("Node startup") { + val node = logElapsedTime("Node startup", log) { Node(directory, myNetAddr, apiNetAddr, config, networkMapId, advertisedServices).setup().start() }