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(String coin,Date start, Date end, List<BlockInfoDto> blockPerDays, boolean useAggregated) {
        return useAggregated ? detailedBlockDataV2Strategy.getTotalBlocks(coin,start, end,blockPerDays)
                             : detailedBlockDataV1Strategy.getTotalBlocks(coin,start, end,blockPerDays) ;
    }
}
