mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-19 22:44:24 +00:00
Replace uses of libs/json with encoding/json. (#7534)
Where possible, replace uses of the custom JSON library with the standard library. The custom library treats interface and unnamed lteral types differently, so this change avoids those even where it would probably be safe to switch them.
This commit is contained in:
+4
-3
@@ -3,6 +3,7 @@ package privval
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
@@ -72,7 +73,7 @@ func (pvKey FilePVKey) Save() error {
|
||||
|
||||
// FilePVLastSignState stores the mutable part of PrivValidator.
|
||||
type FilePVLastSignState struct {
|
||||
Height int64 `json:"height"`
|
||||
Height int64 `json:"height,string"`
|
||||
Round int32 `json:"round"`
|
||||
Step int8 `json:"step"`
|
||||
Signature []byte `json:"signature,omitempty"`
|
||||
@@ -128,7 +129,7 @@ func (lss *FilePVLastSignState) Save() error {
|
||||
if outFile == "" {
|
||||
return errors.New("cannot save FilePVLastSignState: filePath not set")
|
||||
}
|
||||
jsonBytes, err := tmjson.MarshalIndent(lss, "", " ")
|
||||
jsonBytes, err := json.MarshalIndent(lss, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -215,7 +216,7 @@ func loadFilePV(keyFilePath, stateFilePath string, loadState bool) (*FilePV, err
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = tmjson.Unmarshal(stateJSONBytes, &pvState)
|
||||
err = json.Unmarshal(stateJSONBytes, &pvState)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error reading PrivValidator state from %v: %w", stateFilePath, err)
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package privval
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
@@ -105,7 +106,7 @@ func TestUnmarshalValidatorState(t *testing.T) {
|
||||
}`
|
||||
|
||||
val := FilePVLastSignState{}
|
||||
err := tmjson.Unmarshal([]byte(serialized), &val)
|
||||
err := json.Unmarshal([]byte(serialized), &val)
|
||||
require.NoError(t, err)
|
||||
|
||||
// make sure the values match
|
||||
@@ -114,7 +115,7 @@ func TestUnmarshalValidatorState(t *testing.T) {
|
||||
assert.EqualValues(t, val.Step, 1)
|
||||
|
||||
// export it and make sure it is the same
|
||||
out, err := tmjson.Marshal(val)
|
||||
out, err := json.Marshal(val)
|
||||
require.NoError(t, err)
|
||||
assert.JSONEq(t, serialized, string(out))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user