*: implement EncodeBinary with pointer receivers where appropriate

Everywhere except ParamType (which is just a byte), reduce copying things
around for no real reason.
This commit is contained in:
Roman Khimov 2019-12-09 18:25:15 +03:00
parent 7e371588a7
commit 5b6c5af704
5 changed files with 6 additions and 5 deletions

View file

@ -160,7 +160,7 @@ func (p *Payload) SetHeight(h uint32) {
}
// EncodeBinaryUnsigned writes payload to w excluding signature.
func (p Payload) EncodeBinaryUnsigned(w *io.BinWriter) {
func (p *Payload) EncodeBinaryUnsigned(w *io.BinWriter) {
w.WriteLE(p.version)
w.WriteBytes(p.prevHash[:])
w.WriteLE(p.height)

View file

@ -140,7 +140,7 @@ func (u *UnspentBalance) DecodeBinary(r *io.BinReader) {
}
// EncodeBinary implements io.Serializable interface.
func (u UnspentBalance) EncodeBinary(w *io.BinWriter) {
func (u *UnspentBalance) EncodeBinary(w *io.BinWriter) {
u.Tx.EncodeBinary(w)
w.WriteLE(u.Index)
w.WriteLE(u.Value)

View file

@ -115,7 +115,8 @@ func (b *Block) Trim() ([]byte, error) {
buf.WriteVarUint(uint64(len(b.Transactions)))
for _, tx := range b.Transactions {
tx.Hash().EncodeBinary(buf.BinWriter)
h := tx.Hash()
h.EncodeBinary(buf.BinWriter)
}
if buf.Err != nil {
return nil, buf.Err

View file

@ -56,7 +56,7 @@ func getAppExecResultFromStore(s storage.Store, hash util.Uint256) (*AppExecResu
}
// EncodeBinary implements the Serializable interface.
func (ne NotificationEvent) EncodeBinary(w *io.BinWriter) {
func (ne *NotificationEvent) EncodeBinary(w *io.BinWriter) {
w.WriteBytes(ne.ScriptHash[:])
vm.EncodeBinaryStackItem(ne.Item, w)
}

View file

@ -117,7 +117,7 @@ func (u Uint256) MarshalJSON() ([]byte, error) {
func (u Uint256) CompareTo(other Uint256) int { return bytes.Compare(u[:], other[:]) }
// EncodeBinary implements io.Serializable interface.
func (u Uint256) EncodeBinary(w *io.BinWriter) {
func (u *Uint256) EncodeBinary(w *io.BinWriter) {
w.WriteBytes(u[:])
}