package com.m2pool.pool.enums;

import java.math.BigDecimal;

/**
 * @Description 矿池 收益计数器相关常量
 * @Date 2022/5/20 11:15
 * @Author 杜懿
 */
public enum PoolCalParamConfig {

    GRS("grs", BigDecimal.valueOf(Math.pow(2,32)), BigDecimal.valueOf(1440),BigDecimal.valueOf(0.01)),
    MONA("mona", BigDecimal.valueOf(Math.pow(2,32)), BigDecimal.valueOf(960),BigDecimal.valueOf(0.01)),
    DGBS("dgbs", BigDecimal.valueOf(Math.pow(2,32)), BigDecimal.valueOf(1180),BigDecimal.valueOf(0.01)),
    DGBQ("dgbq", BigDecimal.valueOf(Math.pow(2,32)), BigDecimal.valueOf(1180),BigDecimal.valueOf(0.01)),
    DGBO("dgbo", BigDecimal.valueOf(Math.pow(2,32)), BigDecimal.valueOf(1180),BigDecimal.valueOf(0.01)),
    DGB2_ODO("dgb2_odo", BigDecimal.valueOf(Math.pow(2,32)), BigDecimal.valueOf(720),BigDecimal.valueOf(0.01)),
    DGB_QUBIT_A10("dgb_qubit_a10", BigDecimal.valueOf(Math.pow(2,32)), BigDecimal.valueOf(720),BigDecimal.valueOf(0.01)),
    DGB_SKEIN_A10("dgb_skein_a10", BigDecimal.valueOf(Math.pow(2,32)), BigDecimal.valueOf(720),BigDecimal.valueOf(0.01)),
    DGB_ODO_B20("dgb_odo_b20", BigDecimal.valueOf(Math.pow(2,32)), BigDecimal.valueOf(720),BigDecimal.valueOf(0.01)),
    NEXA("nexa", BigDecimal.valueOf(Math.pow(2,32)), BigDecimal.valueOf(720),BigDecimal.valueOf(0.01)),
    RXD("rxd", BigDecimal.valueOf(Math.pow(2,32)), BigDecimal.valueOf(288),BigDecimal.valueOf(0.01)),
    ALPH("alph", BigDecimal.valueOf(Math.pow(2,32)), BigDecimal.valueOf(5400),BigDecimal.valueOf(0.01)),
    ENX("enx", BigDecimal.valueOf(Math.pow(2,32)), BigDecimal.valueOf(86400),BigDecimal.valueOf(0.00)),
    SHA3X("sha3x", BigDecimal.valueOf(1),BigDecimal.valueOf(240) ,BigDecimal.valueOf(0.01)),
    MONERO("monero", BigDecimal.valueOf(1),BigDecimal.valueOf(720) ,BigDecimal.valueOf(0.01));


    /** 币种参数名 */
    private final String coin;

    /** 报块所需哈希次数 难度为1时 */
    private final BigDecimal hashTime;

    /** 每日出块数 s*/
    private final BigDecimal count;

    private final BigDecimal poolFees;

    PoolCalParamConfig(String coin, BigDecimal hashTime, BigDecimal count, BigDecimal poolFees) {
        this.coin = coin;
        this.hashTime = hashTime;
        this.count = count;
        this.poolFees = poolFees;
    }

    public String getCoin() {
        return coin;
    }

    public BigDecimal getHashTime() {
        return hashTime;
    }

    public BigDecimal getCount() {
        return count;
    }

    public BigDecimal getPoolFees() {
        return poolFees;
    }


    /**
     * 根据 coin 名称获取对应的全网每日出块数
     * @param coin 币种名称（如 "grs", "nexa"）
     * @return 对应的全网每日出块数
     */
    public static BigDecimal getCoinCount(String coin) {
        for (PoolCalParamConfig config : PoolCalParamConfig.values()) {
            if (config.getCoin().equalsIgnoreCase(coin)) {
                return config.getCount();
            }
        }
        return BigDecimal.ZERO;
    }
}
