use of com.hedera.mirror.importer.downloader.DownloaderProperties in project hedera-mirror-node by hashgraph.
the class MirrorDateRangePropertiesProcessor method newDateRangeFilter.
private DateRangeFilter newDateRangeFilter(StreamType streamType) {
DownloaderProperties downloaderProperties = getDownloaderProperties(streamType);
if (!downloaderProperties.isEnabled()) {
return DateRangeFilter.empty();
}
Instant startDate = mirrorProperties.getStartDate();
Instant endDate = mirrorProperties.getEndDate();
Instant lastFileInstant = findLatest(streamType).map(StreamFile::getConsensusStart).map(nanos -> Instant.ofEpochSecond(0, nanos)).orElse(null);
Instant filterStartDate = lastFileInstant;
if (startDate != null && startDate.compareTo(endDate) > 0) {
throw new InvalidConfigurationException(String.format("Date range constraint violation: " + "startDate (%s) > endDate (%s)", startDate, endDate));
}
if (startDate != null) {
filterStartDate = max(startDate, lastFileInstant);
} else {
if (mirrorProperties.getNetwork() != MirrorProperties.HederaNetwork.DEMO && lastFileInstant == null) {
filterStartDate = STARTUP_TIME;
}
}
DateRangeFilter filter = new DateRangeFilter(filterStartDate, endDate);
log.info("{}: parser will parse items in the range [{}, {}]", downloaderProperties.getStreamType(), filter.getStartAsInstant(), filter.getEndAsInstant());
return filter;
}
Aggregations