k8s: support enable/disable mining
This commit is contained in:
parent
4b0846eb1c
commit
8829992187
|
@ -28,7 +28,7 @@ func ExampleK8SBlockchain() {
|
|||
ImageRepository("quay.io/amis/geth"),
|
||||
ImageTag("istanbul_develop"),
|
||||
ServiceType("LoadBalancer"),
|
||||
Mine(),
|
||||
Mine(true),
|
||||
)
|
||||
defer chain.Finalize()
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue