From a7f212c4f24edb538fce7f958bc24ce96cd03b5b Mon Sep 17 00:00:00 2001 From: CalDescent Date: Sat, 9 Oct 2021 16:57:19 +0100 Subject: [PATCH] Create a .sha256 file to accompany each bootstrap This can ultimately be validated after download, and can also be used to help coordinate updates on the various bootstrap hosts. --- src/main/java/org/qortal/repository/Bootstrap.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/org/qortal/repository/Bootstrap.java b/src/main/java/org/qortal/repository/Bootstrap.java index ec05812b..3d16dc4c 100644 --- a/src/main/java/org/qortal/repository/Bootstrap.java +++ b/src/main/java/org/qortal/repository/Bootstrap.java @@ -5,6 +5,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.qortal.block.BlockChain; import org.qortal.controller.Controller; +import org.qortal.crypto.Crypto; import org.qortal.data.account.MintingAccountData; import org.qortal.data.block.BlockData; import org.qortal.data.crosschain.TradeBotData; @@ -16,6 +17,7 @@ import org.qortal.utils.NTP; import org.qortal.utils.SevenZ; import java.io.BufferedInputStream; +import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.net.HttpURLConnection; @@ -272,6 +274,11 @@ public class Bootstrap { LOGGER.info("Compressing..."); SevenZ.compress(compressedOutputPath.toString(), outputPath.toFile()); + LOGGER.info("Generating checksum file..."); + String checksum = Crypto.digestHexString(compressedOutputPath.toFile(), 1024*1024); + Path checksumPath = Paths.get(String.format("%s.sha256", compressedOutputPath.toString())); + Files.writeString(checksumPath, checksum, StandardOpenOption.CREATE); + // Return the path to the compressed bootstrap file LOGGER.info("Bootstrap creation complete. Output file: {}", compressedOutputPath.toAbsolutePath().toString()); return compressedOutputPath.toAbsolutePath().toString();