How nodes search for each other in the TERA network. Trusted nodes.

Yuriy Ivanov
2 min readJul 18, 2020

Search for new addresses

At start, an attempt is made to connect to other nodes from the address book list (file jinn-nodes-xxx.lst). When you first run this file, it is empty, so in this case, the list of addresses sewn in the code is taken. When connecting, the node launches the “handshake” Protocol (the HANDSHAKE method), which tells about the network name, the name of the shard, and other information. Nodes compare each other’s parameters and if they don’t match, the connection is broken.

If successful, two protocols are executed:

  • Exchange of addresses (GETNODES method)
  • Connect the hot slot of the data exchange (method CONNECTLEVEL)

Each node has a limited number of slots (about 8), so switching to the state of exchanging transactions with this node is not always possible, since the slot may already be occupied. The exchange slot number is selected by comparing address hashes (ip addresses and port numbers). Since the hash has the property of random distribution, this way a high connectivity of node connections around the world is achieved. This makes the final speed of transaction propagation to each node (approximately 2–3 seconds).

Each node keeps a counter of successful exchanges with another node, this information is later used as a rating when connecting to other nodes. The higher the node’s rating, the more likely it is to connect to it and switch to data exchange mode.

Trusted nodes

If the network user has several nodes, they can assign a high priority for connecting them to each other. You can do this by editing a file with a list of addresses jinn-nodes-xxx.lst, which is in JSON format, by setting the Score parameter, for example, to 1000000:

{

“ip”: “10.20.30.45”,

“port”: 30000,

“Score”: 1000000

},

Or it can set a shared secret password for all nodes in constants (const.lst file):

“COMMON_KEY”: “secret1”,

How to hide a node

By default, when starting a node, it can work as a server-accept incoming connections, and as a client — create outgoing connections.

There are situations when we need to make a node invisible from the public network, for example, if a payment gateway is installed on it. In this case, you need to set a list of available ip addresses for this node at the network settings level (firewall), and use the constants setting:

1. Launch multiple nodes in cluster mode — i.e. with shared secret keys, and set the CLUSTER_HOT_ONLY exchange flag on the “invisible” node:

“CLUSTER_HOT_ONLY”: 1,

“COMMON_KEY”: “Secret1”,

2. Prohibit receiving incoming ip connections on the “invisible” node:

“CLIENT_MODE”: 1,

Recommendations:

Any constant can be changed from the command line as follows (run inside the wallet/Source directory):

node set ИМЯ_Константы=Значение

After changing the constants restart the node

--

--