增加同步节点(Full Nodes)对于区块链网络,尤其是基于 PoA(Proof of Authority)Clique 共识机制的私链,具有重要意义。以下是增加同步节点的主要原因及其优势:
genesis.json
)、网络ID和端口等配置可用以 geth,为例:
# 获取网络ID
> admin.nodeInfo.protocols.eth.network
12345
# 获取验证者的 enode地址
> admin.nodeInfo.enode
"enode://<public_key>@<ip>:<port>"
以 geth,为例:
# 创建新的账户
$ geth account new --datadir /path/to/new/datadir
INFO [11-19|01:41:20.353] Maximum peer count ETH=50 total=50
INFO [11-19|01:41:20.354] Smartcard socket not found, disabling err="stat /run/pcscd/pcscd.comm: no such file or directory"
Your new account is locked with a password. Please give a password. Do not forget this password.
Password:
Repeat password:
Your new key was generated
Public address of the key: 0xe23C2c6e7f785e74EB7AAeF96455B78C53adb2E3
Path of the secret key file: /root/.ethereum/keystore/UTC--2024-11-19T01-41-27.442932800Z--e23c2c6e7f785e74eb7aaef96455b78c53adb2e3
- You can share your public address with anyone. Others need it to interact with you.
- You must NEVER share the secret key with anyone! The key controls access to your funds!
- You must BACKUP your key file! Without the key, it's impossible to access account funds!
- You must REMEMBER your password! Without the password, it's impossible to decrypt the key!
# 启动新节点
$ geth --datadir /path/to/new/datadir --networkid 12345 --http --http.addr "0.0.0.0" --http.port 8545 --http.api "eth,net,web3,admin" --http.corsdomain "*" --unlock 0xe23c2c6e7f785e74eb7aaef96455b78c53adb2e3 --password /path/to/new/datadir/password.txt --allow-insecure-unlock --syncmode full --bootnodes "enode://<public_key>@<ip>:<port>"
在 Geth(Go-Ethereum)中,--bootnodes
参数用于指定网络中的引导节点(Bootnodes)。引导节点的主要功能是帮助新加入的节点发现并连接到其他节点,从而快速加入网络。以下是详细说明:
Bootnode 是区块链网络中一个特殊的节点,其主要功能是充当网络的入口点。新节点通过 Bootnode 获取已知的其他节点列表,从而建立与网络的对等连接。
enode
地址。--bootnodes
参数的作用--bootnodes
参数用于告诉 Geth 节点启动时连接的引导节点列表。这些引导节点的作用是:
enode
信息。--bootnodes
的格式为逗号分隔的 enode
地址列表:
--bootnodes enode://<public_key1>@<ip1>:<port1>,enode://<public_key2>@<ip2>:<port2>
重要字段说明:
public_key
:Bootnode 的公钥,用于唯一标识节点。ip
:Bootnode 的 IP 地址或域名。port
:Bootnode 使用的监听端口(通常为 30303
)。私链/测试网络:
在 PoA 或其他私链环境中,Bootnode 常用来引导新节点快速发现其他对等节点。部署私链时,需要:
公链
在公链中,官方或社区会提供一组公开的 Bootnode(例如 Ethereum 主网的 Bootnode)。新节点只需指定这些 Bootnode 地址即可加入网络。
static-nodes.json
的替代:如果网络较小且节点稳定,也可以通过 static-nodes.json
文件直接配置固定的对等节点,而无需依赖 Bootnode。原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。