github.com/annchain/OG@v0.0.9/og_interface/type_interface.go (about) 1 package og_interface 2 3 import ( 4 "github.com/annchain/commongo/hexutil" 5 "github.com/annchain/commongo/marshaller" 6 ) 7 8 type FixLengthBytes interface { 9 Length() int 10 FromBytes(b []byte) 11 FromHex(s string) error 12 FromHexNoError(s string) 13 Bytes() []byte 14 Hex() string 15 Cmp(FixLengthBytes) int 16 } 17 18 type Address interface { 19 FixLengthBytes 20 AddressKey() AddressKey 21 AddressString() string // just for type safety between Address and Hash 22 AddressShortString() string 23 24 marshaller.IMarshaller 25 } 26 27 type AddressKey string 28 29 func (k AddressKey) Bytes() []byte { 30 b, _ := hexutil.FromHex(string(k)) 31 return b 32 } 33 34 type Hash interface { 35 FixLengthBytes 36 HashKey() HashKey 37 HashString() string 38 HashShortString() string 39 40 marshaller.IMarshaller 41 } 42 43 type HashKey string 44 45 func (k HashKey) Bytes() []byte { 46 b, _ := hexutil.FromHex(string(k)) 47 return b 48 }