update 全网算力优化,幸运值算法优化
This commit is contained in:
parent
bea674e93c
commit
3565396252
|
@ -0,0 +1,31 @@
|
|||
package com.m2pool.pool.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
@Configuration
|
||||
public class ThreadPoolConfig {
|
||||
|
||||
@Bean(name = "customTaskThreadPool")
|
||||
public ThreadPoolTaskExecutor customTaskThreadPool() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
// 核心线程数
|
||||
executor.setCorePoolSize(5);
|
||||
// 最大线程数
|
||||
executor.setMaxPoolSize(10);
|
||||
// 队列容量
|
||||
executor.setQueueCapacity(50);
|
||||
// 线程空闲时间(秒)
|
||||
executor.setKeepAliveSeconds(30);
|
||||
// 线程名前缀
|
||||
executor.setThreadNamePrefix("custom-task-thread-");
|
||||
// 拒绝策略
|
||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
// 初始化
|
||||
executor.initialize();
|
||||
return executor;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.m2pool.pool.context;
|
||||
|
||||
import com.m2pool.pool.dto.BlockInfoDto;
|
||||
import com.m2pool.pool.dto.BlockTimeAndNumberDto;
|
||||
import com.m2pool.pool.strategy.DetailedBlockDataV1Strategy;
|
||||
import com.m2pool.pool.strategy.DetailedBlockDataV2Strategy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 获取矿池报块数 策略上下文
|
||||
*/
|
||||
@Service
|
||||
public class BlockDataContext {
|
||||
|
||||
@Resource
|
||||
private DetailedBlockDataV1Strategy detailedBlockDataV1Strategy;
|
||||
|
||||
@Resource
|
||||
private DetailedBlockDataV2Strategy detailedBlockDataV2Strategy;
|
||||
|
||||
public BlockTimeAndNumberDto getBlockData(Date start, Date end, List<BlockInfoDto> blockPerDays, boolean useAggregated) {
|
||||
return useAggregated ? detailedBlockDataV2Strategy.getTotalBlocks(start, end,blockPerDays)
|
||||
: detailedBlockDataV1Strategy.getTotalBlocks(start, end,blockPerDays) ;
|
||||
}
|
||||
}
|
|
@ -7,11 +7,14 @@ import com.m2pool.common.core.web.page.TableDataInfo;
|
|||
import com.m2pool.common.security.annotation.RequiresLogin;
|
||||
import com.m2pool.pool.dto.NoticeListDto;
|
||||
import com.m2pool.pool.service.NoticeService;
|
||||
import com.m2pool.pool.vo.*;
|
||||
import com.m2pool.pool.vo.NoticeAddVo;
|
||||
import com.m2pool.pool.vo.NoticeDelVo;
|
||||
import com.m2pool.pool.vo.NoticePageVo;
|
||||
import com.m2pool.pool.vo.NoticeUpdateVo;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -23,7 +26,7 @@ import java.util.List;
|
|||
@RequestMapping("/notice")
|
||||
public class NoticeController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
private NoticeService noticeService;
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package com.m2pool.pool.dto;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @ClassName BlockTimeAndNumberDto
|
||||
* @Description 报块数和时间范围返回对象
|
||||
* @Author yyb
|
||||
* @Date 2025/5/7 11:26
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class BlockTimeAndNumberDto {
|
||||
/** 区块高度 */
|
||||
private int height;
|
||||
|
||||
/** 报块时间 */
|
||||
private BigDecimal dateLength;
|
||||
|
||||
}
|
|
@ -7,19 +7,19 @@ package com.m2pool.pool.enums;
|
|||
*/
|
||||
public enum Pools {
|
||||
|
||||
GRS("grs", "grs", "groestl", "grs_pool_blkstats", "grs_mhs", "grs_pool","grs.svg",0.985),
|
||||
MONA("mona", "mona", "Lyra2REv2", "mona_pool_blkstats", "mona_mhs", "mona_pool","mona.svg",0.985),
|
||||
DGBS("dgbs", "dgb(skein)", "DigiByte(Skein)", "dgbs_pool_blkstats", "dgbs_mhs", "dgbs_pool","dgb.svg",0.985),
|
||||
DGBQ("dgbq", "dgb(qubit)", "DigiByte(Qubit)", "dgbq_pool_blkstats", "dgbq_mhs", "dgbq_pool","dgb.svg",0.985),
|
||||
DGBO("dgbo", "dgb(odocrypt)", "DigiByte(Odocrypt)", "dgbo_pool_blkstats", "dgbo_mhs", "dgbo_pool","dgb.svg",0.985),
|
||||
GRS("grs", "grs", "groestl", "grs_pool_blkstats", "grs_mhs", "grs_pool","grs.svg",0.985,60),
|
||||
MONA("mona", "mona", "Lyra2REv2", "mona_pool_blkstats", "mona_mhs", "mona_pool","mona.svg",0.985,90),
|
||||
DGBS("dgbs", "dgb(skein)", "DigiByte(Skein)", "dgbs_pool_blkstats", "dgbs_mhs", "dgbs_pool","dgb.svg",0.985,0),
|
||||
DGBQ("dgbq", "dgb(qubit)", "DigiByte(Qubit)", "dgbq_pool_blkstats", "dgbq_mhs", "dgbq_pool","dgb.svg",0.985,0),
|
||||
DGBO("dgbo", "dgb(odocrypt)", "DigiByte(Odocrypt)", "dgbo_pool_blkstats", "dgbo_mhs", "dgbo_pool","dgb.svg",0.985,0),
|
||||
//DGB2_ODO("dgb2_odo", "dgb-odocrypt-pool2", "odocrypt", "dgb2_odo_pool_blkstats", "dgb2_odo_miners", "dgb2_odo_pool"),
|
||||
DGB_QUBIT_A10("dgb_qubit_a10", "dgb-qubit-pool2", "qubit", "dgb_qubit_a10_pool_blkstats", "dgb_qubit_a10_miners", "dgb_qubit_a10_pool","dgb.svg",0.985),
|
||||
DGB_SKEIN_A10("dgb_skein_a10", "dgb-skein-pool2", "skein", "dgb_skein_a10_pool_blkstats", "dgb_skein_a10_miners", "dgb_skein_a10_pool","dgb.svg",0.985),
|
||||
DGB_ODO_B20("dgb_odo_b20", "dgb-odoscrypt-pool3", "odocrypt", "dgb_odo_b20_pool_blkstats", "dgb_odo_b20_miners", "dgb_odo_b20_pool","dgb.svg",0.985),
|
||||
NEXA("nexa", "nexa", "NexaPow", "nexa_pool_blkstats", "nexa_mhs", "nexa_pool","nexa.png",0.985),
|
||||
RXD("rxd", "Radiant", "Sha512256D", "rxd_pool_blkstats", "rxd_mhs", "rxd_pool","rxd.png",0.985),
|
||||
ALPH("alph", "Alephium", "Blake3", "alph_pool_blkstats", "alph_mhs", "alph_pool","alph.svg",0.985),
|
||||
ENX("enx", "entropyx", "kHeavyHash", "enx_pool_blkstats", "enx_mhs", "enx_pool","enx.svg",0.985);
|
||||
DGB_QUBIT_A10("dgb_qubit_a10", "dgb-qubit-pool2", "qubit", "dgb_qubit_a10_pool_blkstats", "dgb_qubit_a10_miners", "dgb_qubit_a10_pool","dgb.svg",0.985,15),
|
||||
DGB_SKEIN_A10("dgb_skein_a10", "dgb-skein-pool2", "skein", "dgb_skein_a10_pool_blkstats", "dgb_skein_a10_miners", "dgb_skein_a10_pool","dgb.svg",0.985,15),
|
||||
DGB_ODO_B20("dgb_odo_b20", "dgb-odoscrypt-pool3", "odocrypt", "dgb_odo_b20_pool_blkstats", "dgb_odo_b20_miners", "dgb_odo_b20_pool","dgb.svg",0.985,15),
|
||||
NEXA("nexa", "nexa", "NexaPow", "nexa_pool_blkstats", "nexa_mhs", "nexa_pool","nexa.png",0.985,120),
|
||||
RXD("rxd", "Radiant", "Sha512256D", "rxd_pool_blkstats", "rxd_mhs", "rxd_pool","rxd.png",0.985,300),
|
||||
ALPH("alph", "Alephium", "Blake3", "alph_pool_blkstats", "alph_mhs", "alph_pool","alph.svg",0.985,0),
|
||||
ENX("enx", "entropyx", "kHeavyHash", "enx_pool_blkstats", "enx_mhs", "enx_pool","enx.svg",0.985,0);
|
||||
|
||||
|
||||
/** 币种参数名 */
|
||||
|
@ -39,7 +39,12 @@ public enum Pools {
|
|||
|
||||
private final double fac;
|
||||
|
||||
Pools(String coin, String name, String algorithm, String blkTable, String mhs, String poolTable,String img,double fac) {
|
||||
/**
|
||||
* 阻塞时间
|
||||
*/
|
||||
private final long blockTime;
|
||||
|
||||
Pools(String coin, String name, String algorithm, String blkTable, String mhs, String poolTable, String img, double fac, long blockTime) {
|
||||
this.coin = coin;
|
||||
this.name = name;
|
||||
this.algorithm = algorithm;
|
||||
|
@ -48,8 +53,11 @@ public enum Pools {
|
|||
this.poolTable = poolTable;
|
||||
this.img = img;
|
||||
this.fac = fac;
|
||||
this.blockTime = blockTime;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getCoin() {
|
||||
return coin;
|
||||
}
|
||||
|
@ -101,4 +109,8 @@ public enum Pools {
|
|||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public long getBlockTime() {
|
||||
return blockTime;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,4 +173,29 @@ public interface PoolMapper {
|
|||
//todo 分配数据入库 目的:整合主库分库
|
||||
|
||||
public List<OfflineUserMinerDto> getOfflineList(@Param("table") String table, @Param("date") String date);
|
||||
|
||||
/**
|
||||
* 插入全网报块数
|
||||
* @param tableName
|
||||
* @param height
|
||||
* @return
|
||||
*/
|
||||
public boolean insertNetBlock(@Param("tableName") String tableName, @Param("height") Long height);
|
||||
|
||||
/**
|
||||
* 查询全网的报块数
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
public List<BlockInfoDto> selectNetBlock(@Param("tableName") String tableName);
|
||||
|
||||
|
||||
/**
|
||||
* 查询矿池的有效宝库阿叔
|
||||
* @param reduce 多少天以前
|
||||
* @return
|
||||
*/
|
||||
@DistributionDB
|
||||
public int selectPoolBlock(@Param("reduce")int reduce);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,21 +1,17 @@
|
|||
package com.m2pool.pool.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.m2pool.common.core.text.Convert;
|
||||
import com.m2pool.common.core.utils.DateUtils;
|
||||
import com.m2pool.common.core.utils.OpenApiJwtUtils;
|
||||
import com.m2pool.common.core.utils.StringUtils;
|
||||
import com.m2pool.common.core.web.Result.AjaxResult;
|
||||
import com.m2pool.common.datasource.annotation.UserDB;
|
||||
import com.m2pool.common.redis.service.RedisService;
|
||||
import com.m2pool.common.security.utils.SecurityUtils;
|
||||
import com.m2pool.pool.dto.*;
|
||||
import com.m2pool.pool.entity.BlockInfo;
|
||||
import com.m2pool.pool.entity.OpenApiKey;
|
||||
import com.m2pool.pool.enums.*;
|
||||
import com.m2pool.pool.mapper.PoolMapper;
|
||||
import com.m2pool.pool.mapper.UserAccountMapper;
|
||||
|
@ -26,8 +22,6 @@ import com.m2pool.pool.utils.PowerUnitUtils;
|
|||
import com.m2pool.pool.vo.BalanceListGetVo;
|
||||
import com.m2pool.pool.vo.CoinVo;
|
||||
import com.m2pool.pool.vo.MinerAccountAddVo;
|
||||
|
||||
import com.m2pool.pool.vo.TestVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
@ -86,25 +80,32 @@ public class PoolServiceImpl implements PoolService {
|
|||
//从redis中拿币种当前高度、全网算力、全网难度
|
||||
BlockInfo info = redisService.getCacheObject(pool.getCoin() + "_block");
|
||||
if(StringUtils.isNotNull(info)){
|
||||
//System.out.println("info:"+info);
|
||||
//高度
|
||||
dto.setHeight(info.getHeight());
|
||||
// //System.out.println("info:"+info);
|
||||
// //高度
|
||||
// dto.setHeight(info.getHeight());
|
||||
//
|
||||
// //全网难度
|
||||
// dto.setTotalDifficulty(PowerUnitUtils.difficultyFormat(info.getDifficulty()));
|
||||
// Date now = new Date();
|
||||
// int minute = (now.getMinutes() / 30) * 30;
|
||||
// now.setMinutes( minute);
|
||||
// now.setSeconds(0);
|
||||
// Calendar ca = new GregorianCalendar();
|
||||
// ca.setTime(now);
|
||||
// ca.add(ca.DATE,-1);
|
||||
// String start = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, ca.getTime());
|
||||
// BigDecimal netPower = poolMapper.getAvgNetPower(pool.getCoin(), start);
|
||||
|
||||
//全网难度
|
||||
dto.setTotalDifficulty(PowerUnitUtils.difficultyFormat(info.getDifficulty()));
|
||||
Date now = new Date();
|
||||
int minute = (now.getMinutes() / 30) * 30;
|
||||
now.setMinutes( minute);
|
||||
now.setSeconds(0);
|
||||
Calendar ca = new GregorianCalendar();
|
||||
ca.setTime(now);
|
||||
ca.add(ca.DATE,-1);
|
||||
String start = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, ca.getTime());
|
||||
BigDecimal netPower = poolMapper.getAvgNetPower(pool.getCoin(), start);
|
||||
|
||||
BigDecimal netPower;
|
||||
if(pool.getBlockTime() != 0){
|
||||
netPower = BigDecimal.valueOf(info.getDifficulty().longValue() * 2 ^ 32 / pool.getBlockTime());
|
||||
}else{
|
||||
netPower = info.getPower();
|
||||
}
|
||||
//全网算力 调用转换工具 动态转换为数值+单位
|
||||
dto.setTotalPower(PowerUnitUtils.powerFormat(netPower,pool.getCoin()));
|
||||
|
||||
|
||||
//System.out.println("dto"+dto);
|
||||
}else {
|
||||
System.out.println("未能从节点获取到信息");
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package com.m2pool.pool.strategy;
|
||||
|
||||
import com.m2pool.pool.dto.BlockInfoDto;
|
||||
import com.m2pool.pool.dto.BlockTimeAndNumberDto;
|
||||
import com.m2pool.pool.mapper.PoolMapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 旧版
|
||||
* 用于获取矿池实际报块一段时间内总数
|
||||
* 可能存在无效区块
|
||||
*/
|
||||
@Component
|
||||
public class DetailedBlockDataV1Strategy implements PoolBlockDataStrategy {
|
||||
|
||||
@Resource
|
||||
private PoolMapper poolMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public BlockTimeAndNumberDto getTotalBlocks(Date start, Date end,List<BlockInfoDto> blockPerDays ) {
|
||||
|
||||
if (blockPerDays.isEmpty()){
|
||||
return BlockTimeAndNumberDto.builder().dateLength(BigDecimal.ZERO).height(0).build();
|
||||
}
|
||||
|
||||
long count = blockPerDays.stream()
|
||||
.filter(e -> (e.getDate().before(end)))
|
||||
.filter(e -> (e.getDate().after(start) || e.getDate().equals(start)))
|
||||
.count();
|
||||
|
||||
//每日出块数固定的舍弃
|
||||
// BigDecimal nexaCount = PoolCalParamConfig.NEXA.getCount();
|
||||
long diffInMillis = end.getTime() - start.getTime();
|
||||
BigDecimal dateLength2 = BigDecimal.valueOf(diffInMillis).divide(BigDecimal.valueOf(86400000), 0, RoundingMode.HALF_UP);
|
||||
Date poolStart = blockPerDays.get(blockPerDays.size() - 1).getDate();
|
||||
//天数不足时,以实际天数计算
|
||||
if(poolStart.after(start)){
|
||||
dateLength2 = dateLength2.subtract(BigDecimal.valueOf(poolStart.getTime() - start.getTime()).divide(BigDecimal.valueOf(86400000), 2, BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
return BlockTimeAndNumberDto.builder().dateLength(dateLength2).height((int) count).build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.m2pool.pool.strategy;
|
||||
|
||||
import com.m2pool.pool.dto.BlockInfoDto;
|
||||
import com.m2pool.pool.dto.BlockTimeAndNumberDto;
|
||||
import com.m2pool.pool.mapper.PoolMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* v2版
|
||||
* 用于获取矿池实际报块一段时间内总数
|
||||
* 解决了无效区块数的问题
|
||||
*/
|
||||
@Component
|
||||
public class DetailedBlockDataV2Strategy implements PoolBlockDataStrategy {
|
||||
|
||||
@Autowired
|
||||
private PoolMapper poolMapper;
|
||||
|
||||
@Override
|
||||
public BlockTimeAndNumberDto getTotalBlocks(Date start, Date end, List<BlockInfoDto> blockPerDays) {
|
||||
List<BlockInfoDto> collect = blockPerDays.stream()
|
||||
.filter(e -> (e.getDate().before(end)))
|
||||
.filter(e -> (e.getDate().after(start) || e.getDate().equals(start)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (collect.isEmpty()){
|
||||
return BlockTimeAndNumberDto.builder().dateLength(BigDecimal.ZERO).height(0).build();
|
||||
}
|
||||
if (collect.size() == 1){
|
||||
return BlockTimeAndNumberDto.builder().dateLength(BigDecimal.ZERO).height(collect.get(0).getHeight()).build();
|
||||
}
|
||||
return BlockTimeAndNumberDto.builder()
|
||||
.dateLength(BigDecimal.valueOf(collect.size()))
|
||||
.height(collect.get(collect.size() - 1).getHeight()- collect.get(0).getHeight()).build();
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.m2pool.pool.strategy;
|
||||
|
||||
import com.m2pool.pool.dto.BlockInfoDto;
|
||||
import com.m2pool.pool.dto.BlockTimeAndNumberDto;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 幸运值策略接口 v1 版本
|
||||
* 获取的矿池区块数可能存在无效区块
|
||||
*/
|
||||
public interface PoolBlockDataStrategy {
|
||||
|
||||
/**
|
||||
* 获取矿池区块数 计算幸运值
|
||||
* @param start 查询开始时间
|
||||
* @param end 查询结束时间(当前系统时间)
|
||||
* @return
|
||||
*/
|
||||
BlockTimeAndNumberDto getTotalBlocks(Date start, Date end, List<BlockInfoDto> blockPerDays);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -3,13 +3,15 @@ package com.m2pool.pool.task;
|
|||
import com.m2pool.common.core.utils.DateUtils;
|
||||
import com.m2pool.common.core.utils.StringUtils;
|
||||
import com.m2pool.common.redis.service.RedisService;
|
||||
|
||||
import com.m2pool.pool.entity.BlockInfo;
|
||||
import com.m2pool.pool.mapper.PoolMapper;
|
||||
import com.m2pool.pool.utils.NodeRpc;
|
||||
import com.m2pool.pool.vo.DateValueVo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
|
||||
|
@ -25,6 +27,9 @@ import java.util.Map;
|
|||
@EnableScheduling
|
||||
public class NodeTask {
|
||||
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(NodeTask.class);
|
||||
|
||||
@Autowired
|
||||
private PoolMapper poolMapper;
|
||||
|
||||
|
@ -481,4 +486,42 @@ public class NodeTask {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 全网报块高度入库
|
||||
*/
|
||||
@Scheduled(cron = "0 0 0 * * ?")
|
||||
@Async("customTaskThreadPool")
|
||||
public void insertNetBlock(){
|
||||
insertBlockWithRetry("nexa", "nexa_net_block", 10);
|
||||
insertBlockWithRetry("dgbq", "dgbq_net_block", 10);
|
||||
insertBlockWithRetry("dgbo", "dgbo_net_block", 10);
|
||||
insertBlockWithRetry("dgbs", "dgbs_net_block", 10);
|
||||
insertBlockWithRetry("mona", "mona_net_block", 10);
|
||||
insertBlockWithRetry("rxd", "rxd_net_block", 10);
|
||||
insertBlockWithRetry("grs", "grs_net_block", 10);
|
||||
}
|
||||
|
||||
private void insertBlockWithRetry(String blockName, String tableName, int maxRetries) {
|
||||
int retryCount = 0;
|
||||
while (retryCount < maxRetries) {
|
||||
try {
|
||||
BlockInfo block = NodeRpc.getBlock(blockName);
|
||||
poolMapper.insertNetBlock(tableName, block.getHeight());
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
retryCount++;
|
||||
if (retryCount >= maxRetries) {
|
||||
log.error("插入区块 {} 数据失败,重试 {} 次后仍失败", blockName, maxRetries, e);
|
||||
throw e;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException ie) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,11 +3,9 @@ package com.m2pool.pool.utils;
|
|||
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.A;
|
||||
import com.m2pool.common.core.text.Convert;
|
||||
import com.m2pool.common.core.utils.StringUtils;
|
||||
import com.m2pool.pool.entity.BlockInfo;
|
||||
|
@ -16,7 +14,10 @@ import com.m2pool.pool.enums.NodeConstant;
|
|||
import org.apache.http.HttpHeaders;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description 节点调用
|
||||
|
@ -84,7 +85,7 @@ public class NodeRpc{
|
|||
JSONObject requestBody = new JSONObject();
|
||||
requestBody.put("jsonrpc", "1.0");
|
||||
requestBody.put("id", "testnet");
|
||||
requestBody.put("method", method);
|
||||
requestBody.put("method", method);//getblockcount
|
||||
requestBody.put("params",params);
|
||||
|
||||
try {
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
server:
|
||||
port: 9203
|
||||
compression:
|
||||
enabled: true
|
||||
mime-types: application/json
|
||||
|
||||
spring:
|
||||
#邮箱基本配置
|
||||
mail:
|
||||
# 配置在limit_time内,用户可以发送limit次验证码
|
||||
limit: 2 这个是我额外的配置,结合邮箱服务用的
|
||||
limitTime: 10 这个是我额外的配置
|
||||
#配置smtp服务主机地址
|
||||
# sina smtp.sina.cn
|
||||
# aliyun smtp.aliyun.com
|
||||
# 163 smtp.163.com 端口号465或994
|
||||
host: mail.privateemail.com
|
||||
#发送者邮箱
|
||||
username: support@m2pool.cc
|
||||
#配置密码,注意不是真正的密码,而是刚刚申请到的授权码
|
||||
# password:
|
||||
# password: m2pool2024@!
|
||||
# password: axvm-zfgx-cgcg-qhhu
|
||||
password: m2pool2024@!
|
||||
#端口号
|
||||
port: 587
|
||||
#默认的邮件编码为UTF-8
|
||||
default-encoding: UTF-8
|
||||
#其他参数
|
||||
properties:
|
||||
mail:
|
||||
#配置SSL 加密工厂
|
||||
smtp:
|
||||
ssl:
|
||||
#本地测试,先放开ssl
|
||||
enable: false
|
||||
required: false
|
||||
#开启debug模式,这样邮件发送过程的日志会在控制台打印出来,方便排查错误
|
||||
debug: false
|
||||
socketFactory:
|
||||
class: javax.net.ssl.SSLSocketFactory
|
||||
|
||||
application:
|
||||
# 应用名称
|
||||
name: m2pool-pool
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址 172.16.2.5
|
||||
server-addr: 127.0.0.1:8808
|
||||
namespace: m2_prod
|
||||
group: m2_prod_group
|
||||
# server-addr: 127.0.0.1:8808
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:8808
|
||||
# server-addr: 127.0.0.1:8808
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
namespace: m2_prod
|
||||
group: m2_prod_group
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 2MB
|
||||
max-request-size: 8MB
|
||||
|
||||
myenv:
|
||||
domain: https://www.m2pool.com
|
||||
path: /var/www/html/web
|
||||
img: /img
|
||||
filepath: /home/ubuntu/prod
|
|
@ -0,0 +1,74 @@
|
|||
server:
|
||||
port: 9503
|
||||
compression:
|
||||
enabled: true
|
||||
mime-types: application/json
|
||||
|
||||
spring:
|
||||
#邮箱基本配置
|
||||
mail:
|
||||
# 配置在limit_time内,用户可以发送limit次验证码
|
||||
limit: 2 这个是我额外的配置,结合邮箱服务用的
|
||||
limitTime: 10 这个是我额外的配置
|
||||
#配置smtp服务主机地址
|
||||
# sina smtp.sina.cn
|
||||
# aliyun smtp.aliyun.com
|
||||
# 163 smtp.163.com 端口号465或994
|
||||
host: mail.privateemail.com
|
||||
#发送者邮箱
|
||||
username: support@m2pool.cc
|
||||
#配置密码,注意不是真正的密码,而是刚刚申请到的授权码
|
||||
# password:
|
||||
# password: m2pool2024@!
|
||||
# password: axvm-zfgx-cgcg-qhhu
|
||||
password: m2pool2024@!
|
||||
#端口号
|
||||
port: 587
|
||||
#默认的邮件编码为UTF-8
|
||||
default-encoding: UTF-8
|
||||
#其他参数
|
||||
properties:
|
||||
mail:
|
||||
#配置SSL 加密工厂
|
||||
smtp:
|
||||
ssl:
|
||||
#本地测试,先放开ssl
|
||||
enable: false
|
||||
required: false
|
||||
#开启debug模式,这样邮件发送过程的日志会在控制台打印出来,方便排查错误
|
||||
debug: false
|
||||
socketFactory:
|
||||
class: javax.net.ssl.SSLSocketFactory
|
||||
|
||||
application:
|
||||
# 应用名称
|
||||
name: m2pool-pool
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址 172.16.2.5
|
||||
server-addr: 127.0.0.1:8808
|
||||
namespace: m2_test
|
||||
group: m2_test_group
|
||||
# server-addr: 127.0.0.1:8808
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:8808
|
||||
# server-addr: 127.0.0.1:8808
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
namespace: m2_test
|
||||
group: m2_test_group
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 2MB
|
||||
max-request-size: 8MB
|
||||
|
||||
myenv:
|
||||
domain: https://test.m2pool.com
|
||||
path: /var/www/html/web_test
|
||||
img: /img
|
||||
filepath: /home/ubuntu/web
|
|
@ -1,156 +1,4 @@
|
|||
server:
|
||||
port: 9203
|
||||
compression:
|
||||
enabled: true
|
||||
mime-types: application/json
|
||||
|
||||
spring:
|
||||
#邮箱基本配置
|
||||
mail:
|
||||
# 配置在limit_time内,用户可以发送limit次验证码
|
||||
limit: 2 这个是我额外的配置,结合邮箱服务用的
|
||||
limitTime: 10 这个是我额外的配置
|
||||
#配置smtp服务主机地址
|
||||
# sina smtp.sina.cn
|
||||
# aliyun smtp.aliyun.com
|
||||
# 163 smtp.163.com 端口号465或994
|
||||
host: mail.privateemail.com
|
||||
#发送者邮箱
|
||||
username: support@m2pool.cc
|
||||
#配置密码,注意不是真正的密码,而是刚刚申请到的授权码
|
||||
# password:
|
||||
# password: m2pool2024@!
|
||||
# password: axvm-zfgx-cgcg-qhhu
|
||||
password: m2pool2024@!
|
||||
#端口号
|
||||
port: 587
|
||||
#默认的邮件编码为UTF-8
|
||||
default-encoding: UTF-8
|
||||
#其他参数
|
||||
properties:
|
||||
mail:
|
||||
#配置SSL 加密工厂
|
||||
smtp:
|
||||
ssl:
|
||||
#本地测试,先放开ssl
|
||||
enable: false
|
||||
required: false
|
||||
#开启debug模式,这样邮件发送过程的日志会在控制台打印出来,方便排查错误
|
||||
debug: false
|
||||
socketFactory:
|
||||
class: javax.net.ssl.SSLSocketFactory
|
||||
|
||||
application:
|
||||
# 应用名称
|
||||
name: m2pool-pool
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: prod
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址 172.16.2.5
|
||||
server-addr: 127.0.0.1:8808
|
||||
namespace: m2_prod
|
||||
group: m2_prod_group
|
||||
# server-addr: 127.0.0.1:8808
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:8808
|
||||
# server-addr: 127.0.0.1:8808
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
namespace: m2_prod
|
||||
group: m2_prod_group
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 2MB
|
||||
max-request-size: 8MB
|
||||
|
||||
myenv:
|
||||
domain: https://www.m2pool.com
|
||||
path: /var/www/html/web
|
||||
img: /img
|
||||
filepath: /home/ubuntu/prod
|
||||
|
||||
|
||||
#server:
|
||||
# port: 9503
|
||||
# compression:
|
||||
# enabled: true
|
||||
# mime-types: application/json
|
||||
#
|
||||
#spring:
|
||||
# #邮箱基本配置
|
||||
# mail:
|
||||
# # 配置在limit_time内,用户可以发送limit次验证码
|
||||
# limit: 2 这个是我额外的配置,结合邮箱服务用的
|
||||
# limitTime: 10 这个是我额外的配置
|
||||
# #配置smtp服务主机地址
|
||||
# # sina smtp.sina.cn
|
||||
# # aliyun smtp.aliyun.com
|
||||
# # 163 smtp.163.com 端口号465或994
|
||||
# host: mail.privateemail.com
|
||||
# #发送者邮箱
|
||||
# username: support@m2pool.cc
|
||||
# #配置密码,注意不是真正的密码,而是刚刚申请到的授权码
|
||||
# # password:
|
||||
# # password: m2pool2024@!
|
||||
# # password: axvm-zfgx-cgcg-qhhu
|
||||
# password: m2pool2024@!
|
||||
# #端口号
|
||||
# port: 587
|
||||
# #默认的邮件编码为UTF-8
|
||||
# default-encoding: UTF-8
|
||||
# #其他参数
|
||||
# properties:
|
||||
# mail:
|
||||
# #配置SSL 加密工厂
|
||||
# smtp:
|
||||
# ssl:
|
||||
# #本地测试,先放开ssl
|
||||
# enable: false
|
||||
# required: false
|
||||
# #开启debug模式,这样邮件发送过程的日志会在控制台打印出来,方便排查错误
|
||||
# debug: false
|
||||
# socketFactory:
|
||||
# class: javax.net.ssl.SSLSocketFactory
|
||||
#
|
||||
# application:
|
||||
# # 应用名称
|
||||
# name: m2pool-pool
|
||||
# profiles:
|
||||
# # 环境配置
|
||||
# active: test
|
||||
# cloud:
|
||||
# nacos:
|
||||
# discovery:
|
||||
# # 服务注册地址 172.16.2.5
|
||||
# server-addr: 127.0.0.1:8808
|
||||
# namespace: m2_test
|
||||
# group: m2_test_group
|
||||
## server-addr: 127.0.0.1:8808
|
||||
# config:
|
||||
# # 配置中心地址
|
||||
# server-addr: 127.0.0.1:8808
|
||||
## server-addr: 127.0.0.1:8808
|
||||
# # 配置文件格式
|
||||
# file-extension: yml
|
||||
# # 共享配置
|
||||
# shared-configs:
|
||||
# - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
# namespace: m2_test
|
||||
# group: m2_test_group
|
||||
# servlet:
|
||||
# multipart:
|
||||
# max-file-size: 2MB
|
||||
# max-request-size: 8MB
|
||||
#
|
||||
#myenv:
|
||||
# domain: https://test.m2pool.com
|
||||
# path: /var/www/html/web_test
|
||||
# img: /img
|
||||
# filepath: /home/ubuntu/web
|
||||
active: test
|
|
@ -585,6 +585,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
order by `date`
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="batchInsertMhsDataToDB" statementType="STATEMENT">
|
||||
insert into ${table}(
|
||||
`date`,
|
||||
|
@ -881,6 +882,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</insert>
|
||||
|
||||
|
||||
<insert id="insertNetBlock">
|
||||
insert into #{tableName} (`date`,`height`) values(#{date},#{height}) ON DUPLICATE KEY UPDATE `height` = VALUES(`height`)
|
||||
</insert>
|
||||
<select id="selectNetBlock" resultType="com.m2pool.pool.dto.BlockInfoDto">
|
||||
SELECT `date`,height FROM #{tableName} WHERE `date` >= DATE_SUB(CURDATE(),INTERVAL 90 DAY) ORDER BY `date` DESC
|
||||
</select>
|
||||
<select id="selectPoolBlock" resultType="java.lang.Integer">
|
||||
SELECT count(*) FROM nexa_blkreportprofitv2 WHERE `date` >= DATE_SUB(CURDATE(),INTERVAL #{reduce} DAY)
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue