Browse Source

ethereumPow unlocker

unlocker
master
yuriy0803 3 years ago committed by GitHub
parent
commit
8a89e929f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 28
      payouts/unlocker.go

28
payouts/unlocker.go

@ -36,7 +36,9 @@ type UnlockerConfig struct {
const minDepth = 16 const minDepth = 16
// params for ethereumPow // params for ethereumPow
var constReward = math.MustParseBig256("2000000000000000000") // 2 ETHW block Reward const byzantiumHardForkHeightethereumPow = 7280000
var byzantiumEthereumpow = math.MustParseBig256("2000000000000000000")
// Donate 1% from pool fees to developers // Donate 1% from pool fees to developers
const donationFee = 1.0 const donationFee = 1.0
@ -313,7 +315,7 @@ func (u *BlockUnlocker) handleBlock(block *rpc.GetBlockReply, candidate *storage
reward.Add(reward, rewardForUncles) reward.Add(reward, rewardForUncles)
} else if u.config.Network == "ethereumPow" { } else if u.config.Network == "ethereumPow" {
reward := new(big.Int).Set(constReward) reward = getConstRewardEthereumpow(candidate.Height)
// Add reward for including uncles // Add reward for including uncles
uncleReward := new(big.Int).Div(reward, big32) uncleReward := new(big.Int).Div(reward, big32)
rewardForUncles := big.NewInt(0).Mul(uncleReward, big.NewInt(int64(len(block.Uncles)))) rewardForUncles := big.NewInt(0).Mul(uncleReward, big.NewInt(int64(len(block.Uncles))))
@ -364,7 +366,7 @@ func handleUncle(height int64, uncle *rpc.GetBlockReply, candidate *storage.Bloc
} else if cfg.Network == "callisto" { } else if cfg.Network == "callisto" {
reward = getUncleRewardEthereum(new(big.Int).SetInt64(uncleHeight), new(big.Int).SetInt64(height), getConstRewardcallisto(height)) reward = getUncleRewardEthereum(new(big.Int).SetInt64(uncleHeight), new(big.Int).SetInt64(height), getConstRewardcallisto(height))
} else if cfg.Network == "ethereumPow" { } else if cfg.Network == "ethereumPow" {
reward = getUncleRewardEthereumPow(uncleHeight, height) reward = getUncleRewardEthereumpow(new(big.Int).SetInt64(uncleHeight), new(big.Int).SetInt64(height), getConstRewardEthereumpow(height))
} else if cfg.Network == "ethereum" || cfg.Network == "ropsten" || cfg.Network == "ethereumFair" { } else if cfg.Network == "ethereum" || cfg.Network == "ropsten" || cfg.Network == "ethereumFair" {
reward = getUncleRewardEthereum(new(big.Int).SetInt64(uncleHeight), new(big.Int).SetInt64(height), getConstRewardUbiq(height)) reward = getUncleRewardEthereum(new(big.Int).SetInt64(uncleHeight), new(big.Int).SetInt64(height), getConstRewardUbiq(height))
} }
@ -719,6 +721,13 @@ func getConstRewardExpanse(height int64) *big.Int {
return new(big.Int).Set(byzantiumExpanseReward) return new(big.Int).Set(byzantiumExpanseReward)
} }
func getConstRewardEthereumpow(height int64) *big.Int {
if height >= byzantiumHardForkHeight {
return new(big.Int).Set(byzantiumEthereumpow)
}
return new(big.Int).Set(byzantiumEthereumpow)
}
// ubqhash // ubqhash
func getConstRewardUbiq(height int64) *big.Int { func getConstRewardUbiq(height int64) *big.Int {
// Rewards // Rewards
@ -837,9 +846,12 @@ func (u *BlockUnlocker) getExtraRewardForTx(block *rpc.GetBlockReply) (*big.Int,
return amount, nil return amount, nil
} }
func getUncleRewardEthereumPow(uHeight, height int64) *big.Int { func getUncleRewardEthereumpow(uHeight *big.Int, height *big.Int, reward *big.Int) *big.Int {
reward := new(big.Int).Set(constReward) r := new(big.Int)
reward.Mul(big.NewInt(uHeight+8-height), reward) r.Add(uHeight, big8)
reward.Div(reward, big.NewInt(8)) r.Sub(r, height)
return reward r.Mul(r, reward)
r.Div(r, big8)
return r
} }

Loading…
Cancel
Save