Browse Source

update unlocker and miner

ethereumPow, ethereumFair, expanse , etica
master
yuriy0803 3 years ago
parent
commit
131c074a40
  1. 2
      README.md
  2. 57
      payouts/unlocker.go
  3. 4
      proxy/miner.go

2
README.md

@ -131,7 +131,7 @@ otherwise you will get errors on start because of JSON comments.**
"name": "main",
// shares or (solo "pplns": 0,)
"pplns": 9000,
// mordor, classic, ethereum, ropsten or ubiq, callisto, etica
// mordor, classic, ethereum, ropsten or ubiq, callisto, etica, ethereumPow, ethereumFair, expanse
"network": "classic",
// exchange api coingecko
"coin-name":"etc",

57
payouts/unlocker.go

@ -48,6 +48,12 @@ var constantinopleBlockReward = big.NewInt(2e+18)
// params for ubqhash
var ubiqStartReward = big.NewInt(8e+18)
// params for expanse
const byzantiumHardForkHeight = 800000
var homesteadExpanseReward = math.MustParseBig256("8000000000000000000")
var byzantiumExpanseReward = math.MustParseBig256("4000000000000000000")
// misc consts
var big32 = big.NewInt(32)
var big8 = big.NewInt(8)
@ -73,9 +79,19 @@ func NewBlockUnlocker(cfg *UnlockerConfig, backend *storage.RedisClient, network
} else if network == "ethereum" {
cfg.ByzantiumFBlock = big.NewInt(4370000)
cfg.ConstantinopleFBlock = big.NewInt(7280000)
} else if network == "ethereumPow" {
cfg.ByzantiumFBlock = big.NewInt(4370000)
cfg.ConstantinopleFBlock = big.NewInt(7280000)
} else if network == "ethereumFair" {
cfg.ByzantiumFBlock = big.NewInt(4370000)
cfg.ConstantinopleFBlock = big.NewInt(7280000)
} else if network == "ropsten" {
cfg.ByzantiumFBlock = big.NewInt(1700000)
cfg.ConstantinopleFBlock = big.NewInt(4230000)
} else if network == "expanse" {
// nothing needs configuring here, simply proceed.
} else if network == "etica" {
// nothing needs configuring here, simply proceed.
} else if network == "callisto" {
// nothing needs configuring here, simply proceed.
} else if network == "ubiq" {
@ -270,6 +286,20 @@ func (u *BlockUnlocker) handleBlock(block *rpc.GetBlockReply, candidate *storage
rewardForUncles := big.NewInt(0).Mul(uncleReward, big.NewInt(int64(len(block.Uncles))))
reward.Add(reward, rewardForUncles)
} else if u.config.Network == "expanse" {
reward = getConstRewardExpanse(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 if u.config.Network == "etica" {
reward = getConstRewardetica(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 if u.config.Network == "callisto" {
reward = getConstRewardcallisto(candidate.Height)
// Add reward for including uncles
@ -277,7 +307,7 @@ func (u *BlockUnlocker) handleBlock(block *rpc.GetBlockReply, candidate *storage
rewardForUncles := big.NewInt(0).Mul(uncleReward, big.NewInt(int64(len(block.Uncles))))
reward.Add(reward, rewardForUncles)
} else if u.config.Network == "ethereum" || u.config.Network == "ropsten" {
} else if u.config.Network == "ethereum" || u.config.Network == "ropsten" || u.config.Network == "ethereumPow" || u.config.Network == "ethereumFair" {
reward = getConstRewardEthereum(candidate.Height, u.config)
// Add reward for including uncles
uncleReward := new(big.Int).Div(reward, big32)
@ -315,9 +345,13 @@ func handleUncle(height int64, uncle *rpc.GetBlockReply, candidate *storage.Bloc
reward = getUncleReward(new(big.Int).SetInt64(uncleHeight), new(big.Int).SetInt64(height), era, getConstReward(era))
} else if cfg.Network == "ubiq" {
reward = getUncleRewardUbiq(new(big.Int).SetInt64(uncleHeight), new(big.Int).SetInt64(height), getConstRewardUbiq(height))
} else if cfg.Network == "expanse" {
reward = getUncleRewardUbiq(new(big.Int).SetInt64(uncleHeight), new(big.Int).SetInt64(height), getConstRewardExpanse(height))
} else if cfg.Network == "etica" {
reward = getUncleRewardEthereum(new(big.Int).SetInt64(uncleHeight), new(big.Int).SetInt64(height), getConstRewardetica(height))
} else if cfg.Network == "callisto" {
reward = getUncleRewardEthereum(new(big.Int).SetInt64(uncleHeight), new(big.Int).SetInt64(height), getConstRewardcallisto(height))
} else if cfg.Network == "ethereum" || cfg.Network == "ropsten" {
} else if cfg.Network == "ethereum" || cfg.Network == "ropsten" || cfg.Network == "ethereumPow" || cfg.Network == "ethereumFair" {
reward = getUncleRewardEthereum(new(big.Int).SetInt64(uncleHeight), new(big.Int).SetInt64(height), getConstRewardUbiq(height))
}
candidate.Height = height
@ -658,6 +692,14 @@ func getUncleReward(uHeight *big.Int, height *big.Int, era *big.Int, reward *big
return getRewardForUncle(reward)
}
// expanse
func getConstRewardExpanse(height int64) *big.Int {
if height >= byzantiumHardForkHeight {
return new(big.Int).Set(homesteadExpanseReward)
}
return new(big.Int).Set(byzantiumExpanseReward)
}
// ubqhash
func getConstRewardUbiq(height int64) *big.Int {
// Rewards
@ -702,7 +744,14 @@ func getConstRewardcallisto(height int64) *big.Int {
return calcBigNumber(38.88)
}
// ubqhash
// etica
func getConstRewardetica(height int64) *big.Int {
// Rewards)
// etica
return calcBigNumber(2.0)
}
// ubqhash expanse
func getUncleRewardUbiq(uHeight *big.Int, height *big.Int, reward *big.Int) *big.Int {
r := new(big.Int)
@ -735,7 +784,7 @@ func getConstRewardEthereum(height int64, cfg *UnlockerConfig) *big.Int {
return reward
}
// ethash callisto
// ethash callisto etica
func getUncleRewardEthereum(uHeight *big.Int, height *big.Int, reward *big.Int) *big.Int {
r := new(big.Int)
r.Add(uHeight, big8)

4
proxy/miner.go

@ -25,11 +25,9 @@ func (s *ProxyServer) processShare(login, id, ip string, t *BlockTemplate, param
hasher = etchash.New(&ecip1099FBlockClassic, nil)
} else if s.config.Network == "mordor" {
hasher = etchash.New(&ecip1099FBlockMordor, nil)
} else if s.config.Network == "callisto" {
hasher = etchash.New(nil, nil)
} else if s.config.Network == "ubiq" {
hasher = etchash.New(nil, &uip1FEpoch)
} else if s.config.Network == "ethereum" || s.config.Network == "ropsten" {
} 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" {
hasher = etchash.New(nil, nil)
} else {
// unknown network

Loading…
Cancel
Save