|
|
|
@ -35,9 +35,9 @@ type UnlockerConfig struct { |
|
|
|
|
|
|
|
|
|
|
|
const minDepth = 16 |
|
|
|
const minDepth = 16 |
|
|
|
|
|
|
|
|
|
|
|
// Donate 1% from pool fees to developers
|
|
|
|
// Universal block reward ethash
|
|
|
|
const donationFee = 1.0 |
|
|
|
var UniversalBlockReward = math.MustParseBig256("2000000000000000000") // 2.00
|
|
|
|
const donationAccount = "0xd97e0075Abe7dC9e12805345336340649b8658Df" |
|
|
|
var UniversalUncleReward = math.MustParseBig256("1750000000000000000") // 1.75
|
|
|
|
|
|
|
|
|
|
|
|
// params for etchash
|
|
|
|
// params for etchash
|
|
|
|
var homesteadReward = math.MustParseBig256("5000000000000000000") |
|
|
|
var homesteadReward = math.MustParseBig256("5000000000000000000") |
|
|
|
@ -65,6 +65,10 @@ var big32 = big.NewInt(32) |
|
|
|
var big8 = big.NewInt(8) |
|
|
|
var big8 = big.NewInt(8) |
|
|
|
var big2 = big.NewInt(2) |
|
|
|
var big2 = big.NewInt(2) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Donate 1% from pool fees to developers
|
|
|
|
|
|
|
|
const donationFee = 1.0 |
|
|
|
|
|
|
|
const donationAccount = "0xd97e0075Abe7dC9e12805345336340649b8658Df" |
|
|
|
|
|
|
|
|
|
|
|
type BlockUnlocker struct { |
|
|
|
type BlockUnlocker struct { |
|
|
|
config *UnlockerConfig |
|
|
|
config *UnlockerConfig |
|
|
|
backend *storage.RedisClient |
|
|
|
backend *storage.RedisClient |
|
|
|
@ -103,6 +107,8 @@ func NewBlockUnlocker(cfg *UnlockerConfig, backend *storage.RedisClient, network |
|
|
|
// nothing needs configuring here, simply proceed.
|
|
|
|
// nothing needs configuring here, simply proceed.
|
|
|
|
} else if network == "octaspace" { |
|
|
|
} else if network == "octaspace" { |
|
|
|
// nothing needs configuring here, simply proceed.
|
|
|
|
// nothing needs configuring here, simply proceed.
|
|
|
|
|
|
|
|
} else if network == "universal" { |
|
|
|
|
|
|
|
// nothing needs configuring here, simply proceed.
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
log.Fatalln("Invalid network set", network) |
|
|
|
log.Fatalln("Invalid network set", network) |
|
|
|
} |
|
|
|
} |
|
|
|
@ -333,6 +339,12 @@ func (u *BlockUnlocker) handleBlock(block *rpc.GetBlockReply, candidate *storage |
|
|
|
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)))) |
|
|
|
reward.Add(reward, rewardForUncles) |
|
|
|
reward.Add(reward, rewardForUncles) |
|
|
|
|
|
|
|
} else if u.config.Network == "universal" { |
|
|
|
|
|
|
|
reward = getConstRewardUniversal(candidate.Height) |
|
|
|
|
|
|
|
// Add reward for including uncles
|
|
|
|
|
|
|
|
uncleReward := new(big.Int).Div(reward, big32) |
|
|
|
|
|
|
|
rewardForUncles := big.NewInt(0).Mul(uncleReward, big.NewInt(int64(len(block.Uncles)))) |
|
|
|
|
|
|
|
reward.Add(reward, rewardForUncles) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
log.Fatalln("Invalid network set", u.config.Network) |
|
|
|
log.Fatalln("Invalid network set", u.config.Network) |
|
|
|
} |
|
|
|
} |
|
|
|
@ -394,7 +406,10 @@ func handleUncle(height int64, uncle *rpc.GetBlockReply, candidate *storage.Bloc |
|
|
|
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)) |
|
|
|
} else if cfg.Network == "octaspace" { |
|
|
|
} else if cfg.Network == "octaspace" { |
|
|
|
reward = getUncleRewardOctaspace(new(big.Int).SetInt64(uncleHeight), new(big.Int).SetInt64(height), getConstRewardOctaspace(height)) |
|
|
|
reward = getUncleRewardOctaspace(new(big.Int).SetInt64(uncleHeight), new(big.Int).SetInt64(height), getConstRewardOctaspace(height)) |
|
|
|
|
|
|
|
} else if cfg.Network == "universal" { |
|
|
|
|
|
|
|
reward = getUncleRewardUniversal(uncleHeight, candidate.Height) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
candidate.Height = height |
|
|
|
candidate.Height = height |
|
|
|
candidate.UncleHeight = uncleHeight |
|
|
|
candidate.UncleHeight = uncleHeight |
|
|
|
candidate.Orphan = false |
|
|
|
candidate.Orphan = false |
|
|
|
@ -746,17 +761,6 @@ func getConstRewardExpanse(height int64) *big.Int { |
|
|
|
return new(big.Int).Set(homesteadExpanseReward) |
|
|
|
return new(big.Int).Set(homesteadExpanseReward) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// expanse Uncle rw
|
|
|
|
|
|
|
|
func getUncleRewardExpanse(uHeight *big.Int, height *big.Int, reward *big.Int) *big.Int { |
|
|
|
|
|
|
|
r := new(big.Int) |
|
|
|
|
|
|
|
r.Add(uHeight, big8) |
|
|
|
|
|
|
|
r.Sub(r, height) |
|
|
|
|
|
|
|
r.Mul(r, reward) |
|
|
|
|
|
|
|
r.Div(r, big8) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return r |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func getConstRewardEthereumpow(height int64) *big.Int { |
|
|
|
func getConstRewardEthereumpow(height int64) *big.Int { |
|
|
|
// Rewards)
|
|
|
|
// Rewards)
|
|
|
|
// EthereumPow
|
|
|
|
// EthereumPow
|
|
|
|
@ -937,3 +941,25 @@ func getUncleRewardEthereumpow(uHeight *big.Int, height *big.Int, reward *big.In |
|
|
|
|
|
|
|
|
|
|
|
return r |
|
|
|
return r |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// expanse Universal
|
|
|
|
|
|
|
|
func getConstRewardUniversal(height int64) *big.Int { |
|
|
|
|
|
|
|
if big.NewInt(height).Cmp(UniversalBlockReward) >= 0 { |
|
|
|
|
|
|
|
return new(big.Int).Set(UniversalBlockReward) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return new(big.Int).Set(UniversalBlockReward) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
func getUncleRewardUniversal(uHeight, height int64) *big.Int { |
|
|
|
|
|
|
|
return new(big.Int).Set(UniversalUncleReward) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// expanse Uncle rw
|
|
|
|
|
|
|
|
func getUncleRewardExpanse(uHeight *big.Int, height *big.Int, reward *big.Int) *big.Int { |
|
|
|
|
|
|
|
r := new(big.Int) |
|
|
|
|
|
|
|
r.Add(uHeight, big8) |
|
|
|
|
|
|
|
r.Sub(r, height) |
|
|
|
|
|
|
|
r.Mul(r, reward) |
|
|
|
|
|
|
|
r.Div(r, big8) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return r |
|
|
|
|
|
|
|
} |
|
|
|
|