mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-08 22:23:11 +00:00
types: unexpose valset.To/FromBytes
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/tendermint/go-wire"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
"github.com/tendermint/tmlibs/merkle"
|
||||
)
|
||||
@@ -349,24 +348,6 @@ func (valSet *ValidatorSet) VerifyCommitAny(newSet *ValidatorSet, chainID string
|
||||
return nil
|
||||
}
|
||||
|
||||
func (valSet *ValidatorSet) ToBytes() []byte {
|
||||
buf, n, err := new(bytes.Buffer), new(int), new(error)
|
||||
wire.WriteBinary(valSet, buf, n, err)
|
||||
if *err != nil {
|
||||
cmn.PanicCrisis(*err)
|
||||
}
|
||||
return buf.Bytes()
|
||||
}
|
||||
|
||||
func (valSet *ValidatorSet) FromBytes(b []byte) {
|
||||
r, n, err := bytes.NewReader(b), new(int), new(error)
|
||||
wire.ReadBinary(valSet, r, 0, n, err)
|
||||
if *err != nil {
|
||||
// DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED
|
||||
cmn.PanicCrisis(*err)
|
||||
}
|
||||
}
|
||||
|
||||
func (valSet *ValidatorSet) String() string {
|
||||
return valSet.StringIndented("")
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/tendermint/go-crypto"
|
||||
wire "github.com/tendermint/go-wire"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
)
|
||||
|
||||
@@ -166,8 +167,8 @@ func TestProposerSelection3(t *testing.T) {
|
||||
}
|
||||
|
||||
// serialize, deserialize, check proposer
|
||||
b := vset.ToBytes()
|
||||
vset.FromBytes(b)
|
||||
b := vset.toBytes()
|
||||
vset.fromBytes(b)
|
||||
|
||||
computed := vset.GetProposer() // findGetProposer()
|
||||
if i != 0 {
|
||||
@@ -206,3 +207,21 @@ func BenchmarkValidatorSetCopy(b *testing.B) {
|
||||
vset.Copy()
|
||||
}
|
||||
}
|
||||
|
||||
func (valSet *ValidatorSet) toBytes() []byte {
|
||||
buf, n, err := new(bytes.Buffer), new(int), new(error)
|
||||
wire.WriteBinary(valSet, buf, n, err)
|
||||
if *err != nil {
|
||||
cmn.PanicCrisis(*err)
|
||||
}
|
||||
return buf.Bytes()
|
||||
}
|
||||
|
||||
func (valSet *ValidatorSet) fromBytes(b []byte) {
|
||||
r, n, err := bytes.NewReader(b), new(int), new(error)
|
||||
wire.ReadBinary(valSet, r, 0, n, err)
|
||||
if *err != nil {
|
||||
// DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED
|
||||
cmn.PanicCrisis(*err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user