Blockchain By Example
上QQ阅读APP看书,第一时间看更新

Building a Readercoin network

As most of the work is done, let's put the results into practice.

At this level, everything is ready to launch our Readercoin network. We'll need to build a network of two connected machines, called Node A and Node B. Before advancing further, check that both machines can ping each other. Let's say Node A has the IP address 192.168.1.3, and Node B 192.168.1.8.

At this point, we have built Readercoin on a single machine (Node A), so we will need to build it on Node B in the same manner we did in Node A. For that, you can clone the code source from our remote repository, or just transfer the Readercoin folder using a USB memory stick. If successfully built, you will be ready to connect the P2P Readercoin nodes.

Once Readercoin is built successfully on both nodes, run the Qt client or readercoin-qt -printtoconsole.

The option -printtoconsole prints out the client log as follows:

Running the Readercoin client for the first time will create a .readercoin directory in your home directory, along with some other necessary files. Stop the client to create a configuration file named readercoin.conf in~/.readercoin and insert the following lines:

server=1
rpcuser=set a username
rpcpassword=set a password
addnode=the other node's IP
rpcallowip=192.168.0.0/16

Instead of using the addnode option in the configuration file, you can run the clients on both nodes and execute the addnode RPC call:

readercoin-cli addnode 192.168.1.3:9333 onetry (in nodeA)
readercoin-cli addnode 192.168.1.8:9333 onetry (in nodeB)

A log entry in both peers should appear, confirming a pairing similar to the following. If not, try it again or wait for a bit:

You can check whether both nodes are connected using readercoin-cli getpeerinfo.

You'll need to see all the connected peer information, as shown in following screenshot:

It's worth noting that you can run RPC commands from the GUI without using a terminal as follows:

  1. Open the Readercoin wallet
  2. Choose Help
  3. Select Debug window
  4. Select Console
  1. Execute your command line without using readercoin-cli:

Our nodes are ready to start sending and receiving Readercoins but, as you have noticed, we don't have any yet. Therefore, we need to start mining, either on one of the nodes or on both of them.