forked from TrueCloudLab/neoneo-go
io: rename Read/WriteBytes to Read/WriteB
go vet is not happy about them: pkg/io/binaryReader.go:92:21: method ReadByte() byte should have signature ReadByte() (byte, error) pkg/io/binaryWriter.go:75:21: method WriteByte(u8 byte) should have signature WriteByte(byte) error
This commit is contained in:
parent
0b14916d79
commit
8b3080b972
22 changed files with 70 additions and 70 deletions
|
@ -176,7 +176,7 @@ func (p *Payload) EncodeBinaryUnsigned(w *io.BinWriter) {
|
|||
func (p *Payload) EncodeBinary(w *io.BinWriter) {
|
||||
p.EncodeBinaryUnsigned(w)
|
||||
|
||||
w.WriteByte(1)
|
||||
w.WriteB(1)
|
||||
p.Witness.EncodeBinary(w)
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,7 @@ func (p *Payload) DecodeBinary(r *io.BinReader) {
|
|||
return
|
||||
}
|
||||
|
||||
var b = r.ReadByte()
|
||||
var b = r.ReadB()
|
||||
if b != 1 {
|
||||
r.Err = errors.New("invalid format")
|
||||
return
|
||||
|
@ -254,14 +254,14 @@ func (p *Payload) DecodeBinary(r *io.BinReader) {
|
|||
// EncodeBinary implements io.Serializable interface.
|
||||
func (m *message) EncodeBinary(w *io.BinWriter) {
|
||||
w.WriteBytes([]byte{byte(m.Type)})
|
||||
w.WriteByte(m.ViewNumber)
|
||||
w.WriteB(m.ViewNumber)
|
||||
m.payload.EncodeBinary(w)
|
||||
}
|
||||
|
||||
// DecodeBinary implements io.Serializable interface.
|
||||
func (m *message) DecodeBinary(r *io.BinReader) {
|
||||
m.Type = messageType(r.ReadByte())
|
||||
m.ViewNumber = r.ReadByte()
|
||||
m.Type = messageType(r.ReadB())
|
||||
m.ViewNumber = r.ReadB()
|
||||
|
||||
switch m.Type {
|
||||
case changeViewType:
|
||||
|
|
|
@ -90,7 +90,7 @@ func (m *recoveryMessage) EncodeBinary(w *io.BinWriter) {
|
|||
// DecodeBinary implements io.Serializable interface.
|
||||
func (p *changeViewCompact) DecodeBinary(r *io.BinReader) {
|
||||
p.ValidatorIndex = r.ReadU16LE()
|
||||
p.OriginalViewNumber = r.ReadByte()
|
||||
p.OriginalViewNumber = r.ReadB()
|
||||
p.Timestamp = r.ReadU32LE()
|
||||
p.InvocationScript = r.ReadVarBytes()
|
||||
}
|
||||
|
@ -98,14 +98,14 @@ func (p *changeViewCompact) DecodeBinary(r *io.BinReader) {
|
|||
// EncodeBinary implements io.Serializable interface.
|
||||
func (p *changeViewCompact) EncodeBinary(w *io.BinWriter) {
|
||||
w.WriteU16LE(p.ValidatorIndex)
|
||||
w.WriteByte(p.OriginalViewNumber)
|
||||
w.WriteB(p.OriginalViewNumber)
|
||||
w.WriteU32LE(p.Timestamp)
|
||||
w.WriteVarBytes(p.InvocationScript)
|
||||
}
|
||||
|
||||
// DecodeBinary implements io.Serializable interface.
|
||||
func (p *commitCompact) DecodeBinary(r *io.BinReader) {
|
||||
p.ViewNumber = r.ReadByte()
|
||||
p.ViewNumber = r.ReadB()
|
||||
p.ValidatorIndex = r.ReadU16LE()
|
||||
r.ReadBytes(p.Signature[:])
|
||||
p.InvocationScript = r.ReadVarBytes()
|
||||
|
@ -113,7 +113,7 @@ func (p *commitCompact) DecodeBinary(r *io.BinReader) {
|
|||
|
||||
// EncodeBinary implements io.Serializable interface.
|
||||
func (p *commitCompact) EncodeBinary(w *io.BinWriter) {
|
||||
w.WriteByte(p.ViewNumber)
|
||||
w.WriteB(p.ViewNumber)
|
||||
w.WriteU16LE(p.ValidatorIndex)
|
||||
w.WriteBytes(p.Signature[:])
|
||||
w.WriteVarBytes(p.InvocationScript)
|
||||
|
|
|
@ -88,7 +88,7 @@ func NewBlockFromTrimmedBytes(b []byte) (*Block, error) {
|
|||
br := io.NewBinReaderFromBuf(b)
|
||||
block.decodeHashableFields(br)
|
||||
|
||||
_ = br.ReadByte()
|
||||
_ = br.ReadB()
|
||||
|
||||
block.Script.DecodeBinary(br)
|
||||
|
||||
|
@ -109,7 +109,7 @@ func NewBlockFromTrimmedBytes(b []byte) (*Block, error) {
|
|||
func (b *Block) Trim() ([]byte, error) {
|
||||
buf := io.NewBufBinWriter()
|
||||
b.encodeHashableFields(buf.BinWriter)
|
||||
buf.WriteByte(1)
|
||||
buf.WriteB(1)
|
||||
b.Script.EncodeBinary(buf.BinWriter)
|
||||
|
||||
buf.WriteVarUint(uint64(len(b.Transactions)))
|
||||
|
|
|
@ -39,7 +39,7 @@ func NewAccount(scriptHash util.Uint160) *Account {
|
|||
|
||||
// DecodeBinary decodes Account from the given BinReader.
|
||||
func (s *Account) DecodeBinary(br *io.BinReader) {
|
||||
s.Version = uint8(br.ReadByte())
|
||||
s.Version = uint8(br.ReadB())
|
||||
br.ReadBytes(s.ScriptHash[:])
|
||||
s.IsFrozen = br.ReadBool()
|
||||
br.ReadArray(&s.Votes)
|
||||
|
@ -57,7 +57,7 @@ func (s *Account) DecodeBinary(br *io.BinReader) {
|
|||
|
||||
// EncodeBinary encodes Account to the given BinWriter.
|
||||
func (s *Account) EncodeBinary(bw *io.BinWriter) {
|
||||
bw.WriteByte(byte(s.Version))
|
||||
bw.WriteB(byte(s.Version))
|
||||
bw.WriteBytes(s.ScriptHash[:])
|
||||
bw.WriteBool(s.IsFrozen)
|
||||
bw.WriteArray(s.Votes)
|
||||
|
|
|
@ -29,14 +29,14 @@ type Asset struct {
|
|||
// DecodeBinary implements Serializable interface.
|
||||
func (a *Asset) DecodeBinary(br *io.BinReader) {
|
||||
br.ReadBytes(a.ID[:])
|
||||
a.AssetType = transaction.AssetType(br.ReadByte())
|
||||
a.AssetType = transaction.AssetType(br.ReadB())
|
||||
|
||||
a.Name = br.ReadString()
|
||||
|
||||
a.Amount.DecodeBinary(br)
|
||||
a.Available.DecodeBinary(br)
|
||||
a.Precision = uint8(br.ReadByte())
|
||||
a.FeeMode = uint8(br.ReadByte())
|
||||
a.Precision = uint8(br.ReadB())
|
||||
a.FeeMode = uint8(br.ReadB())
|
||||
br.ReadBytes(a.FeeAddress[:])
|
||||
|
||||
a.Owner.DecodeBinary(br)
|
||||
|
@ -49,12 +49,12 @@ func (a *Asset) DecodeBinary(br *io.BinReader) {
|
|||
// EncodeBinary implements Serializable interface.
|
||||
func (a *Asset) EncodeBinary(bw *io.BinWriter) {
|
||||
bw.WriteBytes(a.ID[:])
|
||||
bw.WriteByte(byte(a.AssetType))
|
||||
bw.WriteB(byte(a.AssetType))
|
||||
bw.WriteString(a.Name)
|
||||
a.Amount.EncodeBinary(bw)
|
||||
a.Available.EncodeBinary(bw)
|
||||
bw.WriteByte(byte(a.Precision))
|
||||
bw.WriteByte(byte(a.FeeMode))
|
||||
bw.WriteB(byte(a.Precision))
|
||||
bw.WriteB(byte(a.FeeMode))
|
||||
bw.WriteBytes(a.FeeAddress[:])
|
||||
|
||||
a.Owner.EncodeBinary(bw)
|
||||
|
|
|
@ -26,8 +26,8 @@ type Contract struct {
|
|||
func (cs *Contract) DecodeBinary(br *io.BinReader) {
|
||||
cs.Script = br.ReadVarBytes()
|
||||
br.ReadArray(&cs.ParamList)
|
||||
cs.ReturnType = smartcontract.ParamType(br.ReadByte())
|
||||
cs.Properties = smartcontract.PropertyState(br.ReadByte())
|
||||
cs.ReturnType = smartcontract.ParamType(br.ReadB())
|
||||
cs.Properties = smartcontract.PropertyState(br.ReadB())
|
||||
cs.Name = br.ReadString()
|
||||
cs.CodeVersion = br.ReadString()
|
||||
cs.Author = br.ReadString()
|
||||
|
@ -40,8 +40,8 @@ func (cs *Contract) DecodeBinary(br *io.BinReader) {
|
|||
func (cs *Contract) EncodeBinary(bw *io.BinWriter) {
|
||||
bw.WriteVarBytes(cs.Script)
|
||||
bw.WriteArray(cs.ParamList)
|
||||
bw.WriteByte(byte(cs.ReturnType))
|
||||
bw.WriteByte(byte(cs.Properties))
|
||||
bw.WriteB(byte(cs.ReturnType))
|
||||
bw.WriteB(byte(cs.Properties))
|
||||
bw.WriteString(cs.Name)
|
||||
bw.WriteString(cs.CodeVersion)
|
||||
bw.WriteString(cs.Author)
|
||||
|
|
|
@ -39,7 +39,7 @@ func (ne *NotificationEvent) DecodeBinary(r *io.BinReader) {
|
|||
// EncodeBinary implements the Serializable interface.
|
||||
func (aer *AppExecResult) EncodeBinary(w *io.BinWriter) {
|
||||
w.WriteBytes(aer.TxHash[:])
|
||||
w.WriteByte(aer.Trigger)
|
||||
w.WriteB(aer.Trigger)
|
||||
w.WriteString(aer.VMState)
|
||||
aer.GasConsumed.EncodeBinary(w)
|
||||
w.WriteString(aer.Stack)
|
||||
|
@ -49,7 +49,7 @@ func (aer *AppExecResult) EncodeBinary(w *io.BinWriter) {
|
|||
// DecodeBinary implements the Serializable interface.
|
||||
func (aer *AppExecResult) DecodeBinary(r *io.BinReader) {
|
||||
r.ReadBytes(aer.TxHash[:])
|
||||
aer.Trigger = r.ReadByte()
|
||||
aer.Trigger = r.ReadB()
|
||||
aer.VMState = r.ReadString()
|
||||
aer.GasConsumed.DecodeBinary(r)
|
||||
aer.Stack = r.ReadString()
|
||||
|
|
|
@ -16,7 +16,7 @@ type Attribute struct {
|
|||
|
||||
// DecodeBinary implements Serializable interface.
|
||||
func (attr *Attribute) DecodeBinary(br *io.BinReader) {
|
||||
attr.Usage = AttrUsage(br.ReadByte())
|
||||
attr.Usage = AttrUsage(br.ReadB())
|
||||
|
||||
// very special case
|
||||
if attr.Usage == ECDH02 || attr.Usage == ECDH03 {
|
||||
|
@ -35,7 +35,7 @@ func (attr *Attribute) DecodeBinary(br *io.BinReader) {
|
|||
datasize = 20
|
||||
case DescriptionURL:
|
||||
// It's not VarUint as per C# implementation, dunno why
|
||||
var urllen = br.ReadByte()
|
||||
var urllen = br.ReadB()
|
||||
datasize = uint64(urllen)
|
||||
case Description, Remark, Remark1, Remark2, Remark3, Remark4,
|
||||
Remark5, Remark6, Remark7, Remark8, Remark9, Remark10, Remark11,
|
||||
|
@ -51,7 +51,7 @@ func (attr *Attribute) DecodeBinary(br *io.BinReader) {
|
|||
|
||||
// EncodeBinary implements Serializable interface.
|
||||
func (attr *Attribute) EncodeBinary(bw *io.BinWriter) {
|
||||
bw.WriteByte(byte(attr.Usage))
|
||||
bw.WriteB(byte(attr.Usage))
|
||||
switch attr.Usage {
|
||||
case ECDH02, ECDH03:
|
||||
bw.WriteBytes(attr.Data[1:])
|
||||
|
@ -60,7 +60,7 @@ func (attr *Attribute) EncodeBinary(bw *io.BinWriter) {
|
|||
Remark12, Remark13, Remark14, Remark15:
|
||||
bw.WriteVarBytes(attr.Data)
|
||||
case DescriptionURL:
|
||||
bw.WriteByte(byte(len(attr.Data)))
|
||||
bw.WriteB(byte(len(attr.Data)))
|
||||
fallthrough
|
||||
case Script, ContractHash, Vote, Hash1, Hash2, Hash3, Hash4, Hash5, Hash6,
|
||||
Hash7, Hash8, Hash9, Hash10, Hash11, Hash12, Hash13, Hash14, Hash15:
|
||||
|
|
|
@ -27,10 +27,10 @@ func (tx *PublishTX) DecodeBinary(br *io.BinReader) {
|
|||
lenParams := br.ReadVarUint()
|
||||
tx.ParamList = make([]smartcontract.ParamType, lenParams)
|
||||
for i := 0; i < int(lenParams); i++ {
|
||||
tx.ParamList[i] = smartcontract.ParamType(br.ReadByte())
|
||||
tx.ParamList[i] = smartcontract.ParamType(br.ReadB())
|
||||
}
|
||||
|
||||
tx.ReturnType = smartcontract.ParamType(br.ReadByte())
|
||||
tx.ReturnType = smartcontract.ParamType(br.ReadB())
|
||||
|
||||
if tx.Version >= 1 {
|
||||
tx.NeedStorage = br.ReadBool()
|
||||
|
@ -50,9 +50,9 @@ func (tx *PublishTX) EncodeBinary(bw *io.BinWriter) {
|
|||
bw.WriteVarBytes(tx.Script)
|
||||
bw.WriteVarUint(uint64(len(tx.ParamList)))
|
||||
for _, param := range tx.ParamList {
|
||||
bw.WriteByte(byte(param))
|
||||
bw.WriteB(byte(param))
|
||||
}
|
||||
bw.WriteByte(byte(tx.ReturnType))
|
||||
bw.WriteB(byte(tx.ReturnType))
|
||||
if tx.Version >= 1 {
|
||||
bw.WriteBool(tx.NeedStorage)
|
||||
}
|
||||
|
|
|
@ -30,12 +30,12 @@ type RegisterTX struct {
|
|||
|
||||
// DecodeBinary implements Serializable interface.
|
||||
func (tx *RegisterTX) DecodeBinary(br *io.BinReader) {
|
||||
tx.AssetType = AssetType(br.ReadByte())
|
||||
tx.AssetType = AssetType(br.ReadB())
|
||||
|
||||
tx.Name = br.ReadString()
|
||||
|
||||
tx.Amount.DecodeBinary(br)
|
||||
tx.Precision = uint8(br.ReadByte())
|
||||
tx.Precision = uint8(br.ReadB())
|
||||
|
||||
tx.Owner.DecodeBinary(br)
|
||||
|
||||
|
@ -44,10 +44,10 @@ func (tx *RegisterTX) DecodeBinary(br *io.BinReader) {
|
|||
|
||||
// EncodeBinary implements Serializable interface.
|
||||
func (tx *RegisterTX) EncodeBinary(bw *io.BinWriter) {
|
||||
bw.WriteByte(byte(tx.AssetType))
|
||||
bw.WriteB(byte(tx.AssetType))
|
||||
bw.WriteString(tx.Name)
|
||||
tx.Amount.EncodeBinary(bw)
|
||||
bw.WriteByte(byte(tx.Precision))
|
||||
bw.WriteB(byte(tx.Precision))
|
||||
bw.WriteBytes(tx.Owner.Bytes())
|
||||
bw.WriteBytes(tx.Admin[:])
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ type StateDescriptor struct {
|
|||
|
||||
// DecodeBinary implements Serializable interface.
|
||||
func (s *StateDescriptor) DecodeBinary(r *io.BinReader) {
|
||||
s.Type = DescStateType(r.ReadByte())
|
||||
s.Type = DescStateType(r.ReadB())
|
||||
|
||||
s.Key = r.ReadVarBytes()
|
||||
s.Value = r.ReadVarBytes()
|
||||
|
@ -32,7 +32,7 @@ func (s *StateDescriptor) DecodeBinary(r *io.BinReader) {
|
|||
|
||||
// EncodeBinary implements Serializable interface.
|
||||
func (s *StateDescriptor) EncodeBinary(w *io.BinWriter) {
|
||||
w.WriteByte(byte(s.Type))
|
||||
w.WriteB(byte(s.Type))
|
||||
w.WriteVarBytes(s.Key)
|
||||
w.WriteVarBytes(s.Value)
|
||||
w.WriteString(s.Field)
|
||||
|
|
|
@ -92,8 +92,8 @@ func (t *Transaction) AddInput(in *Input) {
|
|||
|
||||
// DecodeBinary implements Serializable interface.
|
||||
func (t *Transaction) DecodeBinary(br *io.BinReader) {
|
||||
t.Type = TXType(br.ReadByte())
|
||||
t.Version = uint8(br.ReadByte())
|
||||
t.Type = TXType(br.ReadB())
|
||||
t.Version = uint8(br.ReadB())
|
||||
t.decodeData(br)
|
||||
|
||||
br.ReadArray(&t.Attributes)
|
||||
|
@ -151,8 +151,8 @@ func (t *Transaction) EncodeBinary(bw *io.BinWriter) {
|
|||
// encodeHashableFields encodes the fields that are not used for
|
||||
// signing the transaction, which are all fields except the scripts.
|
||||
func (t *Transaction) encodeHashableFields(bw *io.BinWriter) {
|
||||
bw.WriteByte(byte(t.Type))
|
||||
bw.WriteByte(byte(t.Version))
|
||||
bw.WriteB(byte(t.Type))
|
||||
bw.WriteB(byte(t.Version))
|
||||
|
||||
// Underlying TXer.
|
||||
if t.Data != nil {
|
||||
|
|
|
@ -25,7 +25,7 @@ func NewUnspentCoinState(n int) *UnspentCoinState {
|
|||
func (s *UnspentCoinState) EncodeBinary(bw *io.BinWriter) {
|
||||
bw.WriteVarUint(uint64(len(s.states)))
|
||||
for _, state := range s.states {
|
||||
bw.WriteByte(byte(state))
|
||||
bw.WriteB(byte(state))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,6 @@ func (s *UnspentCoinState) DecodeBinary(br *io.BinReader) {
|
|||
lenStates := br.ReadVarUint()
|
||||
s.states = make([]state.Coin, lenStates)
|
||||
for i := 0; i < int(lenStates); i++ {
|
||||
s.states[i] = state.Coin(br.ReadByte())
|
||||
s.states[i] = state.Coin(br.ReadB())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ func (p *PublicKey) DecodeBinary(r *io.BinReader) {
|
|||
var x, y *big.Int
|
||||
var err error
|
||||
|
||||
prefix = uint8(r.ReadByte())
|
||||
prefix = uint8(r.ReadB())
|
||||
if r.Err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -87,9 +87,9 @@ func (r *BinReader) ReadU16BE() uint16 {
|
|||
return binary.BigEndian.Uint16(r.u16)
|
||||
}
|
||||
|
||||
// ReadByte reads a byte from the underlying io.Reader. On read failures it
|
||||
// ReadB reads a byte from the underlying io.Reader. On read failures it
|
||||
// returns zero.
|
||||
func (r *BinReader) ReadByte() byte {
|
||||
func (r *BinReader) ReadB() byte {
|
||||
r.ReadBytes(r.u8)
|
||||
if r.Err != nil {
|
||||
return 0
|
||||
|
@ -100,7 +100,7 @@ func (r *BinReader) ReadByte() byte {
|
|||
// ReadBool reads a boolean value encoded in a zero/non-zero byte from the
|
||||
// underlying io.Reader. On read failures it returns false.
|
||||
func (r *BinReader) ReadBool() bool {
|
||||
return r.ReadByte() != 0
|
||||
return r.ReadB() != 0
|
||||
}
|
||||
|
||||
// ReadArray reads array into value which must be
|
||||
|
@ -169,7 +169,7 @@ func (r *BinReader) ReadVarUint() uint64 {
|
|||
return 0
|
||||
}
|
||||
|
||||
var b = r.ReadByte()
|
||||
var b = r.ReadB()
|
||||
|
||||
if b == 0xfd {
|
||||
return uint64(r.ReadU16LE())
|
||||
|
|
|
@ -71,8 +71,8 @@ func (w *BinWriter) WriteU16BE(u16 uint16) {
|
|||
w.WriteBytes(w.u16)
|
||||
}
|
||||
|
||||
// WriteByte writes a byte into the underlying io.Writer.
|
||||
func (w *BinWriter) WriteByte(u8 byte) {
|
||||
// WriteB writes a byte into the underlying io.Writer.
|
||||
func (w *BinWriter) WriteB(u8 byte) {
|
||||
w.u8[0] = u8
|
||||
w.WriteBytes(w.u8)
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ func (w *BinWriter) WriteBool(b bool) {
|
|||
if b {
|
||||
i = 1
|
||||
}
|
||||
w.WriteByte(i)
|
||||
w.WriteB(i)
|
||||
}
|
||||
|
||||
// WriteArray writes a slice or an array arr into w. Note that nil slices and
|
||||
|
@ -123,22 +123,22 @@ func (w *BinWriter) WriteVarUint(val uint64) {
|
|||
}
|
||||
|
||||
if val < 0xfd {
|
||||
w.WriteByte(byte(val))
|
||||
w.WriteB(byte(val))
|
||||
return
|
||||
}
|
||||
if val < 0xFFFF {
|
||||
w.WriteByte(byte(0xfd))
|
||||
w.WriteB(byte(0xfd))
|
||||
w.WriteU16LE(uint16(val))
|
||||
return
|
||||
}
|
||||
if val < 0xFFFFFFFF {
|
||||
w.WriteByte(byte(0xfe))
|
||||
w.WriteB(byte(0xfe))
|
||||
w.WriteU32LE(uint32(val))
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
w.WriteByte(byte(0xff))
|
||||
w.WriteB(byte(0xff))
|
||||
w.WriteU64LE(val)
|
||||
}
|
||||
|
||||
|
|
|
@ -128,12 +128,12 @@ func TestWriteByte(t *testing.T) {
|
|||
bin = []byte{0xa5}
|
||||
)
|
||||
bw := NewBufBinWriter()
|
||||
bw.WriteByte(val)
|
||||
bw.WriteB(val)
|
||||
assert.Nil(t, bw.Err)
|
||||
wrotebin := bw.Bytes()
|
||||
assert.Equal(t, wrotebin, bin)
|
||||
br := NewBinReaderFromBuf(bin)
|
||||
readval = br.ReadByte()
|
||||
readval = br.ReadB()
|
||||
assert.Nil(t, br.Err)
|
||||
assert.Equal(t, val, readval)
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ func TestReadLEErrors(t *testing.T) {
|
|||
assert.Equal(t, uint32(0), br.ReadU32LE())
|
||||
assert.Equal(t, uint16(0), br.ReadU16LE())
|
||||
assert.Equal(t, uint16(0), br.ReadU16BE())
|
||||
assert.Equal(t, byte(0), br.ReadByte())
|
||||
assert.Equal(t, byte(0), br.ReadB())
|
||||
assert.Equal(t, false, br.ReadBool())
|
||||
assert.NotNil(t, br.Err)
|
||||
}
|
||||
|
|
|
@ -56,12 +56,12 @@ func NewInventory(typ InventoryType, hashes []util.Uint256) *Inventory {
|
|||
|
||||
// DecodeBinary implements Serializable interface.
|
||||
func (p *Inventory) DecodeBinary(br *io.BinReader) {
|
||||
p.Type = InventoryType(br.ReadByte())
|
||||
p.Type = InventoryType(br.ReadB())
|
||||
br.ReadArray(&p.Hashes)
|
||||
}
|
||||
|
||||
// EncodeBinary implements Serializable interface.
|
||||
func (p *Inventory) EncodeBinary(bw *io.BinWriter) {
|
||||
bw.WriteByte(byte(p.Type))
|
||||
bw.WriteB(byte(p.Type))
|
||||
bw.WriteArray(p.Hashes)
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ func TestCreateMultiSigRedeemScript(t *testing.T) {
|
|||
}
|
||||
|
||||
br := io.NewBinReaderFromBuf(out)
|
||||
assert.Equal(t, opcode.PUSH3, opcode.Opcode(br.ReadByte()))
|
||||
assert.Equal(t, opcode.PUSH3, opcode.Opcode(br.ReadB()))
|
||||
|
||||
for i := 0; i < len(validators); i++ {
|
||||
bb := br.ReadVarBytes()
|
||||
|
@ -32,6 +32,6 @@ func TestCreateMultiSigRedeemScript(t *testing.T) {
|
|||
assert.Equal(t, validators[i].Bytes(), bb)
|
||||
}
|
||||
|
||||
assert.Equal(t, opcode.PUSH3, opcode.Opcode(br.ReadByte()))
|
||||
assert.Equal(t, opcode.CHECKMULTISIG, opcode.Opcode(br.ReadByte()))
|
||||
assert.Equal(t, opcode.PUSH3, opcode.Opcode(br.ReadB()))
|
||||
assert.Equal(t, opcode.CHECKMULTISIG, opcode.Opcode(br.ReadB()))
|
||||
}
|
||||
|
|
|
@ -80,12 +80,12 @@ func (pt ParamType) MarshalJSON() ([]byte, error) {
|
|||
|
||||
// EncodeBinary implements io.Serializable interface.
|
||||
func (pt ParamType) EncodeBinary(w *io.BinWriter) {
|
||||
w.WriteByte(byte(pt))
|
||||
w.WriteB(byte(pt))
|
||||
}
|
||||
|
||||
// DecodeBinary implements io.Serializable interface.
|
||||
func (pt *ParamType) DecodeBinary(r *io.BinReader) {
|
||||
*pt = ParamType(r.ReadByte())
|
||||
*pt = ParamType(r.ReadB())
|
||||
}
|
||||
|
||||
// NewParameter returns a Parameter with proper initialized Value
|
||||
|
|
|
@ -50,14 +50,14 @@ func (c *Context) Next() (opcode.Opcode, []byte, error) {
|
|||
}
|
||||
r := io.NewBinReaderFromBuf(c.prog[c.ip:])
|
||||
|
||||
var instrbyte = r.ReadByte()
|
||||
var instrbyte = r.ReadB()
|
||||
instr := opcode.Opcode(instrbyte)
|
||||
c.nextip++
|
||||
|
||||
var numtoread int
|
||||
switch instr {
|
||||
case opcode.PUSHDATA1, opcode.SYSCALL:
|
||||
var n = r.ReadByte()
|
||||
var n = r.ReadB()
|
||||
numtoread = int(n)
|
||||
c.nextip++
|
||||
case opcode.PUSHDATA2:
|
||||
|
|
|
@ -94,7 +94,7 @@ func deserializeItem(data []byte) (StackItem, error) {
|
|||
// as a function because StackItem itself is an interface. Caveat: always check
|
||||
// reader's error value before using the returned StackItem.
|
||||
func DecodeBinaryStackItem(r *io.BinReader) StackItem {
|
||||
var t = r.ReadByte()
|
||||
var t = r.ReadB()
|
||||
if r.Err != nil {
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue