以太坊的区块奖励

基础

const byzantiumHardForkHeight = 4370000
var homesteadReward = math.MustParseBig256("5000000000000000000")
var byzantiumReward = math.MustParseBig256("3000000000000000000")

func getConstReward(height int64) *big.Int {
    if height >= byzantiumHardForkHeight {
        return new(big.Int).Set(byzantiumReward)
    }
    return new(big.Int).Set(homesteadReward)
}

以太坊在4370000高度以前是5 ether,之后是3ether
以上只是基础奖励,下面是具体算法

func getConstReward(height int64) *big.Int {
    if height >= byzantiumHardForkHeight {
        return new(big.Int).Set(byzantiumReward)
    }
    return new(big.Int).Set(homesteadReward)
}

func getRewardForUncle(height int64) *big.Int {
    reward := getConstReward(height)
    return new(big.Int).Div(reward, new(big.Int).SetInt64(32))
}

func getUncleReward(uHeight, height int64) *big.Int {
    reward := getConstReward(height)
    k := height - uHeight
    reward.Mul(big.NewInt(8-k), reward)
    reward.Div(reward, big.NewInt(8))
    return reward
}

func getBlockReward(height uint64) *big.Int {
         reward := getConstReward(height)
        reward += getRewardForUncle(height) * uncleNumber
        reward += u.getExtraRewardForTx(block)
}

上面是使用golang做的算法描述,总结来说
1,区块奖励:基础奖励 + 基础奖励/32 * 包含的叔伯块数 + 交易费
2,叔伯块奖励:(8 - (所在区块高度 - 目标区块高度)) / 8 * 基础奖励

该规则可查阅具体的区块来校验,如 https://etherscan.io/block/4678904

你可能感兴趣的:(以太坊的区块奖励)