update m2pool 策略修复
This commit is contained in:
@@ -47,7 +47,39 @@ public class M2poolHashrateStrategy implements HashrateFetchStrategy {
|
||||
LocalDateTime queryEndTime = dto.getEndTime().plusMinutes(30);
|
||||
dto.setEndTime(queryEndTime);
|
||||
}
|
||||
return leaseOrderMiningMapper.getRecently24HourHashrate(list, POOL_NAME);
|
||||
List<RealHashrateInfoDto> recently24HourHashrate = leaseOrderMiningMapper.getRecently24HourHashrate(list, POOL_NAME);
|
||||
List<RealHashrateInfoDto> filteredHashrateList = new ArrayList<>();
|
||||
|
||||
for (PurchasedMachineListDto dto : list) {
|
||||
LocalDateTime startTime = dto.getStartTime();
|
||||
LocalDateTime endTime = dto.getEndTime();
|
||||
|
||||
// 将开始时间向上取整到最近的5分钟
|
||||
LocalDateTime currentQueryTime = roundUpToNext5Minutes(startTime);
|
||||
|
||||
while (currentQueryTime.isBefore(endTime) || currentQueryTime.isEqual(endTime)) {
|
||||
// 在recently24HourHashrate中查找匹配的记录
|
||||
for (RealHashrateInfoDto hashrateDto : recently24HourHashrate) {
|
||||
if (hashrateDto.getDatetime().isEqual(currentQueryTime)) {
|
||||
filteredHashrateList.add(hashrateDto);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 移动到下一个30分钟间隔
|
||||
currentQueryTime = currentQueryTime.plusMinutes(DATA_INTERVAL_MINUTES);
|
||||
}
|
||||
}
|
||||
|
||||
return filteredHashrateList;
|
||||
}
|
||||
|
||||
private LocalDateTime roundUpToNext5Minutes(LocalDateTime dateTime) {
|
||||
int minute = dateTime.getMinute();
|
||||
int remainder = minute % 5;
|
||||
if (remainder == 0) {
|
||||
return dateTime;
|
||||
}
|
||||
return dateTime.plusMinutes(5 - remainder).withSecond(0).withNano(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user