mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-25 23:42:23 +00:00
*: 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:
parent
7e371588a7
commit
5b6c5af704
5 changed files with 6 additions and 5 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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[:])
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue