Skip to content

Commit c089745

Browse files
committed
fixed more imports and clashes
Signed-off-by: Rocky Thind <harpender.t@swirldslabs.com>
1 parent 8ab3932 commit c089745

File tree

7 files changed

+49
-69
lines changed

7 files changed

+49
-69
lines changed

tools-and-tests/tools/src/main/java/org/hiero/block/tools/BlockStreamTool.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
package org.hiero.block.tools;
33

44
import org.hiero.block.tools.blocks.BlocksCommand;
5-
import org.hiero.block.tools.days.DaysCommand;
5+
import org.hiero.block.tools.days.subcommands.DaysCommand;
66
import org.hiero.block.tools.metadata.MetadataCommand;
77
import org.hiero.block.tools.mirrornode.MirrorNodeCommand;
88
import org.hiero.block.tools.records.RecordsCommand;

tools-and-tests/tools/src/main/java/org/hiero/block/tools/days/download/DownloadDayImplV2.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
// SPDX-License-Identifier: Apache-2.0
2-
package org.hiero.block.tools.commands.days.download;
2+
package org.hiero.block.tools.days.download;
33

4-
import static org.hiero.block.tools.commands.days.download.DownloadConstants.BUCKET_NAME;
5-
import static org.hiero.block.tools.commands.days.download.DownloadConstants.BUCKET_PATH_PREFIX;
6-
import static org.hiero.block.tools.commands.days.listing.DayListingFileReader.loadRecordsFileForDay;
4+
import static org.hiero.block.tools.days.download.DownloadConstants.BUCKET_NAME;
5+
import static org.hiero.block.tools.days.download.DownloadConstants.BUCKET_PATH_PREFIX;
6+
import static org.hiero.block.tools.days.download.DownloadDayUtil.validateBlockHashes;
7+
import static org.hiero.block.tools.days.listing.DayListingFileReader.loadRecordsFileForDay;
78
import static org.hiero.block.tools.records.RecordFileUtils.extractRecordFileTimeStrFromPath;
89
import static org.hiero.block.tools.records.RecordFileUtils.findMostCommonByType;
910
import static org.hiero.block.tools.records.RecordFileUtils.findMostCommonSidecars;
@@ -29,11 +30,11 @@
2930
import java.util.concurrent.TimeUnit;
3031
import java.util.concurrent.atomic.AtomicLong;
3132
import java.util.stream.Collectors;
32-
import org.hiero.block.tools.commands.days.listing.ListingRecordFile;
33-
import org.hiero.block.tools.commands.mirrornode.BlockTimeReader;
34-
import org.hiero.block.tools.commands.mirrornode.DayBlockInfo;
35-
import org.hiero.block.tools.records.InMemoryFile;
36-
import org.hiero.block.tools.records.RecordFileInfo;
33+
34+
import org.hiero.block.tools.days.listing.ListingRecordFile;
35+
import org.hiero.block.tools.mirrornode.BlockTimeReader;
36+
import org.hiero.block.tools.mirrornode.DayBlockInfo;
37+
import org.hiero.block.tools.records.model.unparsed.InMemoryFile;
3738
import org.hiero.block.tools.utils.ConcurrentTarZstdWriter;
3839
import org.hiero.block.tools.utils.Gzip;
3940
import org.hiero.block.tools.utils.Md5Checker;

tools-and-tests/tools/src/main/java/org/hiero/block/tools/days/download/DownloadDayLiveImpl.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// SPDX-License-Identifier: Apache-2.0
2-
package org.hiero.block.tools.commands.days.download;
2+
package org.hiero.block.tools.days.download;
33

