mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-04 23:27:02 +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:
@@ -23,8 +23,8 @@ var (
|
||||
|
||||
// peerStateStats holds internal statistics for a peer.
|
||||
type peerStateStats struct {
|
||||
Votes int `json:"votes"`
|
||||
BlockParts int `json:"block_parts"`
|
||||
Votes int `json:"votes,string"`
|
||||
BlockParts int `json:"block_parts,string"`
|
||||
}
|
||||
|
||||
func (pss peerStateStats) String() string {
|
||||
|
||||
@@ -3,6 +3,7 @@ package consensus
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -20,7 +21,6 @@ import (
|
||||
"github.com/tendermint/tendermint/internal/libs/fail"
|
||||
sm "github.com/tendermint/tendermint/internal/state"
|
||||
tmevents "github.com/tendermint/tendermint/libs/events"
|
||||
tmjson "github.com/tendermint/tendermint/libs/json"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
tmmath "github.com/tendermint/tendermint/libs/math"
|
||||
tmos "github.com/tendermint/tendermint/libs/os"
|
||||
@@ -253,14 +253,14 @@ func (cs *State) GetRoundState() *cstypes.RoundState {
|
||||
func (cs *State) GetRoundStateJSON() ([]byte, error) {
|
||||
cs.mtx.RLock()
|
||||
defer cs.mtx.RUnlock()
|
||||
return tmjson.Marshal(cs.RoundState)
|
||||
return json.Marshal(cs.RoundState)
|
||||
}
|
||||
|
||||
// GetRoundStateSimpleJSON returns a json of RoundStateSimple
|
||||
func (cs *State) GetRoundStateSimpleJSON() ([]byte, error) {
|
||||
cs.mtx.RLock()
|
||||
defer cs.mtx.RUnlock()
|
||||
return tmjson.Marshal(cs.RoundState.RoundStateSimple())
|
||||
return json.Marshal(cs.RoundState.RoundStateSimple())
|
||||
}
|
||||
|
||||
// GetValidators returns a copy of the current validators.
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
tmjson "github.com/tendermint/tendermint/libs/json"
|
||||
tmmath "github.com/tendermint/tendermint/libs/math"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
@@ -237,7 +237,7 @@ func (hvs *HeightVoteSet) StringIndented(indent string) string {
|
||||
func (hvs *HeightVoteSet) MarshalJSON() ([]byte, error) {
|
||||
hvs.mtx.Lock()
|
||||
defer hvs.mtx.Unlock()
|
||||
return tmjson.Marshal(hvs.toAllRoundVotes())
|
||||
return json.Marshal(hvs.toAllRoundVotes())
|
||||
}
|
||||
|
||||
func (hvs *HeightVoteSet) toAllRoundVotes() []roundVotes {
|
||||
|
||||
@@ -13,9 +13,9 @@ import (
|
||||
// PeerRoundState contains the known state of a peer.
|
||||
// NOTE: Read-only when returned by PeerState.GetRoundState().
|
||||
type PeerRoundState struct {
|
||||
Height int64 `json:"height"` // Height peer is at
|
||||
Round int32 `json:"round"` // Round peer is at, -1 if unknown.
|
||||
Step RoundStepType `json:"step"` // Step peer is at
|
||||
Height int64 `json:"height,string"` // Height peer is at
|
||||
Round int32 `json:"round"` // Round peer is at, -1 if unknown.
|
||||
Step RoundStepType `json:"step"` // Step peer is at
|
||||
|
||||
// Estimated start of round 0 at this height
|
||||
StartTime time.Time `json:"start_time"`
|
||||
|
||||
Reference in New Issue
Block a user