以太坊私有链网络配置

一 环境以及软件版本:

1)VMware Workstation 12 Pro

2)Ubuntu 16.04 desktop

3)以太坊geth go语言客户端(Version: 1.8.2-unstable)

4)go语言版本 1.9.4(geth 需要1.7或以上的版本)

二 如何连接:

Geth会持续尝试在网络上连接到其他节点,直到有了端点为止。节点通过发现协议找到对等端。在发现协议中,节点互相

闲聊发现网络上的其他节点。最开始,geth会使用一系列辅助程序节点,这些辅助程序节点的端点记录在源代码中。

三 检查连接和enode身份:

通过net模块可以查看当前客户端连接的对等端数量以及节点是否在监听。

> net.listening

true

> net.peerCount

0


四 节点

Geth支持一个叫静态节点的特征,如果有特定的端点,它会一直想与静态节点连接,如果断开,静态节点就会再次连接。

可以配置永久性静态节点,在当前节点数据目录下创建static-nodes.json文件,内容如下:

[ "enode://f4642fa65af50cfdea8fa7414a5def7bb7991478b768e296f5e4a54e8b995de102e0ceae2e826f293c481b5325f89be6d207b003382e18a8ecba66fbaf6416c0@33.4.2.1:30303",

"enode://pubkey@ip:port"

]


也可以通过控制台添加

>admin.addPeer("enode://867739a9292f889afc02c5e2badb965886fd85d3a3a76a70d41def32240e85c105f46944d82ac68718e4f57cead2b23b96cf467ef949a4c231b996a368ff1169@[::]:30303?discport=0")

true


如果想要了解对等端点的信息(IP地址,端口号等等)

>admin.addPeer("enode://8fb1cc35aea0211046f480067bd24ae19181eaff507689a0e6d14ddd58b6441331c8c0d5158f6d0da6306da042c0ddb7d94baf578e1c9f82a36056e49b16660d@[::]:30303?discport=0" ... )

true

> admin.peers

[{ caps: ["eth/63"],

id:"8fb1cc35aea0211046f480067bd24ae19181eaff507689a0e6d14ddd58b6441331c8c0d5158f6d0da6306da042c0ddb7d94baf578e1c9f82a36056e49b16660d",

name: "Geth/v1.8.2-unstable-0b814d32/linux-amd64/go1.9.4",

network: {

inbound: false,

localAddress: "[::1]:41010",

remoteAddress: "[::1]:30303",

static: true,

trusted: false },

protocols: {

eth: {

difficulty: 262144,

head: "0xa0e580c6769ac3dd80894b2a256164a76b796839d2eb7f799ef6b9850ea5e82e",

version: 63 } } }]


本地起了两个节点以方便测试:

 //第一个节点

tmpPrivate# /eth/go-ethereum/build/bin/geth --datadir "chain" init genesis.json

/eth/go-ethereum/build/bin/geth --datadir "chain" --nodiscover --networkid 15 --port 30306 console 2>> eth.log

 //第二个节点 

tmpPrivateOne# /eth/go-ethereum/build/bin/geth --datadir "chain" init genesis.json

/eth/go-ethereum/build/bin/geth --datadir "chain" --nodiscover --networkid 15 console 2>> eth.log 

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 本文是对以太坊文档 Ethereum Frontier Guide 和 Ethereum Homestead 的整...
    趁风卷阅读 9,585评论 0 16
  • 一 环境以及软件版本: 1)VMware Workstation 12 Pro 2)Ubuntu 16.04 de...
    张_a1d6阅读 945评论 0 0
  • 新手第一次发文,希望大佬轻喷,谢谢。 当前我使用的系统是Centos7,geth是v1.7.3版本 以太坊搭建私有...
    leo_hero阅读 330评论 0 0
  • 新年的第一天,正好是坚持的第三十天,可喜可贺呀…… 1、你喜欢现在的自己吗? 我喜欢现在不停折腾不放弃的自己;这几...
    萃_柳州阅读 183评论 0 0
  • 浅唱低吟 不现身形 我停了 你禁声 我走了 你又鸣 “啹啹啹” “啹啹,啹啹” “啹,啹啹,啹啹啹” …… 车行缓...
    风言无语阅读 394评论 12 40