Ejemplo n.º 1
0
    public static void DetectNetworkAndChain(string netVersionResponse, string gethChainResponse,
                                             out EthereumNetworkType networkType, out GethChainType 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(gethChainResponse, true, out chainType))
        {
            chainType = GethChainType.Unknown;
        }

        if (chainType == GethChainType.Ethereum)
        {
            chainType = GethChainType.Ethereum;
        }

        if (chainType == GethChainType.Callisto)
        {
            chainType = GethChainType.Callisto;
        }
    }
Ejemplo n.º 2
0
        internal static decimal GetUncleReward(GethChainType chainType, ulong uheight, ulong height)
        {
            var reward = GetBaseBlockReward(chainType, height);

            reward *= uheight + 8 - height;
            reward /= 8m;

            return(reward);
        }
Ejemplo n.º 3
0
        internal static decimal GetBaseBlockReward(GethChainType chainType, ulong height)
        {
            switch (chainType)
            {
            case GethChainType.Ethereum:
                if (height >= EthereumConstants.ConstantinopleHardForkHeight)
                {
                    return(EthereumConstants.ConstantinopleReward);
                }

                if (height >= EthereumConstants.ByzantiumHardForkHeight)
                {
                    return(EthereumConstants.ByzantiumBlockReward);
                }

                return(EthereumConstants.HomesteadBlockReward);

            case GethChainType.Callisto:
                return(CallistoConstants.BaseRewardInitial * (CallistoConstants.TreasuryPercent / 100));

            default:
                throw new Exception("Unable to determine block reward: Unsupported chain type");
            }
        }
Ejemplo n.º 4
0
        internal static decimal GetBaseBlockReward(GethChainType chainType, ulong height)
        {
            switch (chainType)
            {
            case GethChainType.Mainnet:
                if (height >= EthereumConstants.ConstantinopleHardForkHeight)
                {
                    return(EthereumConstants.ConstantinopleReward);
                }

                if (height >= EthereumConstants.ByzantiumHardForkHeight)
                {
                    return(EthereumConstants.ByzantiumBlockReward);
                }

                return(EthereumConstants.HomesteadBlockReward);

            case GethChainType.Ropsten:
                return(EthereumConstants.ByzantiumBlockReward);

            default:
                throw new Exception("Unable to determine block reward: Unsupported chain type");
            }
        }