mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-09 14:43:19 +00:00
migrate all JSON to new JSON encoder (#4975)
Uses new JSON encoder in #4955 for all JSON. Branched off of #4968.
This commit is contained in:
@@ -14,20 +14,11 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
amino "github.com/tendermint/go-amino"
|
||||
|
||||
cs "github.com/tendermint/tendermint/consensus"
|
||||
tmjson "github.com/tendermint/tendermint/libs/json"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
var cdc = amino.NewCodec()
|
||||
|
||||
func init() {
|
||||
cs.RegisterMessages(cdc)
|
||||
cs.RegisterWALMessages(cdc)
|
||||
types.RegisterBlockAmino(cdc)
|
||||
}
|
||||
|
||||
func main() {
|
||||
if len(os.Args) < 3 {
|
||||
fmt.Fprintln(os.Stderr, "missing arguments: Usage:json2wal <path-to-JSON> <path-to-wal>")
|
||||
@@ -65,7 +56,7 @@ func main() {
|
||||
}
|
||||
|
||||
var msg cs.TimedWALMessage
|
||||
err = cdc.UnmarshalJSON(msgJSON, &msg)
|
||||
err = tmjson.Unmarshal(msgJSON, &msg)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("failed to unmarshal json: %v", err))
|
||||
}
|
||||
|
||||
@@ -12,20 +12,10 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
|
||||
amino "github.com/tendermint/go-amino"
|
||||
|
||||
cs "github.com/tendermint/tendermint/consensus"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
tmjson "github.com/tendermint/tendermint/libs/json"
|
||||
)
|
||||
|
||||
var cdc = amino.NewCodec()
|
||||
|
||||
func init() {
|
||||
cs.RegisterMessages(cdc)
|
||||
cs.RegisterWALMessages(cdc)
|
||||
types.RegisterBlockAmino(cdc)
|
||||
}
|
||||
|
||||
func main() {
|
||||
if len(os.Args) < 2 {
|
||||
fmt.Println("missing one argument: <path-to-wal>")
|
||||
@@ -47,7 +37,7 @@ func main() {
|
||||
panic(fmt.Errorf("failed to decode msg: %v", err))
|
||||
}
|
||||
|
||||
json, err := cdc.MarshalJSON(msg)
|
||||
json, err := tmjson.Marshal(msg)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("failed to marshal msg: %v", err))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user