4-
import org.hiero.block.tools.commands.days.listing.ListingRecordFile;
5-
import org.hiero.block.tools.commands.mirrornode.BlockTimeReader;
6-
import org.hiero.block.tools.commands.mirrornode.DayBlockInfo;
7-
import org.hiero.block.tools.records.InMemoryFile;
4+
import org.hiero.block.tools.days.listing.ListingRecordFile;
5+
import org.hiero.block.tools.mirrornode.BlockTimeReader;
6+
import org.hiero.block.tools.mirrornode.DayBlockInfo;
7+
import org.hiero.block.tools.records.model.unparsed.InMemoryFile;
88
import org.hiero.block.tools.utils.ConcurrentTarZstdWriter;
99
import org.hiero.block.tools.utils.Gzip;
1010
import org.hiero.block.tools.utils.Md5Checker;
@@ -29,10 +29,10 @@
2929
import java.util.concurrent.atomic.AtomicLong;
3030
import java.util.stream.Collectors;
3131

32-
import static org.hiero.block.tools.commands.days.download.DownloadConstants.BUCKET_NAME;
33-
import static org.hiero.block.tools.commands.days.download.DownloadConstants.BUCKET_PATH_PREFIX;
34-
import static org.hiero.block.tools.commands.days.download.DownloadDayUtil.validateBlockHashes;
35-
import static org.hiero.block.tools.commands.days.listing.DayListingFileReader.loadRecordsFileForDay;
32+
import static org.hiero.block.tools.days.download.DownloadConstants.BUCKET_NAME;
33+
import static org.hiero.block.tools.days.download.DownloadConstants.BUCKET_PATH_PREFIX;
34+
import static org.hiero.block.tools.days.download.DownloadDayUtil.validateBlockHashes;
35+
import static org.hiero.block.tools.days.listing.DayListingFileReader.loadRecordsFileForDay;
3636
import static org.hiero.block.tools.records.RecordFileUtils.extractRecordFileTimeStrFromPath;
3737
import static org.hiero.block.tools.records.RecordFileUtils.findMostCommonByType;
3838
import static org.hiero.block.tools.records.RecordFileUtils.findMostCommonSidecars;
@@ -100,7 +100,7 @@ public BlockDownloadResult(long blockNumber, List<InMemoryFile> files, byte[] ne
100100
* - selects the most common record + sidecar files
101101
* - downloads all required files with MD5 validation and retry
102102
* - ungzips .gz files and computes canonical entry names via {@link #computeNewFilePath}
103-
* - validates block hashes via {@link DownloadDayUtil#validateBlockHashes}
103+
* - validates block hashes via {@link org.hiero.block.tools.commands.days.download.DownloadDayUtil#validateBlockHashes}
104104
*
105105
* On success it returns the in-memory files and the updated previousRecordFileHash
106106
* that should be passed into the next block/day.
Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
// SPDX-License-Identifier: Apache-2.0
2-
package org.hiero.block.tools.commands.days.download;
2+
package org.hiero.block.tools.days.download;
3+
4+
import org.hiero.block.tools.records.model.parsed.ParsedRecordFile;
5+
import org.hiero.block.tools.records.model.unparsed.InMemoryFile;
36

47
import java.util.Arrays;
58
import java.util.HexFormat;
69
import java.util.List;
7-
import org.hiero.block.tools.records.InMemoryFile;
8-
import org.hiero.block.tools.records.RecordFileInfo;
910

1011
public class DownloadDayUtil {
1112

@@ -20,33 +21,33 @@ public class DownloadDayUtil {
2021
* @throws IllegalStateException if any hash validation fails
2122
*/
2223
public static byte[] validateBlockHashes(
23-
final long blockNum,
24-
final List<InMemoryFile> inMemoryFilesForWriting,
25-
final byte[] prevRecordFileHash,
26-
final byte[] blockHashFromMirrorNode) {
24+
final long blockNum,
25+
final List<InMemoryFile> inMemoryFilesForWriting,
26+
final byte[] prevRecordFileHash,
27+
final byte[] blockHashFromMirrorNode) {
2728
final InMemoryFile mostCommonRecordFileInMem = inMemoryFilesForWriting.getFirst();
28-
final RecordFileInfo recordFileInfo = RecordFileInfo.parse(mostCommonRecordFileInMem.data());
29-
byte[] readPreviousBlockHash = recordFileInfo.previousBlockHash().toByteArray();
30-
byte[] computedBlockHash = recordFileInfo.blockHash().toByteArray();
29+
final ParsedRecordFile recordFileInfo = ParsedRecordFile.parse(mostCommonRecordFileInMem);
30+
byte[] readPreviousBlockHash = recordFileInfo.previousBlockHash();
31+
byte[] computedBlockHash = recordFileInfo.blockHash();
3132
if (blockHashFromMirrorNode != null && !Arrays.equals(blockHashFromMirrorNode, computedBlockHash)) {
3233
throw new IllegalStateException(
33-
"Block[" + blockNum + "] hash mismatch with mirror node listing. " + ", Expected: "
34-
+ HexFormat.of().formatHex(blockHashFromMirrorNode).substring(0, 8)
35-
+ ", Found: "
36-
+ HexFormat.of().formatHex(computedBlockHash).substring(0, 8) + "\n"
37-
+ "Context mostCommonRecordFile:"
38-
+ mostCommonRecordFileInMem.path() + " computedHash:"
39-
+ HexFormat.of().formatHex(computedBlockHash).substring(0, 8));
40-
}
41-
if (prevRecordFileHash != null && !Arrays.equals(prevRecordFileHash, readPreviousBlockHash)) {
42-
throw new IllegalStateException("Block[" + blockNum + "] previous block hash mismatch. " + ", Expected: "
43-
+ HexFormat.of().formatHex(prevRecordFileHash).substring(0, 8)
34+
"Block[" + blockNum + "] hash mismatch with mirror node listing. " + ", Expected: "
35+
+ HexFormat.of().formatHex(blockHashFromMirrorNode).substring(0, 8)
4436
+ ", Found: "
45-
+ HexFormat.of().formatHex(readPreviousBlockHash).substring(0, 8) + "\n"
37+
+ HexFormat.of().formatHex(computedBlockHash).substring(0, 8) + "\n"
4638
+ "Context mostCommonRecordFile:"
4739
+ mostCommonRecordFileInMem.path() + " computedHash:"
4840
+ HexFormat.of().formatHex(computedBlockHash).substring(0, 8));
4941
}
42+
if (prevRecordFileHash != null && !Arrays.equals(prevRecordFileHash, readPreviousBlockHash)) {
43+
throw new IllegalStateException("Block[" + blockNum + "] previous block hash mismatch. " + ", Expected: "
44+
+ HexFormat.of().formatHex(prevRecordFileHash).substring(0, 8)
45+
+ ", Found: "
46+
+ HexFormat.of().formatHex(readPreviousBlockHash).substring(0, 8) + "\n"
47+
+ "Context mostCommonRecordFile:"
48+
+ mostCommonRecordFileInMem.path() + " computedHash:"
49+
+ HexFormat.of().formatHex(computedBlockHash).substring(0, 8));
50+
}
5051
return computedBlockHash;
5152
}
5253
}

tools-and-tests/tools/src/main/java/org/hiero/block/tools/days/subcommands/DaysCommand.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
11
// SPDX-License-Identifier: Apache-2.0
2-
package org.hiero.block.tools.days;
2+
package org.hiero.block.tools.days.subcommands;
33

4-
import org.hiero.block.tools.commands.days.subcommands.DownloadLive;
5-
import org.hiero.block.tools.days.subcommands.CleanDayOfBadRecordSets;
6-
import org.hiero.block.tools.days.subcommands.Compress;
7-
import org.hiero.block.tools.days.subcommands.DownloadDay;
8-
import org.hiero.block.tools.days.subcommands.DownloadDays;
9-
import org.hiero.block.tools.days.subcommands.DownloadDaysV2;
10-
import org.hiero.block.tools.days.subcommands.DownloadLive;
11-
import org.hiero.block.tools.days.subcommands.Ls;
12-
import org.hiero.block.tools.days.subcommands.LsDayListing;
13-
import org.hiero.block.tools.days.subcommands.PrintListing;
14-
import org.hiero.block.tools.days.subcommands.SplitJsonToDayFiles;
15-
import org.hiero.block.tools.days.subcommands.UpdateDayListingsCommand;
16-
import org.hiero.block.tools.days.subcommands.Validate;
174
import picocli.CommandLine.Command;
185
import picocli.CommandLine.Model.CommandSpec;
196
import picocli.CommandLine.Spec;

tools-and-tests/tools/src/main/java/org/hiero/block/tools/days/subcommands/DownloadDaysV2.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
package org.hiero.block.tools.days.subcommands;
33

44
import static org.hiero.block.tools.days.download.DownloadConstants.GCP_PROJECT_ID;
5-
import static org.hiero.block.tools.days.download.DownloadDayImplV2.downloadDay;
5+
import static org.hiero.block.tools.days.download.DownloadDayLiveImpl.downloadDay;
66
import static org.hiero.block.tools.mirrornode.DayBlockInfo.loadDayBlockInfoMap;
77

88
import com.google.cloud.storage.Storage;

tools-and-tests/tools/src/main/java/org/hiero/block/tools/days/subcommands/DownloadLive.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@
1414
import java.time.ZonedDateTime;
1515
import java.util.ArrayList;
1616
import java.util.Comparator;
17-
import java.util.HexFormat;
1817
import java.util.List;
1918
import java.util.Map;
2019
import java.util.concurrent.ExecutorService;
2120
import java.util.concurrent.Executors;
22-
import java.util.concurrent.Future;
2321
import java.util.concurrent.TimeUnit;
2422
import java.util.regex.Matcher;
2523
import java.util.regex.Pattern;
@@ -28,22 +26,15 @@
2826
import com.google.cloud.storage.Storage;
2927
import com.google.cloud.storage.StorageOptions;
3028
import org.hiero.block.tools.commands.days.download.DownloadDayLiveImpl;
31-
import org.hiero.block.tools.records.InMemoryFile;
32-
import org.hiero.block.tools.records.RecordFileBlock;
33-
import org.hiero.block.tools.records.RecordFileBlockV6;
34-
import org.hiero.block.tools.commands.days.model.AddressBookRegistry;
3529
import org.hiero.block.tools.commands.mirrornode.BlockInfo;
36-
import org.hiero.block.tools.commands.mirrornode.BlockTimeReader;
37-
import org.hiero.block.tools.commands.mirrornode.DayBlockInfo;
38-
import org.hiero.block.tools.commands.mirrornode.FetchBlockQuery;
3930
import org.hiero.block.tools.commands.mirrornode.MirrorNodeBlockQueryOrder;
31+
import org.hiero.block.tools.days.model.AddressBookRegistry;
32+
import org.hiero.block.tools.records.model.unparsed.InMemoryFile;
4033
import org.hiero.block.tools.utils.gcp.ConcurrentDownloadManagerVirtualThreads;
4134
import picocli.CommandLine;
4235
import picocli.CommandLine.Command;
4336
import picocli.CommandLine.Option;
4437

45-
import static org.hiero.block.tools.commands.days.download.DownloadConstants.GCP_PROJECT_ID;
46-
import static org.hiero.block.tools.commands.mirrornode.DayBlockInfo.loadDayBlockInfoMap;
4738

4839
/**
4940
* CLI implementation for the {@code days download-live} command.
@@ -541,7 +532,7 @@ static final class LiveDownloader {
541532
private final File tmpRoot;
542533
private final int maxConcurrency;
543534
private final Path addressBookPath;
544-
private final AddressBookRegistry addressBookRegistry;
535+
private final org.hiero.block.tools.days.model.AddressBookRegistry addressBookRegistry;
545536
private final ConcurrentDownloadManagerVirtualThreads downloadManager;
546537
// Running previous record-file hash used to validate the block hash chain across files.
547538
private byte[] previousRecordFileHash;

0 commit comments

Comments
 (0)