@@ -24,45 +24,81 @@ type UnmarshalerBinary interface {
2424}
2525
2626var TypeSize = struct {
27- Byte int
28- Int8 int
29- UInt8 int
30- UInt16 int
31- Int16 int
32- UInt32 int
33- UInt64 int
34- UInt128 int
35- Float32 int
36- Float64 int
37- Checksum160 int
38- Checksum256 int
39- Checksum512 int
40- PublicKey int
41- Signature int
27+ Bool int
28+ Byte int
29+
30+ Int8 int
31+ Int16 int
32+
33+ Uint8 int
34+ Uint16 int
35+ Uint32 int
36+ Uint64 int
37+ Uint128 int
38+
39+ Float32 int
40+ Float64 int
41+
42+ Checksum160 int
43+ Checksum256 int
44+ Checksum512 int
45+
46+ PublicKey int
47+ Signature int
48+
4249 Tstamp int
4350 BlockTimestamp int
44- CurrencyName int
45- Bool int
51+
52+ CurrencyName int
53+
54+ // Deprecated Fields
55+
56+ // Deprecated: use Uint8 instead
57+ UInt8 int
58+ // Deprecated: use Uint16 instead
59+ UInt16 int
60+ // Deprecated: use Uint32 instead
61+ UInt32 int
62+ // Deprecated: use Uint64 instead
63+ UInt64 int
64+ // Deprecated: use Uint128 instead
65+ UInt128 int
4666}{
47- Byte : 1 ,
48- Int8 : 1 ,
49- UInt8 : 1 ,
50- UInt16 : 2 ,
51- Int16 : 2 ,
52- UInt32 : 4 ,
53- UInt64 : 8 ,
54- UInt128 : 16 ,
55- Float32 : 4 ,
56- Float64 : 8 ,
57- Checksum160 : 20 ,
58- Checksum256 : 32 ,
59- Checksum512 : 64 ,
60- PublicKey : 34 ,
61- Signature : 66 ,
67+ Byte : 1 ,
68+ Bool : 1 ,
69+
70+ Int8 : 1 ,
71+ Int16 : 2 ,
72+
73+ Uint8 : 1 ,
74+ Uint16 : 2 ,
75+ Uint32 : 4 ,
76+ Uint64 : 8 ,
77+ Uint128 : 16 ,
78+
79+ Float32 : 4 ,
80+ Float64 : 8 ,
81+
82+ Checksum160 : 20 ,
83+ Checksum256 : 32 ,
84+ Checksum512 : 64 ,
85+
86+ PublicKey : 34 ,
87+ Signature : 66 ,
88+
6289 Tstamp : 8 ,
6390 BlockTimestamp : 4 ,
64- CurrencyName : 7 ,
65- Bool : 1 ,
91+
92+ CurrencyName : 7 ,
93+ }
94+
95+ func init () {
96+ // Deprecated fields initialization
97+ TypeSize .UInt8 = TypeSize .Uint8
98+ TypeSize .UInt16 = TypeSize .Uint16
99+ TypeSize .UInt32 = TypeSize .Uint32
100+ TypeSize .UInt64 = TypeSize .Uint64
101+ TypeSize .UInt128 = TypeSize .Uint128
66102}
67103
68104var RegisteredActions = map [AccountName ]map [ActionName ]reflect.Type {}
@@ -592,10 +628,16 @@ func (d *Decoder) ReadBool() (out bool, err error) {
592628
593629}
594630
595- func (d * Decoder ) ReadUInt8 () (out uint8 , err error ) {
631+ func (d * Decoder ) ReadUint8 () (out uint8 , err error ) {
596632 out , err = d .ReadByte ()
597633 return
598634}
635+
636+ // Deprecated: Use `ReadUint8` (with a lower case `i`) instead
637+ func (d * Decoder ) ReadUInt8 () (out uint8 , err error ) {
638+ return d .ReadUint8 ()
639+ }
640+
599641func (d * Decoder ) ReadInt8 () (out int8 , err error ) {
600642 b , err := d .ReadByte ()
601643 out = int8 (b )
@@ -606,13 +648,13 @@ func (d *Decoder) ReadInt8() (out int8, err error) {
606648}
607649
608650func (d * Decoder ) ReadUint16 () (out uint16 , err error ) {
609- if d .remaining () < TypeSize .UInt16 {
610- err = fmt .Errorf ("uint16 required [%d] bytes, remaining [%d]" , TypeSize .UInt16 , d .remaining ())
651+ if d .remaining () < TypeSize .Uint16 {
652+ err = fmt .Errorf ("uint16 required [%d] bytes, remaining [%d]" , TypeSize .Uint16 , d .remaining ())
611653 return
612654 }
613655
614656 out = binary .LittleEndian .Uint16 (d .data [d .pos :])
615- d .pos += TypeSize .UInt16
657+ d .pos += TypeSize .Uint16
616658 if loggingEnabled {
617659 decoderLog .Debug ("read uint16" , zap .Uint16 ("val" , out ))
618660 }
@@ -637,13 +679,13 @@ func (d *Decoder) ReadInt64() (out int64, err error) {
637679}
638680
639681func (d * Decoder ) ReadUint32 () (out uint32 , err error ) {
640- if d .remaining () < TypeSize .UInt32 {
641- err = fmt .Errorf ("uint32 required [%d] bytes, remaining [%d]" , TypeSize .UInt32 , d .remaining ())
682+ if d .remaining () < TypeSize .Uint32 {
683+ err = fmt .Errorf ("uint32 required [%d] bytes, remaining [%d]" , TypeSize .Uint32 , d .remaining ())
642684 return
643685 }
644686
645687 out = binary .LittleEndian .Uint32 (d .data [d .pos :])
646- d .pos += TypeSize .UInt32
688+ d .pos += TypeSize .Uint32
647689 if loggingEnabled {
648690 decoderLog .Debug ("read uint32" , zap .Uint32 ("val" , out ))
649691 }
@@ -659,31 +701,31 @@ func (d *Decoder) ReadInt32() (out int32, err error) {
659701}
660702
661703func (d * Decoder ) ReadUint64 () (out uint64 , err error ) {
662- if d .remaining () < TypeSize .UInt64 {
663- err = fmt .Errorf ("uint64 required [%d] bytes, remaining [%d]" , TypeSize .UInt64 , d .remaining ())
704+ if d .remaining () < TypeSize .Uint64 {
705+ err = fmt .Errorf ("uint64 required [%d] bytes, remaining [%d]" , TypeSize .Uint64 , d .remaining ())
664706 return
665707 }
666708
667- data := d .data [d .pos : d .pos + TypeSize .UInt64 ]
709+ data := d .data [d .pos : d .pos + TypeSize .Uint64 ]
668710 out = binary .LittleEndian .Uint64 (data )
669- d .pos += TypeSize .UInt64
711+ d .pos += TypeSize .Uint64
670712 if loggingEnabled {
671713 decoderLog .Debug ("read uint64" , zap .Uint64 ("val" , out ), zap .Stringer ("hex" , HexBytes (data )))
672714 }
673715 return
674716}
675717
676718func (d * Decoder ) ReadUint128 (typeName string ) (out Uint128 , err error ) {
677- if d .remaining () < TypeSize .UInt128 {
678- err = fmt .Errorf ("%s required [%d] bytes, remaining [%d]" , typeName , TypeSize .UInt128 , d .remaining ())
719+ if d .remaining () < TypeSize .Uint128 {
720+ err = fmt .Errorf ("%s required [%d] bytes, remaining [%d]" , typeName , TypeSize .Uint128 , d .remaining ())
679721 return
680722 }
681723
682- data := d .data [d .pos : d .pos + TypeSize .UInt128 ]
724+ data := d .data [d .pos : d .pos + TypeSize .Uint128 ]
683725 out .Lo = binary .LittleEndian .Uint64 (data )
684726 out .Hi = binary .LittleEndian .Uint64 (data [8 :])
685727
686- d .pos += TypeSize .UInt128
728+ d .pos += TypeSize .Uint128
687729 if loggingEnabled {
688730 decoderLog .Debug ("read uint128" , zap .Stringer ("hex" , out ), zap .Uint64 ("lo" , out .Lo ), zap .Uint64 ("lo" , out .Lo ))
689731 }
@@ -775,7 +817,7 @@ func (d *Decoder) ReadChecksum512() (out Checksum512, err error) {
775817}
776818
777819func (d * Decoder ) ReadPublicKey () (out ecc.PublicKey , err error ) {
778- typeID , err := d .ReadUInt8 ()
820+ typeID , err := d .ReadUint8 ()
779821 if err != nil {
780822 return out , fmt .Errorf ("unable to read public key type: %s" , err )
781823 }
@@ -850,7 +892,7 @@ func (d *Decoder) readWAPublicKeyMaterial() (out []byte, err error) {
850892}
851893
852894func (d * Decoder ) ReadSignature () (out ecc.Signature , err error ) {
853- typeID , err := d .ReadUInt8 ()
895+ typeID , err := d .ReadUint8 ()
854896 if err != nil {
855897 return out , fmt .Errorf ("unable to read signature type: %s" , err )
856898 }
0 commit comments