Browse Source

types: unexpose valset.To/FromBytes

pull/568/head
Ethan Buchman 7 years ago
parent
commit
e76ef2a8a1
2 changed files with 21 additions and 21 deletions
  1. +0
    -19
      types/validator_set.go
  2. +21
    -2
      types/validator_set_test.go

+ 0
- 19
types/validator_set.go 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("")
}


+ 21
- 2
types/validator_set_test.go 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)
}
}

Loading…
Cancel
Save