Fixed default for foundation wallet address at puppeth.

This commit is contained in:
AnilChinchwale 2018-10-29 14:23:45 +05:30
parent ece1dccd93
commit 77bf4b18e1
2 changed files with 17 additions and 9 deletions

View file

@ -58,10 +58,10 @@ func (w *wizard) makeGenesis() {
}
// Figure out which consensus engine to choose
fmt.Println()
fmt.Println("Which consensus engine to use? (default = XDPos)")
fmt.Println("Which consensus engine to use? (default = XDPoS)")
fmt.Println(" 1. Ethash - proof-of-work")
fmt.Println(" 2. Clique - proof-of-authority")
fmt.Println(" 3. XDPos - proof-of-stake-voting")
fmt.Println(" 2. Clique - proof-of-authority")
fmt.Println(" 3. XDPoS - proof-of-stake-voting")
choice := w.read()
switch {
@ -70,7 +70,7 @@ func (w *wizard) makeGenesis() {
genesis.Config.Ethash = new(params.EthashConfig)
genesis.ExtraData = make([]byte, 32)
case choice == "2":
case choice == "2":
// In the case of clique, configure the consensus parameters
genesis.Difficulty = big.NewInt(1)
genesis.Config.Clique = &params.CliqueConfig{
@ -110,7 +110,7 @@ func (w *wizard) makeGenesis() {
case choice == "" || choice == "3":
genesis.Difficulty = big.NewInt(1)
genesis.Config.XDPoS = &params.XDPosConfig{
genesis.Config.XDPoS = &params.XDPoSConfig{
Period: 15,
Epoch: 30000,
Reward: 0,
@ -161,13 +161,17 @@ func (w *wizard) makeGenesis() {
fmt.Println()
fmt.Println("How many blocks per epoch? (default = 900)")
epochNumber := uint64(w.readDefaultInt(900))
genesis.Config.XDPoS.Epoch = genesis.Config.XDPoS.RewardCheckpoint
genesis.Config.XDPoS.Epoch = epochNumber
genesis.Config.XDPoS.RewardCheckpoint = epochNumber
fmt.Println()
fmt.Println("How many blocks before checkpoint need to prepare new set of masternodes? (default = 450)")
genesis.Config.XDPoS.Gap = uint64(w.readDefaultInt(450))
fmt.Println()
fmt.Println("What is foundation wallet address? (default = 0x0000000000000000000000000000000000000068)")
genesis.Config.XDPoS.FoudationWalletAddr = w.readDefaultAddress(common.HexToAddress("0x0000000000000000000000000000000000000068"))
// Validator Smart Contract Code
pKey, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
addr := crypto.PubkeyToAddress(pKey.PublicKey)

View file

@ -29,8 +29,8 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/consensus/XDPoS"
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/consensus/XDPoS"
"github.com/ethereum/go-ethereum/contracts"
"github.com/ethereum/go-ethereum/contracts/validator/contract"
"github.com/ethereum/go-ethereum/core"
@ -217,7 +217,11 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
}
number := header.Number.Uint64()
rCheckpoint := chain.Config().XDPoS.RewardCheckpoint
if number > 0 && number-rCheckpoint > 0 {
foudationWalletAddr := chain.Config().XDPoS.FoudationWalletAddr
if foudationWalletAddr == (common.Address{}) {
log.Error("Foundation Wallet Address is empty", "error", foudationWalletAddr)
}
if number > 0 && number-rCheckpoint > 0 && foudationWalletAddr != (common.Address{}) {
// Get signers in blockSigner smartcontract.
addr := common.HexToAddress(common.BlockSigners)
chainReward := new(big.Int).Mul(new(big.Int).SetUint64(chain.Config().XDPoS.Reward), new(big.Int).SetUint64(params.Ether))
@ -240,7 +244,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
// Add reward for coin holders.
if len(signers) > 0 {
for signer, calcReward := range rewardSigners {
err := contracts.CalculateRewardForHolders(validator, state, signer, calcReward)
err := contracts.CalculateRewardForHolders(foudationWalletAddr, validator, state, signer, calcReward)
if err != nil {
log.Error("Fail to calculate reward for holders.", "error", err)
}