Browse Source

canxium Network

canxium Network
master
yuriy0803 2 years ago
parent
commit
9e641c48e2
  1. 26
      payouts/unlocker.go
  2. 12
      proxy/miner.go

26
payouts/unlocker.go

@ -35,6 +35,13 @@ type UnlockerConfig struct {
const minDepth = 16
// params for canxium
const HydroForkBlock = 4204800
var CanxiumFoundationRewardPercent = big.NewInt(2)
var PreHydroReward = big.NewInt(1875e14)
var HydroRewardPerHash = big.NewInt(500)
// Universal block reward ethash
const UniversalHardForkHeight = 0
@ -91,7 +98,7 @@ func NewBlockUnlocker(cfg *UnlockerConfig, backend *storage.RedisClient, network
case "ethereum":
cfg.ByzantiumFBlock = big.NewInt(4370000)
cfg.ConstantinopleFBlock = big.NewInt(7280000)
case "ethereumPow", "expanse", "etica", "callisto", "ubiq", "octaspace", "universal":
case "ethereumPow", "expanse", "etica", "callisto", "ubiq", "octaspace", "universal", "canxium":
// Nothing needs configuring here, simply proceed.
case "ethereumFair":
cfg.ByzantiumFBlock = big.NewInt(4370000)
@ -342,6 +349,8 @@ func (u *BlockUnlocker) handleBlock(block *rpc.GetBlockReply, candidate *storage
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 == "canxium" {
reward = getConstRewardCanxium(candidate.Height, candidate.Difficulty)
} else {
log.Fatalln("Invalid network set", u.config.Network)
}
@ -405,6 +414,8 @@ func handleUncle(height int64, uncle *rpc.GetBlockReply, candidate *storage.Bloc
reward = getUncleRewardOctaspace(new(big.Int).SetInt64(uncleHeight), new(big.Int).SetInt64(height), getConstRewardOctaspace(height))
} else if cfg.Network == "universal" {
reward = getUncleRewardUniversal(new(big.Int).SetInt64(uncleHeight), new(big.Int).SetInt64(height), getConstRewardUniversal(height))
} else if cfg.Network == "canxium" {
reward = big.NewInt(0)
}
candidate.Height = height
@ -964,3 +975,16 @@ func getUncleRewardExpanse(uHeight *big.Int, height *big.Int, reward *big.Int) *
return r
}
// Canxium Reward
func getConstRewardCanxium(height int64, difficulty int64) *big.Int {
if height < HydroForkBlock {
return PreHydroReward
}
reward := HydroRewardPerHash.Mul(HydroRewardPerHash, big.NewInt(difficulty))
foundation := new(big.Int).Mul(CanxiumFoundationRewardPercent, reward)
foundation.Div(foundation, big.NewInt(100))
reward.Sub(reward, foundation)
return reward
}

12
proxy/miner.go

@ -22,16 +22,16 @@ var (
func (s *ProxyServer) processShare(login, id, ip string, t *BlockTemplate, params []string, stratum bool) (bool, bool) {
if hasher == nil {
if s.config.Network == "classic" {
switch s.config.Network {
case "classic":
hasher = etchash.New(&ecip1099FBlockClassic, nil)
} else if s.config.Network == "mordor" {
case "mordor":
hasher = etchash.New(&ecip1099FBlockMordor, nil)
} else if s.config.Network == "ubiq" {
case "ubiq":
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" || s.config.Network == "octaspace" || s.config.Network == "universal" {
case "ethereum", "ropsten", "ethereumPow", "ethereumFair", "callisto", "etica", "expanse", "octaspace", "universal", "canxium":
hasher = etchash.New(nil, nil)
} else {
// unknown network
default:
log.Printf("Unknown network configuration %s", s.config.Network)
return false, false
}

Loading…
Cancel
Save