Documentation ¶
Index ¶
- Constants
- Variables
- func AbsUint(n1 uint, n2 uint) uint
- func BytesToInt(b []byte) []int
- func BytesToInt16(b []byte) int16
- func ClearBytes(b []byte)
- func CompareHeight(blockHeight uint32, heights []uint32) bool
- func FileExisted(filename string) bool
- func GetUint16Array(source []byte) ([]uint16, error)
- func IntToBytes(n int) []byte
- func IsValidHexAddr(s []byte) bool
- func SliceRemove(slice []uint32, h uint32) []uint32
- func ToByteArray(source []uint16) []byte
- func U256Equal(a, b Uint256) bool
- 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 PriorityQueue
- 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 = 0x031FC8 + 1 // +1 for avoid affected by lower 192bits shift-add
const HEXADDRLEN = PREFIXLEN + UINT160SIZE + SHA256CHKSUM
const PREFIXLEN = 3
PREFIXLEN = len( 0x031FC8.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 BytesToInt ¶
func BytesToInt16 ¶
func ClearBytes ¶
func ClearBytes(b []byte)
func CompareHeight ¶
func FileExisted ¶
func GetUint16Array ¶
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 PriorityQueue ¶
type PriorityQueue struct {
// contains filtered or unexported fields
}
PriorityQueue represents the queue
func (*PriorityQueue) Empty ¶
func (p *PriorityQueue) Empty() bool
func (*PriorityQueue) Len ¶
func (p *PriorityQueue) Len() int
Len returns the number of elements in the queue.
func (*PriorityQueue) Pop ¶
func (p *PriorityQueue) Pop() (interface{}, int64)
Pop removes the element with the highest priority from the queue and returns it.
func (*PriorityQueue) Push ¶
func (p *PriorityQueue) Push(v interface{}, priority int64)
Push insert a new element into the queue. No action is performed on duplicate elements.
func (*PriorityQueue) UpdatePriority ¶
func (p *PriorityQueue) UpdatePriority(x interface{}, newPriority int64)
UpdatePriority changes the priority of a given item. If the specified item is not present in the queue, no action is performed.
type Uint160 ¶
type Uint160 [UINT160SIZE]uint8
var EmptyUint160 Uint160
func BigToUint160 ¶
func BytesToUint160 ¶
func ToCodeHash ¶
func ToScriptHash ¶
func Uint160ParseFromBytes ¶
Uint160ParseFromBytes create an Uint160 from f slice
func (Uint160) MarshalJSON ¶
func (*Uint160) SetBytes ¶
SetBytes u itself with b slice. 1. Drop high-order bytes if b overflow 160bits 2. Keep leading zero if b not enough 160bits
func (*Uint160) ToHexString ¶
type Uint256 ¶
type Uint256 [UINT256SIZE]uint8
var EmptyUint256 Uint256