- Blockchain By Example
- Bellaj Badr Richard Horrocks Xun (Brian) Wu
- 305字
- 2021-06-10 18:53:43
Removing the seed nodes
Next, we'll need to remove the DNS seeds from the code. Bitcoin uses built-in DNS seeds, which are a list of host names for a DNS server to discover other nodes. A Bitcoin client issues DNS requests to learn about the addresses of other peer nodes, and, in response, the DNS seeds return a list of IP addresses of full nodes on the Bitcoin network to assist in peer discovery.
We'll need to remove or comment out the hardcoded seed nodes in the chainparams.cpp file. In this file, you'll find a vector of seed (vSeeds) to which they append a list of DNS URLs:
vSeeds.emplace_back("seed.bitcoin.sipa.be", true);
We need to comment out all occurrences of vSeeds.push_back and vSeeds.emplace_back in both CMainParams and CTestNetParams.
It's not over yet with seeds, as we'll need to deal with fixed IP seeds, either by commenting out the occurrences on the following line, as follows:
vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main));
Or by replacing this line with the following:
vFixedSeeds.clear();
vSeeds.clear();
Otherwise, you can include your proper DNS seed servers. In chainparamseeds.h, you'll find a list of IPs (wrapped inside IPv6 addresses) of nodes that can be connected to for mainnet and testnet to retrieve more IP addresses of nodes that can be connected to:
To set up a seed node, you just need to run a normal node for Readercoin and add its IP address to chainparamseeds.h, or anticipate a list of IPs that you'll use for your nodes later.
Under contrib/seeds, there is a Python script generate-seeds, which will help you to generate the pnSeed6_main and pnSeed6_test arrays that are compiled in the client.
In nodes_test.txt and nodes_main.txt, remove the existing IPs, set all your node IPs (one IP per line), and then run the following command:
~/workspace/readercoin/contrib/seeds$ python3 generate-seeds.py . > ../../src/chainparamseeds.h