state

package
v0.73.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const MaxValidatorsVoted = 1024

MaxValidatorsVoted limits the number of validators that one can vote for.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Version    uint8
	ScriptHash util.Uint160
	IsFrozen   bool
	Votes      []*keys.PublicKey
	Balances   map[util.Uint256][]UnspentBalance
}

Account represents the state of a NEO account.

func NewAccount

func NewAccount(scriptHash util.Uint160) *Account

NewAccount returns a new Account object.

func (*Account) DecodeBinary

func (s *Account) DecodeBinary(br *io.BinReader)

DecodeBinary decodes Account from the given BinReader.

func (*Account) EncodeBinary

func (s *Account) EncodeBinary(bw *io.BinWriter)

EncodeBinary encodes Account to the given BinWriter.

func (*Account) GetBalanceValues

func (s *Account) GetBalanceValues() map[util.Uint256]util.Fixed8

GetBalanceValues sums all unspent outputs and returns a map of asset IDs to overall balances.

type AppExecResult

type AppExecResult struct {
	TxHash      util.Uint256
	Trigger     byte
	VMState     string
	GasConsumed util.Fixed8
	Stack       string // JSON
	Events      []NotificationEvent
}

AppExecResult represent the result of the script execution, gathering together all resulting notifications, state, stack and other metadata.

func (*AppExecResult) DecodeBinary

func (aer *AppExecResult) DecodeBinary(r *io.BinReader)

DecodeBinary implements the Serializable interface.

func (*AppExecResult) EncodeBinary

func (aer *AppExecResult) EncodeBinary(w *io.BinWriter)

EncodeBinary implements the Serializable interface.

type Asset

type Asset struct {
	ID         util.Uint256
	AssetType  transaction.AssetType
	Name       string
	Amount     util.Fixed8
	Available  util.Fixed8
	Precision  uint8
	FeeMode    uint8
	FeeAddress util.Uint160
	Owner      keys.PublicKey
	Admin      util.Uint160
	Issuer     util.Uint160
	Expiration uint32
	IsFrozen   bool
}

Asset represents the state of an NEO registered Asset.

func (*Asset) DecodeBinary

func (a *Asset) DecodeBinary(br *io.BinReader)

DecodeBinary implements Serializable interface.

func (*Asset) EncodeBinary

func (a *Asset) EncodeBinary(bw *io.BinWriter)

EncodeBinary implements Serializable interface.

func (*Asset) GetName

func (a *Asset) GetName() string

GetName returns the asset name based on its type.

type Coin

type Coin uint8

Coin represents the state of a coin.

const (
	CoinConfirmed Coin = 0
	CoinSpent     Coin = 1 << 1
	CoinClaimed   Coin = 1 << 2
	CoinFrozen    Coin = 1 << 5
)

Viable Coin constants.

type Contract

type Contract struct {
	Script      []byte
	ParamList   []smartcontract.ParamType
	ReturnType  smartcontract.ParamType
	Properties  smartcontract.PropertyState
	Name        string
	CodeVersion string
	Author      string
	Email       string
	Description string
	// contains filtered or unexported fields
}

Contract holds information about a smart contract in the NEO blockchain.

func (*Contract) DecodeBinary

func (cs *Contract) DecodeBinary(br *io.BinReader)

DecodeBinary implements Serializable interface.

func (*Contract) EncodeBinary

func (cs *Contract) EncodeBinary(bw *io.BinWriter)

EncodeBinary implements Serializable interface.

func (*Contract) HasDynamicInvoke

func (cs *Contract) HasDynamicInvoke() bool

HasDynamicInvoke checks whether the contract has dynamic invoke property set.

func (*Contract) HasStorage

func (cs *Contract) HasStorage() bool

HasStorage checks whether the contract has storage property set.

func (*Contract) IsPayable

func (cs *Contract) IsPayable() bool

IsPayable checks whether the contract has payable property set.

func (*Contract) ScriptHash

func (cs *Contract) ScriptHash() util.Uint160

ScriptHash returns a contract script hash.

type NotificationEvent

