启动Substrate节点时无法查看Local Node Identity的问题咨询
自定义链节点获取Local Node Identity的方法
从节点数据目录提取密钥生成Identity
当你通过--base-path指定节点存储目录时,节点的密钥会自动保存在该目录的chains/<自定义链ID>/network/secret_ed25519文件中(其中<自定义链ID>可从你的customSpecRaw.json文件的id字段获取)。
执行以下命令即可生成Local Node Identity:
./target/release/node-template key inspect-node-key --file /tmp/node01/chains/<你的链ID>/network/secret_ed25519
手动指定密钥启动节点(提前生成)
- 先生成独立的node-key文件:
./target/release/node-template key generate-node-key --file node01-key.txt
- 修改启动命令,添加
--node-key-file参数指定密钥文件:
./target/release/node-template \ --base-path /tmp/node01 \ --chain ./customSpecRaw.json \ --port 30333 \ --ws-port 9945 \ --rpc-port 9933 \ --telemetry-url "wss://telemetry.polkadot.io/submit/ 0" \ --validator \ --rpc-methods Unsafe \ --name MyNode01 \ --password-interactive \ --node-key-file node01-key.txt
- 启动后日志会直接输出Local Node Identity,也可以用以下命令从文件生成:
./target/release/node-template key inspect-node-key --file node01-key.txt
通过RPC查询运行中节点的Identity
如果节点已经启动运行,可通过RPC接口直接查询:
curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method":"system_localPeerId"}' http://localhost:9933
内容的提问来源于stack exchange,提问作者doordashcon
相关产品推荐
相关产品推荐

