Browse Source

Merge branch 'yuriy0803:master' into master

master
WMYeah 3 years ago committed by GitHub
parent
commit
1fde5bb6cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      README.md
  2. 59
      payouts/unlocker.go
  3. 2
      proxy/miner.go

2
README.md

@ -283,7 +283,7 @@ otherwise you will get errors on start because of JSON comments.**
"name": "main", "name": "main",
// shares or (solo "pplns": 0,) // shares or (solo "pplns": 0,)
"pplns": 9000, "pplns": 9000,
// mordor, classic, ethereum, ropsten or ubiq, callisto, etica, ethereumPow, ethereumFair, expanse // mordor, classic, ethereum, ropsten or ubiq, callisto, etica, ethereumPow, ethereumFair, expanse, octaspace
"network": "classic", "network": "classic",
// etchash, ethash, ubqhash // etchash, ethash, ubqhash
"algo": "etchash", "algo": "etchash",

59
payouts/unlocker.go

@ -51,6 +51,9 @@ var constantinopleBlockReward = big.NewInt(2e+18)
// params for ubqhash // params for ubqhash
var ubiqStartReward = big.NewInt(8e+18) var ubiqStartReward = big.NewInt(8e+18)
// params for Octaspace
var octaspaceStartReward = big.NewInt(650e+16)
// params for expanse // params for expanse
const byzantiumHardForkHeight = 800000 const byzantiumHardForkHeight = 800000
@ -98,6 +101,8 @@ func NewBlockUnlocker(cfg *UnlockerConfig, backend *storage.RedisClient, network
// nothing needs configuring here, simply proceed. // nothing needs configuring here, simply proceed.
} else if network == "ubiq" { } else if network == "ubiq" {
// nothing needs configuring here, simply proceed. // nothing needs configuring here, simply proceed.
} else if network == "octaspace" {
// nothing needs configuring here, simply proceed.
} else { } else {
log.Fatalln("Invalid network set", network) log.Fatalln("Invalid network set", network)
} }
@ -322,6 +327,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 == "octaspace" {
reward = getConstRewardOctaspace(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)
} }
@ -381,6 +392,8 @@ func handleUncle(height int64, uncle *rpc.GetBlockReply, candidate *storage.Bloc
reward = getUncleRewardEthereumpow(new(big.Int).SetInt64(uncleHeight), new(big.Int).SetInt64(height), getConstRewardEthereumpow(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))
} else if cfg.Network == "octaspace" {
reward = getUncleRewardOctaspace(new(big.Int).SetInt64(uncleHeight), new(big.Int).SetInt64(height), getConstRewardOctaspace(height))
} }
candidate.Height = height candidate.Height = height
candidate.UncleHeight = uncleHeight candidate.UncleHeight = uncleHeight
@ -769,6 +782,52 @@ func getConstRewardUbiq(height int64) *big.Int {
return reward return reward
} }
// Octaspace
func getConstRewardOctaspace(height int64) *big.Int {
// Rewards
reward := new(big.Int).Set(octaspaceStartReward)
headerNumber := big.NewInt(height)
if headerNumber.Cmp(big.NewInt(400_000)) > 0 {
reward = big.NewInt(500e+16)
// ArcturusBlock
}
if headerNumber.Cmp(big.NewInt(1_000_000)) > 0 {
reward = big.NewInt(400e+16)
// OldenburgBlock
}
if headerNumber.Cmp(big.NewInt(1_500_000)) > 0 {
reward = big.NewInt(350e+16)
// ZagamiBlock
}
if headerNumber.Cmp(big.NewInt(2_000_000)) > 0 {
reward = big.NewInt(300e+16)
// SpringwaterBlock
}
// PolarisBlock
if headerNumber.Cmp(big.NewInt(2_500_000)) >= 0 {
reward = big.NewInt(280e+16)
}
// MahasimBlock
if headerNumber.Cmp(big.NewInt(3_000_000)) >= 0 {
reward = big.NewInt(230e+16)
}
return reward
}
// Octaspace Uncle rw
func getUncleRewardOctaspace(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 calcBigNumber(reward float64) *big.Int { func calcBigNumber(reward float64) *big.Int {
bigReward := new(big.Float).Mul(big.NewFloat(reward), big.NewFloat(1e+18)) bigReward := new(big.Float).Mul(big.NewFloat(reward), big.NewFloat(1e+18))
bigRewardInt := new(big.Int) bigRewardInt := new(big.Int)

2
proxy/miner.go

@ -28,7 +28,7 @@ func (s *ProxyServer) processShare(login, id, ip string, t *BlockTemplate, param
hasher = etchash.New(&ecip1099FBlockMordor, nil) hasher = etchash.New(&ecip1099FBlockMordor, nil)
} else if s.config.Network == "ubiq" { } else if s.config.Network == "ubiq" {
hasher = etchash.New(nil, &uip1FEpoch) hasher = etchash.New(nil, &uip1FEpoch)
} else if s.config.Network == "ethereum" || s.config.Network == "ropsten" || s.config.Network == "ethereumPow" || s.config.Network == "ethereumFair" || s.config.Network == "callisto" || s.config.Network == "etica" || s.config.Network == "expanse" { } else if s.config.Network == "ethereum" || s.config.Network == "ropsten" || s.config.Network == "ethereumPow" || s.config.Network == "ethereumFair" || s.config.Network == "callisto" || s.config.Network == "etica" || s.config.Network == "expanse" || s.config.Network == "octaspace" {
hasher = etchash.New(nil, nil) hasher = etchash.New(nil, nil)
} else { } else {
// unknown network // unknown network

Loading…
Cancel
Save