-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdump-txs.go
More file actions
36 lines (32 loc) · 730 Bytes
/
dump-txs.go
File metadata and controls
36 lines (32 loc) · 730 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"bufio"
"fmt"
"log"
"math/big"
"os"
)
func dumpTxs() {
//clientLocation := "/nvme/op-geth/snapdata-path/geth.ipc"
clientLocation := "/nvme/op-geth/snapdata-path/"
blockNum := big.NewInt(10000000) // starting block; will iterate backwards from here
txIter := NewTxIterRPC(clientLocation, blockNum)
f, err := os.Create("./dump")
if err != nil {
log.Fatalln(err)
}
defer f.Close()
w := bufio.NewWriter(f)
count := 0
for b := txIter.Next(); ; b = txIter.Next() {
if b == nil {
log.Println("ran out of transactions, exiting loop")
break
}
fmt.Fprintf(w, "%x\n", b)
count++
if count%100000 == 0 {
fmt.Println("tx count:", count, "on block:", txIter.BlockNumber())
}
}
}