@@ -2,6 +2,7 @@ package cmd
2
2
3
3
import (
4
4
"bufio"
5
+ "crypto/sha256"
5
6
"encoding/binary"
6
7
"fmt"
7
8
"io"
@@ -41,9 +42,25 @@ The binary layout of the deduplicated file is as follows:
41
42
42
43
seenDifficulty , seenVanity , seenSealLen := runAnalysis (inputFile )
43
44
runDedup (inputFile , outputFile , seenDifficulty , seenVanity , seenSealLen )
45
+ runSHA256 (outputFile )
44
46
},
45
47
}
46
48
49
+ func runSHA256 (outputFile string ) {
50
+ f , err := os .Open (outputFile )
51
+ defer f .Close ()
52
+ if err != nil {
53
+ log .Fatalf ("Error opening file: %v" , err )
54
+ }
55
+
56
+ h := sha256 .New ()
57
+ if _ , err = io .Copy (h , f ); err != nil {
58
+ log .Fatalf ("Error hashing file: %v" , err )
59
+ }
60
+
61
+ fmt .Printf ("Deduplicated headers written to %s with sha256 checksum: %x\n " , outputFile , h .Sum (nil ))
62
+ }
63
+
47
64
func init () {
48
65
rootCmd .AddCommand (dedupCmd )
49
66
@@ -93,15 +110,13 @@ func runDedup(inputFile, outputFile string, seenDifficulty map[uint64]int, seenV
93
110
defer reader .close ()
94
111
95
112
writer := newMissingHeaderFileWriter (outputFile , seenVanity )
96
- writer .close ()
113
+ defer writer .close ()
97
114
98
115
writer .missingHeaderWriter .writeVanities ()
99
116
100
117
reader .read (func (header * types.Header ) {
101
118
writer .missingHeaderWriter .write (header )
102
119
})
103
-
104
- fmt .Printf ("Deduplicated headers written to %s\n " , outputFile )
105
120
}
106
121
107
122
type headerReader struct {
0 commit comments