internal static decimal GetBaseBlockReward(ParityChainType chainType, ulong height) { switch (chainType) { case ParityChainType.Mainnet: if (height >= EthereumConstants.ByzantiumHardForkHeight) { return(EthereumConstants.ByzantiumBlockReward); } return(EthereumConstants.HomesteadBlockReward); case ParityChainType.Classic: { var era = Math.Floor(((double)height + 1) / EthereumClassicConstants.BlockPerEra); return((decimal)Math.Pow((double)EthereumClassicConstants.BasePercent, era) * EthereumClassicConstants.BaseRewardInitial); } case ParityChainType.Expanse: return(EthereumConstants.ExpanseBlockReward); case ParityChainType.Ellaism: return(EthereumConstants.EllaismBlockReward); case ParityChainType.Ropsten: return(EthereumConstants.ByzantiumBlockReward); case ParityChainType.CallistoTestnet: case ParityChainType.Callisto: return(CallistoConstants.BaseRewardInitial * (1.0m - CallistoConstants.TreasuryPercent)); default: throw new Exception("Unable to determine block reward: Unsupported chain type"); } }
internal static decimal GetUncleReward(ParityChainType chainType, ulong uheight, ulong height) { var reward = GetBaseBlockReward(chainType, height); switch (chainType) { case ParityChainType.Classic: reward *= EthereumClassicConstants.UnclePercent; break; default: reward *= uheight + 8 - height; reward /= 8m; break; } return(reward); }
public static void DetectNetworkAndChain(string netVersionResponse, string parityChainResponse, out EthereumNetworkType networkType, out ParityChainType chainType) { // convert network if (int.TryParse(netVersionResponse, out var netWorkTypeInt)) { networkType = (EthereumNetworkType)netWorkTypeInt; if (!Enum.IsDefined(typeof(EthereumNetworkType), networkType)) { networkType = EthereumNetworkType.Unknown; } } else { networkType = EthereumNetworkType.Unknown; } // convert chain if (!Enum.TryParse(parityChainResponse, true, out chainType)) { if (parityChainResponse.ToLower() == "ethereum classic") { chainType = ParityChainType.Classic; } else { chainType = ParityChainType.Unknown; } } if (chainType == ParityChainType.Foundation) { chainType = ParityChainType.Mainnet; } if (chainType == ParityChainType.Joys) { chainType = ParityChainType.Joys; } }