Documentation ¶
Index ¶
- Constants
- Variables
- func AbsUint(n1 uint, n2 uint) uint
- func BytesToHexString(data []byte) string
- func BytesToInt(b []byte) []int
- func BytesToInt16(b []byte) int16
- func ClearBytes(arr []byte, len int)
- func CompareHeight(blockHeight uint32, heights []uint32) bool
- func FileExisted(filename string) bool
- func GetUint16Array(source []byte) ([]uint16, error)
- func HexStringToBytes(value string) ([]byte, error)
- func IntToBytes(n int) []byte
- func IsValidHexAddr(s []byte) bool
- func SliceRemove(slice []uint32, h uint32) []uint32
- func ToByteArray(source []uint16) []byte
- type Cache
- type Fixed64
- type GoCache
- func (gc *GoCache) Add(key []byte, value interface{}) error
- func (gc *GoCache) Delete(key []byte) error
- func (gc *GoCache) Get(key []byte) (interface{}, bool)
- func (gc *GoCache) Set(key []byte, value interface{}) error
- func (gc *GoCache) SetWithExpiration(key []byte, value interface{}, expiration time.Duration) error
- type HexStr
- type Uint160
- func (u *Uint160) Big() *big.Int
- func (u *Uint160) CompareTo(o Uint160) int
- func (f *Uint160) Deserialize(r io.Reader) error
- func (f Uint160) MarshalJSON() ([]byte, error)
- func (u *Uint160) Serialize(w io.Writer) (int, error)
- func (u *Uint160) SetBytes(b []byte) *Uint160
- func (f *Uint160) ToAddress() (string, error)
- func (u *Uint160) ToArray() []byte
- func (u *Uint160) ToHexString() string
- type Uint256
Constants ¶
const ( // supported max asset precision is 8 MaximumPrecision = 8 StorageFactor = 100000000 )
const FOOLPROOFPREFIX = 0x02b824 + 1 // +1 for avoid affected by lower 192bits shift-add
FOOLPROOFPREFIX used for fool-proof prefix base58.BitcoinEncoding[21] = 'N', base58.BitcoinEncoding[18] = 'K' 33 = len(base58.Encode( (2**192).Bytes() )), 192 = 8bit * (UINT160SIZE + SHA256CHKSUM) ((21 * 58**35) + (18 * 58**34) + (21 * 58**33)) >> 192 = 0x02b824
const HEXADDRLEN = PREFIXLEN + UINT160SIZE + SHA256CHKSUM
const PREFIXLEN = 3
PREFIXLEN = len( 0x02b825.Bytes() )
const SHA256CHKSUM = 4
const UINT160SIZE = 20
const UINT256SIZE = 32
Variables ¶
var MaxUint256 = Uint256{
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
}
Functions ¶
func BytesToHexString ¶
func BytesToInt ¶
func BytesToInt16 ¶
func ClearBytes ¶
func CompareHeight ¶
func FileExisted ¶
func GetUint16Array ¶
func HexStringToBytes ¶
func IntToBytes ¶
func IsValidHexAddr ¶
func SliceRemove ¶
func ToByteArray ¶
Types ¶
type Cache ¶
type Cache interface { Add(key []byte, value interface{}) error Get(key []byte) (value interface{}, ok bool) Set(key []byte, value interface{}) error SetWithExpiration(key []byte, value interface{}, expiration time.Duration) error Delete(key []byte) error }
Cache is an anstract cache layer
type Fixed64 ¶
type Fixed64 int64
the 64 bit fixed-point number, precise 10^-8
func StringToFixed64 ¶
type GoCache ¶
GoCache is the caching layer implemented by go-cache.
func NewGoCache ¶
NewGoCache creates a go-cache cache with a given default expiration duration and cleanup interval.
func (*GoCache) Add ¶
Add adds an item to the cache only if an item doesn't already exist for the given key, or if the existing item has expired. Returns an error otherwise.
func (*GoCache) Delete ¶
Delete deletes an item from the cache. Does nothing if the key is not in the cache.
func (*GoCache) Get ¶
Get gets an item from the cache. Returns the item or nil, and a bool indicating whether the key was found.
type Uint160 ¶
type Uint160 [UINT160SIZE]uint8
var EmptyUint160 Uint160
func BigToUint160 ¶
func BytesToUint160 ¶
func ToCodeHash ¶
func ToScriptHash ¶
func Uint160ParseFromBytes ¶
func (Uint160) MarshalJSON ¶
func (*Uint160) ToHexString ¶
type Uint256 ¶
type Uint256 [UINT256SIZE]uint8
var EmptyUint256 Uint256