Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
381 views
in Technique[技术] by (71.8m points)

network programming - Corda nodes: how to connect two independent pc as two nodes?

One friend of mine and I are trying to develop a CorDapp for a financial use case, I can run the cordapp-tutorial and the demos, however they only run on localhost. We would like to create two "real" nodes and I understood correctly we should build two Corda nodes, my pc as one node server and his pc as another node server, but how can we effectively connect over the internet? On slack I have been told to enable dev-mode, but how do you enable it?

We have a corda.jar and the nodea.conf, but the part I don't really understand from the documentation is:

"Each node server by default must have a node.conf file in the current working directory. After first execution of the node server there will be many other configuration and persistence files created in this workspace directory. The directory can be overridden by the --base-directory= command line argument."

What is intended as working directory?

I've read this documentation : Corda Nodes

Thank to all, I think I will be asking a lot of question in the near future :D

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In Corda 3.1, you can use the network bootstrapper to create a dev-mode network of nodes running on two separate machines as follows:

  • Create the nodes by following the instructions here (e.g. by using gradlew deployNodes)

  • Navigate to the folder where the nodes were created (e.g. build/nodes)

  • Open the node.conf file of each node and change the localhost part of its p2pAddress to the IP address of the machine where the node will be run (e.g. p2pAddress="10.18.0.166:10007")

  • After making these changes, we need to redistribute the updated nodeInfo files to each node, so that they have the updated IP addresses for each node. Use the network bootstrapper tool to automatically update the files and have them distributed to each node:

    java -jar network-bootstrapper.jar kotlin-source/build/nodes

  • Move the node folders to their individual machines (e.g. using a USB key). It is important that none of the nodes - including the notary - end up on more than one machine. Each computer should also have a copy of runnodes and runnodes.bat.

    For example, you may end up with the following layout:

    • Machine 1: Notary, PartyA, runnodes, runnodes.bat

    • Machine 2: PartyB, PartyC, runnodes, runnodes.bat

  • After starting each node, the nodes will be able to see one another and agree ledger updates among themselves

Warning

The bootstrapper must be run after the node.conf files have been modified, but before the nodes are distributed across machines. Otherwise, the nodes will not have the updated IP addresses for each node and will not be able to communicate.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...