type NotificationEvent struct {
	ScriptHash util.Uint160
	Item       vm.StackItem
}

NotificationEvent is a tuple of scripthash that emitted the StackItem as a notification and that item itself.

func (*NotificationEvent) DecodeBinary

func (ne *NotificationEvent) DecodeBinary(r *io.BinReader)

DecodeBinary implements the Serializable interface.

func (*NotificationEvent) EncodeBinary

func (ne *NotificationEvent) EncodeBinary(w *io.BinWriter)

EncodeBinary implements the Serializable interface.

type StorageItem

type StorageItem struct {
	Value   []byte
	IsConst bool
}

StorageItem is the value to be stored with read-only flag.

func (*StorageItem) DecodeBinary

func (si *StorageItem) DecodeBinary(r *io.BinReader)

DecodeBinary implements Serializable interface.

func (*StorageItem) EncodeBinary

func (si *StorageItem) EncodeBinary(w *io.BinWriter)

EncodeBinary implements Serializable interface.

type UnspentBalance

type UnspentBalance struct {
	Tx    util.Uint256 `json:"txid"`
	Index uint16       `json:"n"`
	Value util.Fixed8  `json:"value"`
}

UnspentBalance contains input/output transactons that sum up into the account balance for the given asset.

func (*UnspentBalance) DecodeBinary

func (u *UnspentBalance) DecodeBinary(r *io.BinReader)

DecodeBinary implements io.Serializable interface.

func (*UnspentBalance) EncodeBinary

func (u *UnspentBalance) EncodeBinary(w *io.BinWriter)

EncodeBinary implements io.Serializable interface.

type UnspentBalances

type UnspentBalances []UnspentBalance

UnspentBalances is a slice of UnspentBalance (mostly needed to sort them).

func (UnspentBalances) Len

func (us UnspentBalances) Len() int

Len returns the length of UnspentBalances (used to sort things).

func (UnspentBalances) Less

func (us UnspentBalances) Less(i, j int) bool

Less compares two elements of UnspentBalances (used to sort things).

func (UnspentBalances) Swap

func (us UnspentBalances) Swap(i, j int)

Swap swaps two elements of UnspentBalances (used to sort things).

type Validator

type Validator struct {
	PublicKey  *keys.PublicKey
	Registered bool
	Votes      util.Fixed8
}

Validator holds the state of a validator.

func (*Validator) DecodeBinary

func (vs *Validator) DecodeBinary(reader *io.BinReader)

DecodeBinary decodes Validator from the given BinReader.

func (*Validator) EncodeBinary

func (vs *Validator) EncodeBinary(bw *io.BinWriter)

EncodeBinary encodes Validator to the given BinWriter.

func (*Validator) RegisteredAndHasVotes

func (vs *Validator) RegisteredAndHasVotes() bool

RegisteredAndHasVotes returns true or false whether Validator is registered and has votes.

func (*Validator) UnregisteredAndHasNoVotes added in v0.73.0

func (vs *Validator) UnregisteredAndHasNoVotes() bool

UnregisteredAndHasNoVotes returns true when Validator is not registered and has no votes.

type ValidatorsCount added in v0.73.0

type ValidatorsCount [MaxValidatorsVoted]util.Fixed8

ValidatorsCount represents votes with particular number of consensus nodes for this number to be changeable by the voting system.

func (*ValidatorsCount) DecodeBinary added in v0.73.0

func (vc *ValidatorsCount) DecodeBinary(r *io.BinReader)

DecodeBinary decodes ValidatorCount from the given BinReader.

func (*ValidatorsCount) EncodeBinary added in v0.73.0

func (vc *ValidatorsCount) EncodeBinary(w *io.BinWriter)

EncodeBinary encodes ValidatorCount to the given BinWriter.

func (*ValidatorsCount) GetWeightedAverage added in v0.73.0

func (vc *ValidatorsCount) GetWeightedAverage() int

GetWeightedAverage returns an average count of validators that's been voted for not counting 1/4 of minimum and maximum numbers.

Jump to

Keyboard shortcuts

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