k8s: support enable/disable mining

This commit is contained in:
Miya Chen 2017-10-17 11:21:43 +08:00
parent 4b0846eb1c
commit 8829992187
3 changed files with 17 additions and 5 deletions

View File

@ -28,7 +28,7 @@ func ExampleK8SBlockchain() {
ImageRepository("quay.io/amis/geth"),
ImageTag("istanbul_develop"),
ServiceType("LoadBalancer"),
Mine(),
Mine(true),
)
defer chain.Finalize()

View File

@ -346,11 +346,23 @@ func (eth *ethereum) AddPeer(address string) error {
}
func (eth *ethereum) StartMining() error {
return nil
client := eth.NewClient()
if client == nil {
return errors.New("failed to retrieve client")
}
defer client.Close()
return client.StartMining(context.Background())
}
func (eth *ethereum) StopMining() error {
return nil
client := eth.NewClient()
if client == nil {
return errors.New("failed to retrieve client")
}
defer client.Close()
return client.StopMining(context.Background())
}
func (eth *ethereum) Accounts() (addrs []common.Address) {

View File

@ -62,9 +62,9 @@ func NetworkID(networkID string) Option {
}
}
func Mine() Option {
func Mine(mine bool) Option {
return func(eth *ethereum) {
eth.args = append(eth.args, "ethereum.mining.enabled=true")
eth.args = append(eth.args, fmt.Sprintf("ethereum.mining.enabled=%v", mine))
}
}