io: rename ReadBytes() to ReadVarBytes()
This commit is contained in:
parent
f01fc1cc29
commit
838050f8b5
14 changed files with 22 additions and 22 deletions
|
@ -217,7 +217,7 @@ func (p *Payload) DecodeBinaryUnsigned(r *io.BinReader) {
|
||||||
r.ReadLE(&p.validatorIndex)
|
r.ReadLE(&p.validatorIndex)
|
||||||
r.ReadLE(&p.timestamp)
|
r.ReadLE(&p.timestamp)
|
||||||
|
|
||||||
data := r.ReadBytes()
|
data := r.ReadVarBytes()
|
||||||
if r.Err != nil {
|
if r.Err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ func (p *changeViewCompact) DecodeBinary(r *io.BinReader) {
|
||||||
r.ReadLE(&p.ValidatorIndex)
|
r.ReadLE(&p.ValidatorIndex)
|
||||||
r.ReadLE(&p.OriginalViewNumber)
|
r.ReadLE(&p.OriginalViewNumber)
|
||||||
r.ReadLE(&p.Timestamp)
|
r.ReadLE(&p.Timestamp)
|
||||||
p.InvocationScript = r.ReadBytes()
|
p.InvocationScript = r.ReadVarBytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
// EncodeBinary implements io.Serializable interface.
|
// EncodeBinary implements io.Serializable interface.
|
||||||
|
@ -109,7 +109,7 @@ func (p *commitCompact) DecodeBinary(r *io.BinReader) {
|
||||||
r.ReadLE(&p.ViewNumber)
|
r.ReadLE(&p.ViewNumber)
|
||||||
r.ReadLE(&p.ValidatorIndex)
|
r.ReadLE(&p.ValidatorIndex)
|
||||||
r.ReadBE(p.Signature[:])
|
r.ReadBE(p.Signature[:])
|
||||||
p.InvocationScript = r.ReadBytes()
|
p.InvocationScript = r.ReadVarBytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
// EncodeBinary implements io.Serializable interface.
|
// EncodeBinary implements io.Serializable interface.
|
||||||
|
@ -123,7 +123,7 @@ func (p *commitCompact) EncodeBinary(w *io.BinWriter) {
|
||||||
// DecodeBinary implements io.Serializable interface.
|
// DecodeBinary implements io.Serializable interface.
|
||||||
func (p *preparationCompact) DecodeBinary(r *io.BinReader) {
|
func (p *preparationCompact) DecodeBinary(r *io.BinReader) {
|
||||||
r.ReadLE(&p.ValidatorIndex)
|
r.ReadLE(&p.ValidatorIndex)
|
||||||
p.InvocationScript = r.ReadBytes()
|
p.InvocationScript = r.ReadVarBytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
// EncodeBinary implements io.Serializable interface.
|
// EncodeBinary implements io.Serializable interface.
|
||||||
|
|
|
@ -38,7 +38,7 @@ func (a Contracts) commit(store storage.Store) error {
|
||||||
|
|
||||||
// DecodeBinary implements Serializable interface.
|
// DecodeBinary implements Serializable interface.
|
||||||
func (cs *ContractState) DecodeBinary(br *io.BinReader) {
|
func (cs *ContractState) DecodeBinary(br *io.BinReader) {
|
||||||
cs.Script = br.ReadBytes()
|
cs.Script = br.ReadVarBytes()
|
||||||
br.ReadArray(&cs.ParamList)
|
br.ReadArray(&cs.ParamList)
|
||||||
br.ReadLE(&cs.ReturnType)
|
br.ReadLE(&cs.ReturnType)
|
||||||
br.ReadLE(&cs.Properties)
|
br.ReadLE(&cs.Properties)
|
||||||
|
|
|
@ -59,6 +59,6 @@ func (si *StorageItem) EncodeBinary(w *io.BinWriter) {
|
||||||
|
|
||||||
// DecodeBinary implements Serializable interface.
|
// DecodeBinary implements Serializable interface.
|
||||||
func (si *StorageItem) DecodeBinary(r *io.BinReader) {
|
func (si *StorageItem) DecodeBinary(r *io.BinReader) {
|
||||||
si.Value = r.ReadBytes()
|
si.Value = r.ReadVarBytes()
|
||||||
r.ReadLE(&si.IsConst)
|
r.ReadLE(&si.IsConst)
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ func NewInvocationTX(script []byte, gas util.Fixed8) *Transaction {
|
||||||
|
|
||||||
// DecodeBinary implements Serializable interface.
|
// DecodeBinary implements Serializable interface.
|
||||||
func (tx *InvocationTX) DecodeBinary(br *io.BinReader) {
|
func (tx *InvocationTX) DecodeBinary(br *io.BinReader) {
|
||||||
tx.Script = br.ReadBytes()
|
tx.Script = br.ReadVarBytes()
|
||||||
if tx.Version >= 1 {
|
if tx.Version >= 1 {
|
||||||
br.ReadLE(&tx.Gas)
|
br.ReadLE(&tx.Gas)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -22,7 +22,7 @@ type PublishTX struct {
|
||||||
|
|
||||||
// DecodeBinary implements Serializable interface.
|
// DecodeBinary implements Serializable interface.
|
||||||
func (tx *PublishTX) DecodeBinary(br *io.BinReader) {
|
func (tx *PublishTX) DecodeBinary(br *io.BinReader) {
|
||||||
tx.Script = br.ReadBytes()
|
tx.Script = br.ReadVarBytes()
|
||||||
|
|
||||||
lenParams := br.ReadVarUint()
|
lenParams := br.ReadVarUint()
|
||||||
tx.ParamList = make([]smartcontract.ParamType, lenParams)
|
tx.ParamList = make([]smartcontract.ParamType, lenParams)
|
||||||
|
|
|
@ -25,8 +25,8 @@ type StateDescriptor struct {
|
||||||
func (s *StateDescriptor) DecodeBinary(r *io.BinReader) {
|
func (s *StateDescriptor) DecodeBinary(r *io.BinReader) {
|
||||||
r.ReadLE(&s.Type)
|
r.ReadLE(&s.Type)
|
||||||
|
|
||||||
s.Key = r.ReadBytes()
|
s.Key = r.ReadVarBytes()
|
||||||
s.Value = r.ReadBytes()
|
s.Value = r.ReadVarBytes()
|
||||||
s.Field = r.ReadString()
|
s.Field = r.ReadString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@ type Witness struct {
|
||||||
|
|
||||||
// DecodeBinary implements Serializable interface.
|
// DecodeBinary implements Serializable interface.
|
||||||
func (w *Witness) DecodeBinary(br *io.BinReader) {
|
func (w *Witness) DecodeBinary(br *io.BinReader) {
|
||||||
w.InvocationScript = br.ReadBytes()
|
w.InvocationScript = br.ReadVarBytes()
|
||||||
w.VerificationScript = br.ReadBytes()
|
w.VerificationScript = br.ReadVarBytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
// EncodeBinary implements Serializable interface.
|
// EncodeBinary implements Serializable interface.
|
||||||
|
|
|
@ -127,17 +127,17 @@ func (r *BinReader) ReadVarUint() uint64 {
|
||||||
return uint64(b)
|
return uint64(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadBytes reads the next set of bytes from the underlying reader.
|
// ReadVarBytes reads the next set of bytes from the underlying reader.
|
||||||
// ReadVarUInt() is used to determine how large that slice is
|
// ReadVarUInt() is used to determine how large that slice is
|
||||||
func (r *BinReader) ReadBytes() []byte {
|
func (r *BinReader) ReadVarBytes() []byte {
|
||||||
n := r.ReadVarUint()
|
n := r.ReadVarUint()
|
||||||
b := make([]byte, n)
|
b := make([]byte, n)
|
||||||
r.ReadLE(b)
|
r.ReadLE(b)
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadString calls ReadBytes and casts the results as a string.
|
// ReadString calls ReadVarBytes and casts the results as a string.
|
||||||
func (r *BinReader) ReadString() string {
|
func (r *BinReader) ReadString() string {
|
||||||
b := r.ReadBytes()
|
b := r.ReadVarBytes()
|
||||||
return string(b)
|
return string(b)
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ func TestReaderErrHandling(t *testing.T) {
|
||||||
assert.Equal(t, i, iorig)
|
assert.Equal(t, i, iorig)
|
||||||
val := br.ReadVarUint()
|
val := br.ReadVarUint()
|
||||||
assert.Equal(t, val, uint64(0))
|
assert.Equal(t, val, uint64(0))
|
||||||
b := br.ReadBytes()
|
b := br.ReadVarBytes()
|
||||||
assert.Equal(t, b, []byte{})
|
assert.Equal(t, b, []byte{})
|
||||||
s := br.ReadString()
|
s := br.ReadString()
|
||||||
assert.Equal(t, s, "")
|
assert.Equal(t, s, "")
|
||||||
|
|
|
@ -21,7 +21,7 @@ func (m *MerkleBlock) DecodeBinary(br *io.BinReader) {
|
||||||
|
|
||||||
m.TxCount = int(br.ReadVarUint())
|
m.TxCount = int(br.ReadVarUint())
|
||||||
br.ReadArray(&m.Hashes)
|
br.ReadArray(&m.Hashes)
|
||||||
m.Flags = br.ReadBytes()
|
m.Flags = br.ReadVarBytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
// EncodeBinary implements Serializable interface.
|
// EncodeBinary implements Serializable interface.
|
||||||
|
|
|
@ -60,7 +60,7 @@ func (p *Version) DecodeBinary(br *io.BinReader) {
|
||||||
br.ReadLE(&p.Timestamp)
|
br.ReadLE(&p.Timestamp)
|
||||||
br.ReadLE(&p.Port)
|
br.ReadLE(&p.Port)
|
||||||
br.ReadLE(&p.Nonce)
|
br.ReadLE(&p.Nonce)
|
||||||
p.UserAgent = br.ReadBytes()
|
p.UserAgent = br.ReadVarBytes()
|
||||||
br.ReadLE(&p.StartHeight)
|
br.ReadLE(&p.StartHeight)
|
||||||
br.ReadLE(&p.Relay)
|
br.ReadLE(&p.Relay)
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ func TestCreateMultiSigRedeemScript(t *testing.T) {
|
||||||
assert.Equal(t, opcode.PUSH3, opcode.Opcode(b))
|
assert.Equal(t, opcode.PUSH3, opcode.Opcode(b))
|
||||||
|
|
||||||
for i := 0; i < len(validators); i++ {
|
for i := 0; i < len(validators); i++ {
|
||||||
bb := br.ReadBytes()
|
bb := br.ReadVarBytes()
|
||||||
if br.Err != nil {
|
if br.Err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,14 +102,14 @@ func DecodeBinaryStackItem(r *io.BinReader) StackItem {
|
||||||
|
|
||||||
switch stackItemType(t) {
|
switch stackItemType(t) {
|
||||||
case byteArrayT:
|
case byteArrayT:
|
||||||
data := r.ReadBytes()
|
data := r.ReadVarBytes()
|
||||||
return NewByteArrayItem(data)
|
return NewByteArrayItem(data)
|
||||||
case booleanT:
|
case booleanT:
|
||||||
var b bool
|
var b bool
|
||||||
r.ReadLE(&b)
|
r.ReadLE(&b)
|
||||||
return NewBoolItem(b)
|
return NewBoolItem(b)
|
||||||
case integerT:
|
case integerT:
|
||||||
data := r.ReadBytes()
|
data := r.ReadVarBytes()
|
||||||
num := new(big.Int).SetBytes(util.ArrayReverse(data))
|
num := new(big.Int).SetBytes(util.ArrayReverse(data))
|
||||||
return &BigIntegerItem{
|
return &BigIntegerItem{
|
||||||
value: num,
|
value: num,
|
||||||
|
|
Loading…
Reference in a new issue