首页 文章

Geth未能连接到私人网络

提问于
浏览
0

我正在创建一个私人网络(以太坊) . 我写了genesis.json文件(下面的代码),然后我没有错误地初始化它,但是当我尝试连接它时,创建了一个新行(暗示应该指定一个额外的命令) . 当我按回车键时,geth只是连接到主网络 . 如何获得连接到专用网络的geth?

note :您可以立即告诉geth连接到主网络,因为我的链的ID是 15 ,它显示与 1 的连接 .

genesis.json:

{
  "difficulty" : "0x20000",
  "extraData"  : "",
  "gasLimit"   : "0x8000000",
  "alloc": {},
  "config": {
        "chainId": 15,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    }
}

命令行:

Ryan-Cocuzzos-Laptop:BlockDev Ryan$ geth init ./genesis.json --datadir mychaindata
WARN [01-05|12:12:00] No etherbase set and no accounts found as default 
INFO [01-05|12:12:00] Allocated cache and file handles         database=/Users/Ryan/Desktop/BlockDev/mychaindata/geth/chaindata cache=16 handles=16
INFO [01-05|12:12:00] Writing custom genesis block 
INFO [01-05|12:12:00] Successfully wrote genesis state         database=chaindata                                               hash=0613eb…9a64e7
INFO [01-05|12:12:00] Allocated cache and file handles         database=/Users/Ryan/Desktop/BlockDev/mychaindata/geth/lightchaindata cache=16 handles=16
INFO [01-05|12:12:00] Writing custom genesis block 
INFO [01-05|12:12:00] Successfully wrote genesis state         database=lightchaindata                                               hash=0613eb…9a64e7
Ryan-Cocuzzos-Laptop:BlockDev Ryan$ geth --datadir .\mychaindata\
> 
WARN [01-05|12:13:37] No etherbase set and no accounts found as default 
INFO [01-05|12:13:37] Starting peer-to-peer node               instance=Geth/v1.7.3-stable/darwin-amd64/go1.9.2
INFO [01-05|12:13:37] Allocated cache and file handles         database=/Users/Ryan/Desktop/BlockDev/.mychaindata/geth/chaindata cache=128 handles=1024
INFO [01-05|12:13:37] Writing default main-net genesis block 
INFO [01-05|12:13:37] Initialised chain configuration          config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Engine: ethash}"
INFO [01-05|12:13:37] Disk storage enabled for ethash caches   dir=/Users/Ryan/Desktop/BlockDev/.mychaindata/geth/ethash count=3
INFO [01-05|12:13:37] Disk storage enabled for ethash DAGs     dir=/Users/Ryan/.ethash                                   count=2
INFO [01-05|12:13:37] Initialising Ethereum protocol           versions="[63 62]" network=1
INFO [01-05|12:13:37] Loaded most recent local header          number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [01-05|12:13:37] Loaded most recent local full block      number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [01-05|12:13:37] Loaded most recent local fast block      number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [01-05|12:13:37] Regenerated local transaction journal    transactions=0 accounts=0
INFO [01-05|12:13:37] Starting P2P networking

ADDITIONAL INFO: 我正在运行MacOS Sierra(10.12.3)我正在使用终端(2.7.1)

2 回答

  • 0

    你在启动 geth 时错过了 --networkid .

    geth --networkid 15 --datadir mychaindata

  • 1

    您缺少 --networkid 和其他导入参数,如端口等 . 使用以下命令连接到您的网络 .

    geth --networkid 15 --datadir .\mychaindata
    

    geth 的其他参数如下

    geth --networkid <chainId> 
         --mine 
         --datadir <datadir> 
         --nodiscover 
         --rpc --rpcport "8545" 
         --port "30303" 
         --rpccorsdomain "*" 
         --nat "any" 
         --rpcapi eth,web3,personal,net 
         --unlock 0 
         --password <password file> 
         --ipcpath <path to .ipc file>
    

相关问题