go-ethereum(geth)源码在eclipse下搭建开发环境

geth环境搭建备忘

一、环境版本:

window10 64位系统,1.8.4 go-ethereum版本

1.jdk:1.8

2.go:1.10

3.eclipse:

Eclipse Java EE IDE for Web Developers.

Version: Oxygen.2 Release (4.7.2)
Build id: 20171218-0600

OS: Windows 8, v.6.2, x86_64 / win32

4.geth:1.8.4

二、安装过程

1.安装jdk、go、eclipse略

  go1.10下载:

  https://pan.baidu.com/s/1h0acPBSDr9ADitLoubcRvA

2.安装eclipse go插件 ,可参考https://studygolang.com/articles/8300

3.安装eclipse三个go执行文件

  需要自己编译一下,如果你也是win10 64位系统,可以直接使用我编译好的,链接:

  https://pan.baidu.com/s/1iSaU0xDwB3yL1TYCECF6HQ

  配置: 

  

   4.安装gcc编译环境,win10 64位下载:

   https://pan.baidu.com/s/1xTMSDiAji3KLzNQ7vNE6JA

  5.新建go工程,将源码复制到工程目录下,目录结构必须准守如下目录:

     

6.编译

  src/github.com/ethereum/go-ethereum/cmd/geth/main.go

 右键run一下,可以看到bin下面生成geth.exe

7.初始化创世文件

  {
    "config": {
        "chainId": 11,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
    "alloc": {
        "0xbdda794a097b41309700fdc5bdba880a7763c738": {
            "balance": "1000"
        }
    },
    "nonce": "0x0000000000000042",
    "difficulty": "0x020000",
    "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "coinbase": "0x0000000000000000000000000000000000000000",
    "timestamp": "0x00",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "extraData": "",
    "gasLimit": "0xffffffff"

}

另存为genesis.json,然后使用刚才编译好的geth.exe执行

 geth init D:/workspace4/geth/chain/chain0/genesis.json --datadir D:/workspace4/geth/chain/chain0

7.启动:

src/github.com/ethereum/go-ethereum/cmd/geth/main.go

在这个go文件右键,填入启动参数

--nodiscover --datadir D:/workspace4/geth/chain/chain0 --maxpeers 3 --identity "private etherum" --rpc --rpccorsdomain "*" --rpcaddr "0.0.0.0" --port "30303" --shh --rpcapi "db,eth,net,web3,personal,shh" --networkid "11"

--networkid "11" 是你创世文件的值



启动完成后使用geth attach ipc:\\.\pipe\geth.ipc启动客户端