我正在使用Geth配置文件(*.toml)来管理我的专用网络节点的配置。命令geth --config=config/.toml
用于在每个堆栈(dev、prod等)上运行节点。
prod堆栈是针对主Ethereum网络运行的,在本例中,toml配置是显而易见的(主要是默认配置)。但是,对于dev堆栈,我需要提供一个在--testnet
模式下运行D2
的配置。
我应该给出哪种toml
配置来运行节点,就好像它是用--testnet
标志运行的一样?
我试着运行geth --testnet dumpconfig
,但唯一的区别实际上是网络id,但它不足以针对Ropsten运行。关于如何在TOML文件中定义testnet配置的指针吗?谢谢。
发布于 2018-02-06 23:43:55
如果您计划建立您自己的专用网络,我相信您最好从头开始,即使用您自己的创世纪文件和节点配置。但这并不是真正的协奏曲。
在放弃之前,我花了相当长的时间尝试config.toml
文件的所有内容。一些参数(如networkId )已成功初始化,而其他参数则未应用(没有返回错误)。我想,尽管经历了很多考验,我还是错过了一些细节。
不过,我可以分享我所学到的,也许你会想出办法的。下面是我的config.toml
文件的示例
[Eth]
NetworkId = 1515
[Node]
DataDir = '/home/jfo/privateNetworks/geth_PoA/node1'
HTTPHost = 'localhost'
HTTPPort = 8501
HTTPModules = ['personal','db','eth','net','web3']
[Node.P2P]
StaticNodes = ["enode://398e0338de829b887e050a1665bcaef2282ad7066054c8e1b8fe580e53e0fa36a8c62c4174b064a30f76ea26629317966a65100952d78e3ef5f6f176910fd322@127.0.0.1:30301"]
ListenAddr = ':30311'
我从来没有能够让我的节点找到我的引导节点,并且我尝试了在p2p/server.go
(link1,link2)中定义的所有可能的参数。也许数据类型[]*discover.Node
是导致问题的原因。
我怎么知道那些领域的?通过向geth源代码致敬。这个命令
~/Downloads/go-ethereum-master$ grep -rwn "type Config struct" --exclude-dir=vendor/
会把你还给你
p2p/server.go:60:type Config struct {
swarm/api/config.go:42:type Config struct {
console/console.go:52:type Config struct {
consensus/ethash/ethash.go:382:type Config struct {
core/vm/interpreter.go:30:type Config struct {
core/vm/runtime/runtime.go:34:type Config struct {
whisper/whisperv5/config.go:19:type Config struct {
whisper/whisperv6/config.go:20:type Config struct {
dashboard/config.go:29:type Config struct {
node/config.go:49:type Config struct {
eth/gasprice/gasprice.go:34:type Config struct {
eth/config.go:73:type Config struct {
eth/gen_config.go:19: type Config struct {
eth/gen_config.go:60: type Config struct {
例如,在cmd/geth/config.go
(链接)中,您会发现
type gethConfig struct {
Eth eth.Config
Shh whisper.Config
Node node.Config
Ethstats ethstatsConfig
Dashboard dashboard.Config
}
从那里您可以跳到eth/config.go
(链接)找到关于[Eth]
参数的信息。
type Config struct {
// The genesis block, which is inserted if the database is empty.
// If nil, the Ethereum main net block is used.
Genesis *core.Genesis `toml:",omitempty"`
// Protocol options
NetworkId uint64 // Network ID to use for selecting peers to connect to
SyncMode downloader.SyncMode
// Light client options
LightServ int `toml:",omitempty"` // Maximum percentage of time allowed for serving LES requests
LightPeers int `toml:",omitempty"` // Maximum number of LES client peers
// Database options
SkipBcVersionCheck bool `toml:"-"`
DatabaseHandles int `toml:"-"`
DatabaseCache int
// Mining-related options
Etherbase common.Address `toml:",omitempty"`
MinerThreads int `toml:",omitempty"`
ExtraData []byte `toml:",omitempty"`
GasPrice *big.Int
// Ethash options
Ethash ethash.Config
// Transaction pool options
TxPool core.TxPoolConfig
// Gas Price Oracle options
GPO gasprice.Config
// Enables tracking of SHA3 preimages in the VM
EnablePreimageRecording bool
// Miscellaneous options
DocRoot string `toml:"-"`
}
在源代码中,也定义了对温带的参数。
https://ethereum.stackexchange.com/questions/38794
复制