diff --git a/rollup/missing_header_fields/export-headers-toolkit/cmd/dedup.go b/rollup/missing_header_fields/export-headers-toolkit/cmd/dedup.go index e759e877bd8f..68ba381f98cd 100644 --- a/rollup/missing_header_fields/export-headers-toolkit/cmd/dedup.go +++ b/rollup/missing_header_fields/export-headers-toolkit/cmd/dedup.go @@ -2,6 +2,7 @@ package cmd import ( "bufio" + "crypto/sha256" "encoding/binary" "fmt" "io" @@ -41,9 +42,25 @@ The binary layout of the deduplicated file is as follows: seenDifficulty, seenVanity, seenSealLen := runAnalysis(inputFile) runDedup(inputFile, outputFile, seenDifficulty, seenVanity, seenSealLen) + runSHA256(outputFile) }, } +func runSHA256(outputFile string) { + f, err := os.Open(outputFile) + defer f.Close() + if err != nil { + log.Fatalf("Error opening file: %v", err) + } + + h := sha256.New() + if _, err = io.Copy(h, f); err != nil { + log.Fatalf("Error hashing file: %v", err) + } + + fmt.Printf("Deduplicated headers written to %s with sha256 checksum: %x\n", outputFile, h.Sum(nil)) +} + func init() { rootCmd.AddCommand(dedupCmd) @@ -93,15 +110,13 @@ func runDedup(inputFile, outputFile string, seenDifficulty map[uint64]int, seenV defer reader.close() writer := newMissingHeaderFileWriter(outputFile, seenVanity) - writer.close() + defer writer.close() writer.missingHeaderWriter.writeVanities() reader.read(func(header *types.Header) { writer.missingHeaderWriter.write(header) }) - - fmt.Printf("Deduplicated headers written to %s\n", outputFile) } type headerReader struct { diff --git a/rollup/missing_header_fields/export-headers-toolkit/cmd/fetch.go b/rollup/missing_header_fields/export-headers-toolkit/cmd/fetch.go index e799c40cdc45..b9799d12ba29 100644 --- a/rollup/missing_header_fields/export-headers-toolkit/cmd/fetch.go +++ b/rollup/missing_header_fields/export-headers-toolkit/cmd/fetch.go @@ -11,9 +11,10 @@ import ( "sync" "time" - "github.com/scroll-tech/go-ethereum/ethclient" "github.com/spf13/cobra" + "github.com/scroll-tech/go-ethereum/ethclient" + "github.com/scroll-tech/go-ethereum/export-headers-toolkit/types" )