common

package
v0.8.4-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// supported max asset precision is 8
	MaximumPrecision = 8
	StorageFactor    = 100000000
)
View Source
const HEXADDRLEN = 1 + UINT160SIZE + SHA256CHKSUM // 1 for prefix char 53
View Source
const MaxUint32 = ^uint32(0)
View Source
const PREFIXCHAR = byte(53)
View Source
const SHA256CHKSUM = 4
View Source
const UINT160SIZE = 20
View Source
const UINT256SIZE = 32

Variables

This section is empty.

Functions

func AbsUint

func AbsUint(n1 uint, n2 uint) uint

func BytesReverse

func BytesReverse(u []byte) []byte

func BytesToHexString

func BytesToHexString(data []byte) string

func BytesToInt

func BytesToInt(b []byte) []int

func BytesToInt16

func BytesToInt16(b []byte) int16

func ClearBytes

func ClearBytes(arr []byte, len int)

func CompareHeight

func CompareHeight(blockHeight uint32, heights []uint32) bool

func FileExisted

func FileExisted(filename string) bool

func GetCompactUint

func GetCompactUint(buf []byte) (uint64, uint8)

func GetNonce

func GetNonce() uint64

func GetUint16Array

func GetUint16Array(source []byte) ([]uint16, error)

func HexStringToBytes

func HexStringToBytes(value string) ([]byte, error)

func HexStringToBytesReverse

func HexStringToBytesReverse(value string) ([]byte, error)

func IntToBytes

func IntToBytes(n int) []byte

func IsEqualBytes

func IsEqualBytes(b1 []byte, b2 []byte) bool

func IsValidHexAddr

func IsValidHexAddr(s []byte) bool

func SetCompactUint

func SetCompactUint(num uint64) []byte

TODO Fix the return value to the correct number

func SliceRemove

func SliceRemove(slice []uint32, h uint32) []uint32

func ToArrayReverse

func ToArrayReverse(arr []byte) []byte

func ToByteArray

func ToByteArray(source []uint16) []byte

Types

type Cache

type Cache interface {
	Add([]byte, interface{}) error
	Get([]byte) (interface{}, bool)
	Set([]byte, interface{}) error
}

Cache is an anstract cache layer

type CompactUint

type CompactUint struct {
	// contains filtered or unexported fields
}

type Fixed64

type Fixed64 int64

the 64 bit fixed-point number, precise 10^-8

func StringToFixed64

func StringToFixed64(s string) (Fixed64, error)

func (*Fixed64) Deserialize

func (f *Fixed64) Deserialize(r io.Reader) error

func (Fixed64) GetData

func (f Fixed64) GetData() int64

func (*Fixed64) Serialize

func (f *Fixed64) Serialize(w io.Writer) error

func (Fixed64) String

func (f Fixed64) String() string

type GoCache

type GoCache struct {
	// contains filtered or unexported fields
}

GoCache is the caching layer implemented by go-cache.

func NewGoCache

func NewGoCache(defaultExpiration, cleanupInterval time.Duration) *GoCache

NewGoCache creates a go-cache cache with a given default expiration duration and cleanup interval.

func (*GoCache) Add

func (gc *GoCache) Add(key []byte, value interface{}) error

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) Get

func (gc *GoCache) Get(key []byte) (interface{}, bool)

Get gets an item from the cache. Returns the item or nil, and a bool indicating whether the key was found.

func (*GoCache) Set

func (gc *GoCache) Set(key []byte, value interface{}) error

Set adds an item to the cache, replacing any existing item, using the default expiration.

type Inventory

type Inventory interface {
	//sig.SignableData
	Hash() Uint256
	Verify() error
	Type() InventoryType
}

TODO: temp inventory

type InventoryType

type InventoryType byte
const (
	TRANSACTION InventoryType = 0x01
	BLOCK       InventoryType = 0x02
)

type Uint160

type Uint160 [UINT160SIZE]uint8
var EmptyUint160 Uint160

func BigToUint160

func BigToUint160(b *big.Int) Uint160

func BytesToUint160

func BytesToUint160(b []byte) Uint160

func ToCodeHash

func ToCodeHash(code []byte) (Uint160, error)

func ToScriptHash

func ToScriptHash(address string) (Uint160, error)

func Uint160ParseFromBytes

func Uint160ParseFromBytes(f []byte) (Uint160, error)

func (*Uint160) Big

func (u *Uint160) Big() *big.Int

func (*Uint160) CompareTo

func (u *Uint160) CompareTo(o Uint160) int

func (*Uint160) Deserialize

func (f *Uint160) Deserialize(r io.Reader) error

func (*Uint160) Serialize

func (u *Uint160) Serialize(w io.Writer) (int, error)

func (*Uint160) SetBytes

func (u *Uint160) SetBytes(b []byte)

func (*Uint160) ToAddress

func (f *Uint160) ToAddress() (string, error)

func (*Uint160) ToArray

func (u *Uint160) ToArray() []byte

func (*Uint160) ToArrayReverse

func (u *Uint160) ToArrayReverse() []byte

type Uint256

type Uint256 [UINT256SIZE]uint8
var EmptyUint256 Uint256

func Uint256ParseFromBytes

func Uint256ParseFromBytes(f []byte) (hash Uint256, err error)

func (*Uint256) CompareTo

func (u *Uint256) CompareTo(o Uint256) int

func (*Uint256) Deserialize

func (u *Uint256) Deserialize(r io.Reader) error

func (*Uint256) Serialize

func (u *Uint256) Serialize(w io.Writer) (int, error)

func (*Uint256) ToArray

func (u *Uint256) ToArray() []byte

func (*Uint256) ToArrayReverse

func (u *Uint256) ToArrayReverse() []byte

func (*Uint256) ToHexString

func (u *Uint256) ToHexString() string

func (*Uint256) ToString

func (u *Uint256) ToString() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL