add json2wal & fix wal2json (#2196)

* add json2wal & fix wal2json

* fix bug

* Update main.go

* add wal2JsonTest file

* Delete wal2JsonTest
This commit is contained in:
bradyjoestar
2018-08-10 13:09:40 +08:00
committed by Anton Kaliaev
parent 5a8fe61200
commit 785786bec4
3 changed files with 87 additions and 3 deletions

View File

@ -8,14 +8,23 @@
package main
import (
"encoding/json"
"fmt"
"io"
"os"
cs "github.com/tendermint/tendermint/consensus"
"github.com/tendermint/go-amino"
"github.com/tendermint/tendermint/types"
)
var cdc = amino.NewCodec()
func init() {
cs.RegisterConsensusMessages(cdc)
cs.RegisterWALMessages(cdc)
types.RegisterBlockAmino(cdc)
}
func main() {
if len(os.Args) < 2 {
fmt.Println("missing one argument: <path-to-wal>")
@ -37,7 +46,7 @@ func main() {
panic(fmt.Errorf("failed to decode msg: %v", err))
}
json, err := json.Marshal(msg)
json, err := cdc.MarshalJSON(msg)
if err != nil {
panic(fmt.Errorf("failed to marshal msg: %v", err))
}