Skip to content

Commit

Permalink
set pbft.miner.address use file path
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangbin authored and ttblack committed Jul 5, 2022
1 parent a4259f0 commit 32402c5
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,24 @@ func MakePasswordList(ctx *cli.Context) []string {
return lines
}

func MakeMinerCoinbaseAddress(ctx *cli.Context) string {
path := ctx.GlobalString(PbftMinerAddress.Name)
if path == "" {
return ""
}
text, err := ioutil.ReadFile(path)
if err != nil {
Fatalf("Failed to read pbft.miner.address file: %v", err)
}
address := strings.TrimRight(string(text), "\r")
address = strings.TrimRight(string(address), "\n")
if !common.IsHexAddress(address) {
panic(fmt.Sprintf("pbft.miner.address is not ethereum format:%s", address))
}

return address
}

// MakeDposPasswordList reads password lines from the file specified by the global --password flag.
func MakeDposPasswordList(ctx *cli.Context) string {
path := ctx.GlobalString(PbftKeystorePassWord.Name)
Expand Down Expand Up @@ -1573,11 +1591,8 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
cfg.PbftKeyStorePassWord = MakeDposPasswordList(ctx)
cfg.PbftIPAddress = ctx.GlobalString(PbftIPAddress.Name)
cfg.PbftDPosPort = uint16(ctx.GlobalUint(PbftDposPort.Name))
cfg.PbftMinerAddress = ctx.GlobalString(PbftMinerAddress.Name)
cfg.PbftMinerAddress = MakeMinerCoinbaseAddress(ctx)
if cfg.PbftMinerAddress != "" {
if !common.IsHexAddress(cfg.PbftMinerAddress) {
panic("pbft.miner.address is not ethereum format")
}
cfg.Miner.Etherbase = common.HexToAddress(cfg.PbftMinerAddress)
}

Expand Down

0 comments on commit 32402c5

Please sign in to comment.