Go-Ethereum

如何使用 Android 客戶端庫連接到私有鏈?

  • January 10, 2017

似乎還沒有太多關於移動乙太坊庫的文件,至少我能找到。

我知道它們仍在開發中,但是有沒有辦法在移動庫中設置 Genesis 文件呢?更具體地說是在 Android 庫中?

(此外,如果有任何有用的移動圖書館文件連結將不勝感激,因為我找不到任何!)

經過一番探勘,我在下面的原始碼中找到了這個/mobile/geth.go

NodeConfig為您創建時Geth.newNode,您可以為您需要的客戶端指定任何配置。在生成 Go to Java 綁定時,gomobile 預設將結構轉換為類並生成通用的 setter 和 getter。因此,NodeConfig可以EthereumGenesis使用NodeConfig.setEthereumGenesis(String str)

具體來說,NodeConfig 的結構在 Go 中是這樣佈局的:

// NodeConfig represents the collection of configuration values to fine tune the Geth
// node embedded into a mobile process. The available values are a subset of the
// entire API provided by go-ethereum to reduce the maintenance surface and dev
// complexity.
type NodeConfig struct {

// Bootstrap nodes used to establish connectivity with the rest of the network.
   BootstrapNodes *Enodes

// MaxPeers is the maximum number of peers that can be connected. If this is
// set to zero, then only the configured static and trusted peers can connect.
   MaxPeers int

// EthereumEnabled specifies whether the node should run the Ethereum protocol.
   EthereumEnabled bool

// EthereumNetworkID is the network identifier used by the Ethereum protocol to
// decide if remote peers should be accepted or not.
   EthereumNetworkID int

// EthereumChainConfig is the default parameters of the blockchain to use. If no
// configuration is specified, it defaults to the main network.
   EthereumChainConfig *ChainConfig

// EthereumGenesis is the genesis JSON to use to seed the blockchain with. An
// empty genesis state is equivalent to using the mainnet's state.
   EthereumGenesis string

// EthereumDatabaseCache is the system memory in MB to allocate for database caching.
// A minimum of 16MB is always reserved.
   EthereumDatabaseCache int

// EthereumNetStats is a netstats connection string to use to report various
// chain, transaction and node stats to a monitoring server.
//
// It has the form "nodename:secret@host:port"
   EthereumNetStats string

// WhisperEnabled specifies whether the node should run the Whisper protocol.
   WhisperEnabled bool
}

引用自:https://ethereum.stackexchange.com/questions/11245