So most of the time, we are running a private eos network on our own machine. And there is only one producer if we just run nodeos. We all know that eos has 21 producers. In this post, I will talk about how to run several producers on your own private network.

Before I start, I have to mention that I refer to this post a lot.

https://bihu.com/article/206780

The idea is that we run different nodes on different ports.

First, we run nodeos as usual. And the producer here is that eosio.

And then we will run the second node. The producer for this one is samtre. So the command here is

1
nodeos -p samtre --plugin eosio::chain_api_plugin --plugin eosio::net_api_plugin --http-server-address 127.0.0.1:8889 --p2p-listen-endpoint 127.0.0.1:9877 --p2p-peer-address 127.0.0.1:9876 --config-dir node2 --data-dir node2 --private-key [\"EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV\",\"5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3\"]

Here, the server address is set to port 8889 since the first one is on 8888. And the p2p listen port is 9877 while the original one is 9876. And the config file and block data are put under the node2 dir.

When the second node starts running, we can find it starts to receive blocks.

And you can use this command to get the node info.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
sam@hero:~$ cleos --wallet-url http://localhost:8888 get info
{
"server_version": "75635168",
"chain_id": "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f",
"head_block_num": 23188,
"last_irreversible_block_num": 23187,
"last_irreversible_block_id": "00005a930c4ee6743045ee82ad15f69e4a5ee44160fef50acb5305bd17b8d119",
"head_block_id": "00005a948f9d2567d4fff114675e8a56bbffcb5cbeb8a1939b5df37369648642",
"head_block_time": "2018-08-01T03:25:50.500",
"head_block_producer": "eosio",
"virtual_block_cpu_limit": 200000000,
"virtual_block_net_limit": 1048576000,
"block_cpu_limit": 199900,
"block_net_limit": 1048576
}

For samtre, it’s on the 8889 port so you need to change that port.

Finally you can change the producer with this command.

1
2
3
sam@hero:~$ cleos push action eosio setprods '{"schedule":[{"producer_name":"samtre","block_signing_key":"EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"}]}' -p eosio
executed transaction: 6c2931277377c8ffb4f05ada4b2aab8e0b80f8a68321a3eb06c4bd2fcfa3f7a3 136 bytes 683 us
# eosio <= eosio::setprods {"schedule":[{"producer_name":"samtre","block_signing_key":"EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtH...

You will find now that samtre is starting to produce blocks!