参考:构建多节点私链
一、eosio节点:
1.1、修改配置文件:
wallet(keosd) port:8900 (默认)
Nodeos(http-server-address):9800
p2p port:9900
NOTE: 127.0.0.1 与0.0.0.0的区别,其他机器找不到127.0.0.1
# The local IP and port to listen for incoming http connections; set blank to disable. (eosio::http_plugin) http-server-address = 0.0.0.0:9800 # The actual host:port used to listen for incoming p2p connections. (eosio::net_plugin) p2p-listen-endpoint = 0.0.0.0:9900 # The public endpoint of a peer node to connect to. Use multiple p2p-peer-address options as needed to compose a network. (eosio::net_plugin) # p2p-peer-address = p2p-peer-address = 172.20.22.128:9900 producer-name = eosio # Timeout for unlocked wallet in seconds (default 900 (15 minutes)). Wallets will automatically lock after specified number of seconds of inactivity. Activity is defined as any wallet command e.g. list-wallets. (eosio::wallet_plugin) unlock-timeout = 90000 # Plugin(s) to enable, may be specified multiple times # plugin = plugin = eosio::http_plugin plugin = eosio::chain_api_plugin plugin = eosio::net_api_plugin plugin = eosio::wallet_api_plugin plugin = eosio::history_api_plugin
位置:
sec@ll-B85M-DS3H-A:~/rgh/eos_multi/config$ pwd
/home/sec/rgh/eos_multi/config
1.2 创建钱包:
cleos wallet create
1.4 创建密钥对:
cleos create key Private key: 5Jmsawgsp1tQ3GD6JyGCwy1dcvqKZgX6ugMVMdjirx85iv5VyPR Public key: EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4
1.2 创建账户inita:
cleos --url http://localhost:9800 create account eosio inita EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4 EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4
1.3 将eosio和inita的私钥导入钱包(nodeos配置文件 signature-provider =):
//eosio私钥
signature-provider = EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV=KEY:5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
cleos wallet import --private-key
//inita私钥
创建账户的公私钥对
1.3 创建合约
cleos --url http://localhost:9800 set contract eosio /home/sec/rgh/eos_719/eos/build/contracts/eosio.bios
1.4 启动nodeos节点:
sec@ll-B85M-DS3H-A:~/rgh/eos_multi$ pwd
/home/sec/rgh/eos_multi
sec@ll-B85M-DS3H-A:~/rgh/eos_multi$ nodeos --enable-stale-production --data-dir ./data --config-dir ./config --replay-blockchain --delete-all-blocks eosio::chain_plugin
二、inita 节点
2.1 配置文件
signature-provider =
# The local IP and port to listen for incoming http connections; set blank to disable. (eosio::http_plugin)
http-server-address = 0.0.0.0:9800
# The actual host:port used to listen for incoming p2p connections. (eosio::net_plugin)
p2p-listen-endpoint = 0.0.0.0:9900
# The public endpoint of a peer node to connect to. Use multiple p2p-peer-address options as needed to compose a network. (eosio::net_plugin)
# p2p-peer-address =
p2p-peer-address = 172.20.22.137:9900
signature-provider = EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4=KEY:5Jmsawgsp1tQ3GD6JyGCwy1dcvqKZgX6ugMVMdjirx85iv5VyPR
# ID of producer controlled by this node (e.g. inita; may specify multiple times) (eosio::producer_plugin)
producer-name = inita
# Plugin(s) to enable, may be specified multiple times
# plugin =
plugin = eosio::http_plugin
plugin = eosio::chain_api_plugin
plugin = eosio::net_api_plugin
#plugin = eosio::wallet_api_plugin
#plugin = eosio::account_history_api_plugin
2.2 启动inita 节点:
u@u-Inspiron-3847:~/eos2_eos_multi$ pwd
/home/u/eos2_eos_multi
u@u-Inspiron-3847:~/eos2_eos_multi$ nodeos --enable-stale-production --data-dir ./data --config-dir ./config --replay-blockchain --delete-all-blocks eosio::chain_plugin
至此:nodeos 产块,Inita接收块:
三、在nodeos机器向eosio合约推送动作:
sec@ll-B85M-DS3H-A:~$ cleos --url http://localhost:9800 push action eosio setprods "{\"schedule\":[{\"producer_name\":\"inita\",\"block_signing_key\":\"EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4\"},{\"producer_name\":\"eosio\",\"block_signing_key\":\"EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV\"}]}" -p eosio@active executed transaction: b50cbfc8de00f69020ff0fa05e1ae23f2376fb43aecf151169d281dbcfece41b 184 bytes 10155 us # eosio <= eosio::setprods {"schedule":[{"producer_name":"inita","block_signing_key":"EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro... warning: transaction executed locally, but may not be confirmed by the network yet ]
至此:eosio和nodeos节点轮流产块:nodeos节点产块,inita接收;inita 产块,nodeos接收