mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 09:23:48 +00:00
Modify consensus rewards for Callisto's network
This commit is contained in:
parent
7a045af05b
commit
4b7415a2e1
1 changed files with 22 additions and 5 deletions
|
|
@ -36,6 +36,7 @@ import (
|
||||||
|
|
||||||
// Ethash proof-of-work protocol constants.
|
// Ethash proof-of-work protocol constants.
|
||||||
var (
|
var (
|
||||||
|
callistoBlockReward, _ = new(big.Int).SetString("10000000000000000000", 10) // Block reward in wei for successfully mining a block
|
||||||
frontierBlockReward *big.Int = big.NewInt(5e+18) // Block reward in wei for successfully mining a block
|
frontierBlockReward *big.Int = big.NewInt(5e+18) // Block reward in wei for successfully mining a block
|
||||||
byzantiumBlockReward *big.Int = big.NewInt(3e+18) // Block reward in wei for successfully mining a block upward from Byzantium
|
byzantiumBlockReward *big.Int = big.NewInt(3e+18) // Block reward in wei for successfully mining a block upward from Byzantium
|
||||||
maxUncles = 2 // Maximum number of uncles allowed in a single block
|
maxUncles = 2 // Maximum number of uncles allowed in a single block
|
||||||
|
|
@ -529,12 +530,16 @@ var (
|
||||||
// TODO (karalabe): Move the chain maker into this package and make this private!
|
// TODO (karalabe): Move the chain maker into this package and make this private!
|
||||||
func AccumulateRewards(config *params.ChainConfig, state *state.StateDB, header *types.Header, uncles []*types.Header) {
|
func AccumulateRewards(config *params.ChainConfig, state *state.StateDB, header *types.Header, uncles []*types.Header) {
|
||||||
// Select the correct block reward based on chain progression
|
// Select the correct block reward based on chain progression
|
||||||
blockReward := frontierBlockReward
|
blockReward := callistoBlockReward
|
||||||
if config.IsByzantium(header.Number) {
|
//if config.IsByzantium(header.Number) {
|
||||||
blockReward = byzantiumBlockReward
|
// blockReward = byzantiumBlockReward
|
||||||
}
|
//}
|
||||||
// Accumulate the rewards for the miner and any included uncles
|
treasuryPercent := getTreasuryPercent(header)
|
||||||
reward := new(big.Int).Set(blockReward)
|
reward := new(big.Int).Set(blockReward)
|
||||||
|
treasuryReward := new(big.Int)
|
||||||
|
treasuryReward.Mul(reward, big.NewInt(treasuryPercent))
|
||||||
|
treasuryReward.Div(treasuryReward, big.NewInt(100))
|
||||||
|
// Accumulate the rewards for the miner and any included uncles
|
||||||
r := new(big.Int)
|
r := new(big.Int)
|
||||||
for _, uncle := range uncles {
|
for _, uncle := range uncles {
|
||||||
r.Add(uncle.Number, big8)
|
r.Add(uncle.Number, big8)
|
||||||
|
|
@ -546,5 +551,17 @@ func AccumulateRewards(config *params.ChainConfig, state *state.StateDB, header
|
||||||
r.Div(blockReward, big32)
|
r.Div(blockReward, big32)
|
||||||
reward.Add(reward, r)
|
reward.Add(reward, r)
|
||||||
}
|
}
|
||||||
|
reward.Sub(reward, treasuryReward)
|
||||||
state.AddBalance(header.Coinbase, reward)
|
state.AddBalance(header.Coinbase, reward)
|
||||||
|
state.AddBalance(common.HexToAddress("SET ADDRESS IN SETTINGS"), treasuryReward)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// getTreasuryPercent computes the current block reward's percent will be for
|
||||||
|
// dev subsidy.
|
||||||
|
func getTreasuryPercent(header *types.Header) int64 {
|
||||||
|
factorReduction := new(big.Int).Set(header.Number)
|
||||||
|
factorReduction.Div(factorReduction, big.NewInt(2160000))
|
||||||
|
|
||||||
|
return 10 - (2 * factorReduction.Int64())
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue