diff options
author | zelig <viktor.tron@gmail.com> | 2015-03-27 05:49:22 +0800 |
---|---|---|
committer | zelig <viktor.tron@gmail.com> | 2015-03-27 05:52:22 +0800 |
commit | b375bbee5fa0b04867cdecdc28e66078a2e32280 (patch) | |
tree | 574aecb617218dc7fe9f7d1c0b0a8b32a195f3fa /eth/backend.go | |
parent | b0b0939879b9fb8453ec1c8fa2ceb522e56df3bc (diff) | |
download | dexon-b375bbee5fa0b04867cdecdc28e66078a2e32280.tar dexon-b375bbee5fa0b04867cdecdc28e66078a2e32280.tar.gz dexon-b375bbee5fa0b04867cdecdc28e66078a2e32280.tar.bz2 dexon-b375bbee5fa0b04867cdecdc28e66078a2e32280.tar.lz dexon-b375bbee5fa0b04867cdecdc28e66078a2e32280.tar.xz dexon-b375bbee5fa0b04867cdecdc28e66078a2e32280.tar.zst dexon-b375bbee5fa0b04867cdecdc28e66078a2e32280.zip |
settable etherbase
- etherbase flag for block reward destination
- coinbase => etherbase
- CLI- eth Config -> eth, xeth -> RPC / Miner
- use primary instead of coinbase as the unlock magic wildcard
- accounts: firstAddr/Coinbase -> Primary
Diffstat (limited to 'eth/backend.go')
-rw-r--r-- | eth/backend.go | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/eth/backend.go b/eth/backend.go index c73e76792..fed0da016 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -63,6 +63,7 @@ type Config struct { Shh bool Dial bool + Etherbase string MinerThreads int AccountManager *accounts.Manager @@ -140,6 +141,7 @@ type Ethereum struct { Mining bool DataDir string + etherbase common.Address clientVersion string ethVersionId int netVersionId int @@ -185,6 +187,7 @@ func New(config *Config) (*Ethereum, error) { eventMux: &event.TypeMux{}, accountManager: config.AccountManager, DataDir: config.DataDir, + etherbase: common.HexToAddress(config.Etherbase), clientVersion: config.Name, // TODO should separate from Name ethVersionId: config.ProtocolVersion, netVersionId: config.NetworkId, @@ -297,15 +300,31 @@ func (s *Ethereum) ResetWithGenesisBlock(gb *types.Block) { } func (s *Ethereum) StartMining() error { - cb, err := s.accountManager.Coinbase() + eb, err := s.Etherbase() if err != nil { - servlogger.Errorf("Cannot start mining without coinbase: %v\n", err) - return fmt.Errorf("no coinbase: %v", err) + err = fmt.Errorf("Cannot start mining without etherbase address: %v", err) + servlogger.Errorln(err) + return err + } - s.miner.Start(common.BytesToAddress(cb)) + + s.miner.Start(eb) return nil } +func (s *Ethereum) Etherbase() (eb common.Address, err error) { + eb = s.etherbase + if (eb == common.Address{}) { + var ebbytes []byte + ebbytes, err = s.accountManager.Primary() + eb = common.BytesToAddress(ebbytes) + if (eb == common.Address{}) { + err = fmt.Errorf("no accounts found") + } + } + return +} + func (s *Ethereum) StopMining() { s.miner.Stop() } func (s *Ethereum) IsMining() bool { return s.miner.Mining() } func (s *Ethereum) Miner() *miner.Miner { return s.miner } |