types

package
v2.2.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2019 License: GPL-3.0 Imports: 11 Imported by: 168

Documentation

Index

Constants

View Source
const (
	AddressPrefix   = "vite_"
	AddressSize     = 21
	AddressCoreSize = 20
)
View Source
const (
	UserAddrByte     = byte(0)
	ContractAddrByte = byte(1)
)
View Source
const (
	Unkonwn         BlockSource = 0
	RemoteBroadcast             = 10
	RemoteFetch                 = 20
	Local                       = 30
	RollbackChain               = 40
	QueryChain                  = 41
	RemoteSync                  = 50
	RemoteCache                 = 60
)
View Source
const (
	TokenTypeIdPrefix = "tti_"
	TokenTypeIdSize   = 10
)
View Source
const (
	GidSize = 10
)
View Source
const (
	HashSize = 32
)

Variables

View Source
var (
	AddressPledge, _         = BytesToAddress([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, ContractAddrByte})
	AddressConsensusGroup, _ = BytesToAddress([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, ContractAddrByte})
	AddressMintage, _        = BytesToAddress([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, ContractAddrByte})

	BuiltinContractAddrList             = []Address{AddressPledge, AddressConsensusGroup, AddressMintage}
	BuiltinContractWithoutQuotaAddrList = []Address{AddressPledge, AddressConsensusGroup, AddressMintage}
	BuiltinContractWithSendConfirm      = []Address{AddressPledge, AddressConsensusGroup, AddressMintage}
)
View Source
var (
	PRIVATE_GID  = Gid{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
	SNAPSHOT_GID = Gid{0, 0, 0, 0, 0, 0, 0, 0, 0, 1}
	DELEGATE_GID = Gid{0, 0, 0, 0, 0, 0, 0, 0, 0, 2}
)
View Source
var EmptyHeight = uint64(0)
View Source
var (
	ErrJsonNotString = errors.New("not valid string")
)
View Source
var GenesisHeight = uint64(1)
View Source
var ZERO_ADDRESS = Address{}
View Source
var ZERO_HASH = Hash{}
View Source
var ZERO_TOKENID = TokenTypeId{}

Functions

func IsBuiltinContractAddr

func IsBuiltinContractAddr(addr Address) bool

func IsBuiltinContractAddrInUse

func IsBuiltinContractAddrInUse(addr Address) bool

func IsBuiltinContractAddrInUseWithSendConfirm

func IsBuiltinContractAddrInUseWithSendConfirm(addr Address) bool

func IsBuiltinContractAddrInUseWithoutQuota

func IsBuiltinContractAddrInUseWithoutQuota(addr Address) bool

func IsContractAddr

func IsContractAddr(addr Address) bool

func IsValidHexAddress

func IsValidHexAddress(hexStr string) bool

func IsValidHexTokenTypeId

func IsValidHexTokenTypeId(hexStr string) bool

Types

type Address

type Address [AddressSize]byte

func BigToAddress added in v1.2.0

func BigToAddress(b *big.Int) (Address, error)

func BytesToAddress

func BytesToAddress(b []byte) (Address, error)

func CreateAddress

func CreateAddress() (Address, ed25519.PrivateKey, error)

func CreateAddressWithDeterministic

func CreateAddressWithDeterministic(d [32]byte) (Address, ed25519.PrivateKey, error)

func CreateContractAddress

func CreateContractAddress(data ...[]byte) Address

func GenContractAddress

func GenContractAddress(data []byte) (Address, error)

func GenUserAddress

func GenUserAddress(data []byte) (Address, error)

func HexToAddress

func HexToAddress(hexStr string) (Address, error)

func HexToAddressPanic

func HexToAddressPanic(hexstr string) Address

func PrikeyToAddress

func PrikeyToAddress(key ed25519.PrivateKey) Address

func PubkeyToAddress

func PubkeyToAddress(pubkey []byte) Address

func ValidHexAddress

func ValidHexAddress(hexStr string) (Address, error)

func (Address) Bytes

func (addr Address) Bytes() []byte

func (Address) Hex

func (addr Address) Hex() string

func (Address) MarshalText

func (a Address) MarshalText() ([]byte, error)

func (*Address) SetBytes

func (addr *Address) SetBytes(b []byte) error

func (Address) String

func (addr Address) String() string

func (*Address) UnmarshalJSON

func (a *Address) UnmarshalJSON(input []byte) error

func (*Address) UnmarshalText

func (a *Address) UnmarshalText(input []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type BlockSource

type BlockSource uint16

type ConsensusGroupInfo

type ConsensusGroupInfo struct {
	Gid                    Gid         // Consensus group id
	NodeCount              uint8       // Active miner count
	Interval               int64       // Timestamp gap between two continuous block
	PerCount               int64       // Continuous block generation interval count
	RandCount              uint8       // Random miner count
	RandRank               uint8       // Chose random miner with chain rank limit of vote
	Repeat                 uint16      // reuse consensus info to produce blocks within repeat times
	CheckLevel             uint8       // consensus check param, 0-check address and sequence, 1-check address only
	CountingTokenId        TokenTypeId // Token id for selecting miner through vote
	RegisterConditionId    uint8
	RegisterConditionParam []byte
	VoteConditionId        uint8
	VoteConditionParam     []byte
	Owner                  Address
	PledgeAmount           *big.Int
	WithdrawHeight         uint64
}

func (*ConsensusGroupInfo) IsActive

func (groupInfo *ConsensusGroupInfo) IsActive() bool

type GetError

type GetError struct {
	Code int
	Err  error
}

func (GetError) Error

func (getErr GetError) Error() string

type Gid

type Gid [GidSize]byte

func BigToGid

func BigToGid(data *big.Int) (Gid, error)

func BytesToGid

func BytesToGid(b []byte) (Gid, error)

func DataToGid

func DataToGid(data ...[]byte) Gid

func HexToGid

func HexToGid(hexStr string) (Gid, error)

func (*Gid) Bytes

func (gid *Gid) Bytes() []byte

func (Gid) Hex

func (gid Gid) Hex() string

func (Gid) MarshalText

func (gid Gid) MarshalText() ([]byte, error)

func (*Gid) SetBytes

func (gid *Gid) SetBytes(b []byte) error

func (Gid) String

func (gid Gid) String() string

func (*Gid) UnmarshalJSON

func (gid *Gid) UnmarshalJSON(input []byte) error

type Hash

type Hash [HashSize]byte

func BigToHash

func BigToHash(b *big.Int) (Hash, error)

func BytesToHash

func BytesToHash(b []byte) (Hash, error)

func DataHash

func DataHash(data []byte) Hash

func DataListHash

func DataListHash(data ...[]byte) Hash

func HexToHash

func HexToHash(hexstr string) (Hash, error)

func HexToHashPanic added in v1.3.0

func HexToHashPanic(hexstr string) Hash

func (Hash) Big

func (h Hash) Big() *big.Int

func (Hash) Bytes

func (h Hash) Bytes() []byte

func (Hash) Hex

func (h Hash) Hex() string

func (Hash) IsZero

func (h Hash) IsZero() bool

func (Hash) MarshalText

func (h Hash) MarshalText() ([]byte, error)

func (*Hash) SetBytes

func (h *Hash) SetBytes(b []byte) error

func (Hash) String

func (h Hash) String() string

func (*Hash) UnmarshalJSON

func (h *Hash) UnmarshalJSON(input []byte) error

type Quota

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

func NewQuota

func NewQuota(pledgeQuota, current, avg, snapshotCurrent uint64, blocked bool) Quota

func (*Quota) Avg

func (q *Quota) Avg() uint64

func (*Quota) Blocked

func (q *Quota) Blocked() bool

func (*Quota) Current

func (q *Quota) Current() uint64

Current quota of a single account

func (*Quota) PledgeQuotaPerSnapshotBlock

func (q *Quota) PledgeQuotaPerSnapshotBlock() uint64

func (*Quota) SnapshotCurrent

func (q *Quota) SnapshotCurrent() uint64

Available quota in current snapshot block, excluding unconfirmed blocks

type QuotaInfo

type QuotaInfo struct {
	BlockCount     uint64
	QuotaTotal     uint64
	QuotaUsedTotal uint64
}

type Registration

type Registration struct {
	Name           string
	NodeAddr       Address
	PledgeAddr     Address
	Amount         *big.Int
	WithdrawHeight uint64
	RewardTime     int64
	CancelTime     int64
	HisAddrList    []Address
}

func (*Registration) IsActive

func (r *Registration) IsActive() bool

type TokenInfo

type TokenInfo struct {
	TokenName     string   `json:"tokenName"`
	TokenSymbol   string   `json:"tokenSymbol"`
	TotalSupply   *big.Int `json:"totalSupply"`
	Decimals      uint8    `json:"decimals"`
	Owner         Address  `json:"owner"`
	MaxSupply     *big.Int `json:"maxSupply"`
	OwnerBurnOnly bool     `json:"ownerBurnOnly"`
	IsReIssuable  bool     `json:"isReIssuable"`
	Index         uint16   `json:"index"`
}

type TokenTypeId

type TokenTypeId [TokenTypeIdSize]byte

func BigToTokenTypeId added in v1.2.0

func BigToTokenTypeId(b *big.Int) (TokenTypeId, error)

func BytesToTokenTypeId

func BytesToTokenTypeId(b []byte) (TokenTypeId, error)

func CreateTokenTypeId

func CreateTokenTypeId(data ...[]byte) TokenTypeId

func HexToTokenTypeId

func HexToTokenTypeId(hexStr string) (TokenTypeId, error)

func (TokenTypeId) Bytes

func (tid TokenTypeId) Bytes() []byte

func (TokenTypeId) Hex

func (tid TokenTypeId) Hex() string

func (TokenTypeId) MarshalText

func (tid TokenTypeId) MarshalText() ([]byte, error)

func (*TokenTypeId) SetBytes

func (tid *TokenTypeId) SetBytes(b []byte) error

func (TokenTypeId) String

func (tid TokenTypeId) String() string

func (*TokenTypeId) UnmarshalJSON

func (tid *TokenTypeId) UnmarshalJSON(input []byte) error

func (*TokenTypeId) UnmarshalText

func (tid *TokenTypeId) UnmarshalText(input []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type VoteInfo

type VoteInfo struct {
	VoterAddr Address
	NodeName  string
}

Jump to

Keyboard shortcuts

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