0

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

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

创世纪.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 

附加信息: 我正在运行 MacOS Sierra (10.12.3) 我正在使用终端 (2.7.1)

4

2 回答 2

1

--networkid开始时你不见了geth

geth --networkid 15 --datadir mychaindata

于 2018-01-05T20:42:55.500 回答
0

您缺少--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>
于 2018-01-06T19:05:19.580 回答