util: implement io.Serializable for Uint256

This commit is contained in:
Evgenii Stratonikov 2019-11-14 11:07:23 +03:00
parent b16e56a47b
commit 2be18f91df
9 changed files with 48 additions and 54 deletions

View file

@ -6,6 +6,8 @@ import (
"encoding/json"
"fmt"
"strings"
"github.com/CityOfZion/neo-go/pkg/io"
)
// Uint256Size is the size of Uint256 in bytes.
@ -93,3 +95,13 @@ func (u Uint256) MarshalJSON() ([]byte, error) {
// -1 implies u < other.
// 0 implies u = other.
func (u Uint256) CompareTo(other Uint256) int { return bytes.Compare(u[:], other[:]) }
// EncodeBinary implements io.Serializable interface.
func (u Uint256) EncodeBinary(w *io.BinWriter) {
w.WriteBE(u)
}
// DecodeBinary implements io.Serializable interface.
func (u *Uint256) DecodeBinary(r *io.BinReader) {
r.ReadBE(u[:])
}