mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-27 13:58:05 +00:00
54d888ba70
This seriously improves the serialization/deserialization performance for several reasons: * no time spent in `binary` reflection * no memory allocations being made on every read/write * uses fast ReadBytes everywhere it's appropriate It also makes Fixed8 Serializable just for convenience.
23 lines
512 B
Go
23 lines
512 B
Go
package state
|
|
|
|
import (
|
|
"github.com/CityOfZion/neo-go/pkg/io"
|
|
)
|
|
|
|
// StorageItem is the value to be stored with read-only flag.
|
|
type StorageItem struct {
|
|
Value []byte
|
|
IsConst bool
|
|
}
|
|
|
|
// EncodeBinary implements Serializable interface.
|
|
func (si *StorageItem) EncodeBinary(w *io.BinWriter) {
|
|
w.WriteVarBytes(si.Value)
|
|
w.WriteBool(si.IsConst)
|
|
}
|
|
|
|
// DecodeBinary implements Serializable interface.
|
|
func (si *StorageItem) DecodeBinary(r *io.BinReader) {
|
|
si.Value = r.ReadVarBytes()
|
|
si.IsConst = r.ReadBool()
|
|
}
|