types: unexpose valset.To/FromBytes

This commit is contained in:
Ethan Buchman
2017-10-26 00:13:19 -04:00
parent 376f47e030
commit e76ef2a8a1
2 changed files with 21 additions and 21 deletions

View File

@@ -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("")
}

View File

@@ -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)
}
}