mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-14 13:51:21 +00:00
write docs for cutWALUntil and wal2json binaries
This commit is contained in:
@ -1,3 +1,10 @@
|
|||||||
|
/*
|
||||||
|
cutWALUntil is a small utility for cutting a WAL until the given height
|
||||||
|
(inclusively). Note it does not include last cs.EndHeightMessage.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
cutWALUntil <path-to-wal> height-to-stop <output-wal>
|
||||||
|
*/
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -10,27 +17,32 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
if len(os.Args) < 4 {
|
||||||
|
fmt.Println("3 arguments required: <path-to-wal> height-to-stop <output-wal>")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
var heightToStop uint64
|
var heightToStop uint64
|
||||||
var err error
|
var err error
|
||||||
if heightToStop, err = strconv.ParseUint(os.Args[2], 10, 64); err != nil {
|
if heightToStop, err = strconv.ParseUint(os.Args[2], 10, 64); err != nil {
|
||||||
panic(fmt.Errorf("failed to parse height: %v (format: cutWALUntil in heightToStop out)", err))
|
panic(fmt.Errorf("failed to parse height: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
in, err := os.Open(os.Args[1])
|
in, err := os.Open(os.Args[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Errorf("failed to open WAL file: %v (format: cutWALUntil in heightToStop out)", err))
|
panic(fmt.Errorf("failed to open input WAL file: %v", err))
|
||||||
}
|
}
|
||||||
defer in.Close()
|
defer in.Close()
|
||||||
|
|
||||||
out, err := os.Create(os.Args[3])
|
out, err := os.Create(os.Args[3])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Errorf("failed to open WAL file: %v (format: cutWALUntil in heightToStop out)", err))
|
panic(fmt.Errorf("failed to open output WAL file: %v", err))
|
||||||
}
|
}
|
||||||
defer out.Close()
|
defer out.Close()
|
||||||
|
|
||||||
enc := cs.NewWALEncoder(out)
|
enc := cs.NewWALEncoder(out)
|
||||||
|
|
||||||
dec := cs.NewWALDecoder(in)
|
dec := cs.NewWALDecoder(in)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
msg, err := dec.Decode()
|
msg, err := dec.Decode()
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
/*
|
||||||
|
wal2json converts binary WAL file to JSON.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
wal2json <path-to-wal>
|
||||||
|
*/
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -10,6 +16,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
if len(os.Args) < 2 {
|
||||||
|
fmt.Println("missing one argument: <path-to-wal>")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
f, err := os.Open(os.Args[1])
|
f, err := os.Open(os.Args[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Errorf("failed to open WAL file: %v", err))
|
panic(fmt.Errorf("failed to open WAL file: %v", err))
|
||||||
|
Reference in New Issue
Block a user