diff --git a/README.md b/README.md index 74dc606..f3682cd 100644 --- a/README.md +++ b/README.md @@ -283,7 +283,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, ethereumPow, ethereumFair, expanse + // mordor, classic, ethereum, ropsten or ubiq, callisto, etica, ethereumPow, ethereumFair, expanse, octaspace "network": "classic", // etchash, ethash, ubqhash "algo": "etchash", diff --git a/payouts/unlocker.go b/payouts/unlocker.go index 4948cae..537faaa 100644 --- a/payouts/unlocker.go +++ b/payouts/unlocker.go @@ -51,6 +51,9 @@ var constantinopleBlockReward = big.NewInt(2e+18) // params for ubqhash var ubiqStartReward = big.NewInt(8e+18) +// params for Octaspace +var octaspaceStartReward = big.NewInt(650e+16) + // params for expanse const byzantiumHardForkHeight = 800000 @@ -98,6 +101,8 @@ func NewBlockUnlocker(cfg *UnlockerConfig, backend *storage.RedisClient, network // nothing needs configuring here, simply proceed. } else if network == "ubiq" { // nothing needs configuring here, simply proceed. + } else if network == "octaspace" { + // nothing needs configuring here, simply proceed. } else { 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) rewardForUncles := big.NewInt(0).Mul(uncleReward, big.NewInt(int64(len(block.Uncles)))) 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 { 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)) } 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)) + } else if cfg.Network == "octaspace" { + reward = getUncleRewardOctaspace(new(big.Int).SetInt64(uncleHeight), new(big.Int).SetInt64(height), getConstRewardOctaspace(height)) } candidate.Height = height candidate.UncleHeight = uncleHeight @@ -769,6 +782,52 @@ func getConstRewardUbiq(height int64) *big.Int { 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 { bigReward := new(big.Float).Mul(big.NewFloat(reward), big.NewFloat(1e+18)) bigRewardInt := new(big.Int) diff --git a/proxy/miner.go b/proxy/miner.go index 8fcf2b6..b89350b 100644 --- a/proxy/miner.go +++ b/proxy/miner.go @@ -28,7 +28,7 @@ func (s *ProxyServer) processShare(login, id, ip string, t *BlockTemplate, param hasher = etchash.New(&ecip1099FBlockMordor, nil) } else if s.config.Network == "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" { + } 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) } else { // unknown network