package com.m2pool.lease.constant;

import com.m2pool.common.core.utils.StringUtils;

import java.math.BigDecimal;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 * @Description 币种算法
 * @Date 2025/8/18 16:19
 * @Author yyb
 */
public class Algorithm {
    public static final String GRS_ALGORITHM= "groestl";

    public static final String MONA_ALGORITHM= "Lyra2REv2";

    public static final String NEXA_ALGORITHM= "NexaPow";

    public static final String RXD_ALGORITHM= "Sha512256D";

    public static final String DGBQ_ALGORITHM= "DigiByte(Qubit)";

    public static final String DGBS_ALGORITHM= "DigiByte(Skein)";

    public static final String DGBO_ALGORITHM= "DigiByte(Odocrypt)";

    public static final String MONERO_ALGORITHM= "randomx";

    public static final String ALPH_ALGORITHM= "Blake3";



    public static final String GRS_FULL_NAME= "Groestlcoin";

    public static final String MONA_FULL_NAME= "Monacoin";

    public static final String NEXA_FULL_NAME= "nexa";

    public static final String RXD_FULL_NAME= "Radiant";

    public static final String DGBQ_FULL_NAME= "DigiByte(qubit)";

    public static final String DGBS_FULL_NAME= "DigiByte(skein)";

    public static final String DGBO_FULL_NAME= "DigiByte(odocrypt)";

    public static final String MONERO_FULL_NAME= "monero";

    public static final String ALPH_FULL_NAME = "Alephium";

    private static final Map<String, String> ALGORITHM_MAP;

    private static final Map<String, String> COINFLULLNAME_MAP;


    static {
        HashMap<String, String> map = new HashMap<>();
        map.put("grs", GRS_ALGORITHM);
        map.put("mona", MONA_ALGORITHM);
        map.put("nexa", NEXA_ALGORITHM);
        map.put("rxd", RXD_ALGORITHM);
        map.put("dgbq", DGBQ_ALGORITHM);
        map.put("dgbs", DGBS_ALGORITHM);
        map.put("dgbo", DGBO_ALGORITHM);
        map.put("monero", MONERO_ALGORITHM);
        map.put("alph", ALPH_ALGORITHM);
        ALGORITHM_MAP = Collections.unmodifiableMap(map);
        HashMap<String, String> mapFullName = new HashMap<>();
        mapFullName.put("grs", GRS_FULL_NAME);
        mapFullName.put("mona", MONA_FULL_NAME);
        mapFullName.put("nexa", NEXA_FULL_NAME);
        mapFullName.put("rxd", RXD_FULL_NAME);
        mapFullName.put("dgbq", DGBQ_FULL_NAME);
        mapFullName.put("dgbs", DGBS_FULL_NAME);
        mapFullName.put("dgbo", DGBO_FULL_NAME);
        mapFullName.put("monero", MONERO_FULL_NAME);
        mapFullName.put("alph", ALPH_FULL_NAME);
        COINFLULLNAME_MAP = Collections.unmodifiableMap(mapFullName);
    }

    /**
     * 根据币种名称获取对应的算法
     * @param coinName 币种名称，不区分大小写
     * @return 对应的每日理论出块数，如果未找到则返回 null
     */
    public static String getAlgorithm(String coinName) {
        String algorithm = ALGORITHM_MAP.get(coinName.toLowerCase());
        if (StringUtils.isEmpty(algorithm)){
            return "";
        }
        return algorithm;
    }


    public static String getCoinFullName(String coinName) {
        String algorithm = COINFLULLNAME_MAP.get(coinName.toLowerCase());
        if (StringUtils.isEmpty(algorithm)){
            return "";
        }
        return algorithm;
    }
}
