add block reward to clique config

This commit is contained in:
Tuna 2018-04-10 11:05:53 +07:00
parent 16009f940c
commit a8fb4ed8f3
3 changed files with 10 additions and 2 deletions

View file

@ -66,11 +66,16 @@ func (w *wizard) makeGenesis() {
genesis.Config.Clique = &params.CliqueConfig{ genesis.Config.Clique = &params.CliqueConfig{
Period: 15, Period: 15,
Epoch: 30000, Epoch: 30000,
Reward: 0,
} }
fmt.Println() fmt.Println()
fmt.Println("How many seconds should blocks take? (default = 15)") fmt.Println("How many seconds should blocks take? (default = 15)")
genesis.Config.Clique.Period = uint64(w.readDefaultInt(15)) genesis.Config.Clique.Period = uint64(w.readDefaultInt(15))
fmt.Println()
fmt.Println("How many Ethers should be rewarded to signer? (default = 0)")
genesis.Config.Clique.Reward = uint64(w.readDefaultInt(0))
// We also need the initial list of signers // We also need the initial list of signers
fmt.Println() fmt.Println()
fmt.Println("Which accounts are allowed to seal? (mandatory at least one)") fmt.Println("Which accounts are allowed to seal? (mandatory at least one)")

View file

@ -571,8 +571,10 @@ func (c *Clique) Prepare(chain consensus.ChainReader, header *types.Header) erro
// rewards given, and returns the final block. // rewards given, and returns the final block.
func (c *Clique) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error) { func (c *Clique) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error) {
// set block reward // set block reward
blockReward := big.NewInt(5e+18) // FIXME: unit Ether could be too plump
reward := new(big.Int).Set(blockReward) chainReward := new(big.Int).SetUint64(chain.Config().Clique.Reward * params.Ether)
reward := new(big.Int).Set(chainReward)
state.AddBalance(header.Coinbase, reward) state.AddBalance(header.Coinbase, reward)
// No block rewards in PoA, so the state remains as is and uncles are dropped // No block rewards in PoA, so the state remains as is and uncles are dropped

View file

@ -135,6 +135,7 @@ func (c *EthashConfig) String() string {
type CliqueConfig struct { type CliqueConfig struct {
Period uint64 `json:"period"` // Number of seconds between blocks to enforce Period uint64 `json:"period"` // Number of seconds between blocks to enforce
Epoch uint64 `json:"epoch"` // Epoch length to reset votes and checkpoint Epoch uint64 `json:"epoch"` // Epoch length to reset votes and checkpoint
Reward uint64 `json:"reward"` // Block reward - unit Ether
} }
// String implements the stringer interface, returning the consensus engine details. // String implements the stringer interface, returning the consensus engine details.