Skip to content

Commit

Permalink
canxium Network
Browse files Browse the repository at this point in the history
canxium Network
  • Loading branch information
yuriy0803 committed Nov 20, 2023
1 parent f4e7877 commit 9e641c4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
26 changes: 25 additions & 1 deletion payouts/unlocker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 changes: 6 additions & 6 deletions proxy/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 9e641c4

Please sign in to comment.