native

package
v0.90.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2020 License: MIT Imports: 28 Imported by: 6

Documentation

Index

Constants

View Source
const GASFactor = NEOTotalSupply

GASFactor is a divisor for finding GAS integral value.

View Source
const MaxValidatorsVoted = 1024

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

View Source
const (

	// NEOTotalSupply is the total amount of NEO in the system.
	NEOTotalSupply = 100000000
)

Variables

This section is empty.

Functions

func Deploy

func Deploy(ic *interop.Context, _ *vm.VM) error

Deploy deploys native contract.

Types

type BlockedAccounts

type BlockedAccounts []util.Uint160

BlockedAccounts represents a slice of blocked accounts hashes.

func BlockedAccountsFromBytes

func BlockedAccountsFromBytes(b []byte) (BlockedAccounts, error)

BlockedAccountsFromBytes converts serialized BlockedAccounts to structure.

func (*BlockedAccounts) Bytes

func (ba *BlockedAccounts) Bytes() []byte

Bytes returns serialized BlockedAccounts.

func (*BlockedAccounts) DecodeBinary

func (ba *BlockedAccounts) DecodeBinary(r *io.BinReader)

DecodeBinary implements io.Serializable interface.

func (*BlockedAccounts) EncodeBinary

func (ba *BlockedAccounts) EncodeBinary(w *io.BinWriter)

EncodeBinary implements io.Serializable interface.

func (*BlockedAccounts) ToStackItem

func (ba *BlockedAccounts) ToStackItem() stackitem.Item

ToStackItem converts BlockedAccounts to stackitem.Item

type Contracts

type Contracts struct {
	NEO       *NEO
	GAS       *GAS
	Policy    *Policy
	Contracts []interop.Contract
	// contains filtered or unexported fields
}

Contracts is a set of registered native contracts.

func NewContracts

func NewContracts() *Contracts

NewContracts returns new set of native contracts with new GAS, NEO and Policy contracts.

func (*Contracts) ByHash

func (cs *Contracts) ByHash(h util.Uint160) interop.Contract

ByHash returns native contract with the specified hash.

func (*Contracts) ByID

func (cs *Contracts) ByID(id uint32) interop.Contract

ByID returns native contract with the specified id.

func (*Contracts) GetNativeInterop

func (cs *Contracts) GetNativeInterop(ic *interop.Context) func(uint32) *vm.InteropFuncPrice

GetNativeInterop returns an interop getter for a given set of contracts.

func (*Contracts) GetPersistScript

func (cs *Contracts) GetPersistScript() []byte

GetPersistScript returns VM script calling "onPersist" method of every native contract.

type GAS

type GAS struct {
	NEO *NEO
	// contains filtered or unexported fields
}

GAS represents GAS native contract.

func NewGAS

func NewGAS() *GAS

NewGAS returns GAS native contract.

func (*GAS) Decimals

func (c *GAS) Decimals(_ *interop.Context, _ []stackitem.Item) stackitem.Item

func (*GAS) Initialize

func (g *GAS) Initialize(ic *interop.Context) error

Initialize initializes GAS contract.

func (*GAS) Metadata

func (c *GAS) Metadata() *interop.ContractMD

func (*GAS) Name

func (c *GAS) Name(_ *interop.Context, _ []stackitem.Item) stackitem.Item

func (*GAS) OnPersist

func (g *GAS) OnPersist(ic *interop.Context) error

OnPersist implements Contract interface.

func (*GAS) Symbol

func (c *GAS) Symbol(_ *interop.Context, _ []stackitem.Item) stackitem.Item

func (*GAS) TotalSupply

func (c *GAS) TotalSupply(ic *interop.Context, _ []stackitem.Item) stackitem.Item

func (*GAS) Transfer

func (c *GAS) Transfer(ic *interop.Context, args []stackitem.Item) stackitem.Item

type NEO

type NEO struct {
	GAS *GAS
	// contains filtered or unexported fields
}

NEO represents NEO native contract.

func NewNEO

func NewNEO() *NEO

NewNEO returns NEO native contract.

func (*NEO) Decimals

func (c *NEO) Decimals(_ *interop.Context, _ []stackitem.Item) stackitem.Item

func (*NEO) GetNextBlockValidatorsInternal

func (n *NEO) GetNextBlockValidatorsInternal(bc blockchainer.Blockchainer, d dao.DAO) (keys.PublicKeys, error)

GetNextBlockValidatorsInternal returns next block validators.

func (*NEO) GetRegisteredValidators

func (n *NEO) GetRegisteredValidators(d dao.DAO) ([]state.Validator, error)

GetRegisteredValidators returns current registered validators list with keys and votes.

func (*NEO) GetValidatorsInternal

func (n *NEO) GetValidatorsInternal(bc blockchainer.Blockchainer, d dao.DAO) (keys.PublicKeys, error)

GetValidatorsInternal returns a list of current validators.

func (*NEO) Initialize

func (n *NEO) Initialize(ic *interop.Context) error

Initialize initializes NEO contract.

func (*NEO) Metadata

func (c *NEO) Metadata() *interop.ContractMD

func (*NEO) ModifyAccountVotes

func (n *NEO) ModifyAccountVotes(acc *state.NEOBalanceState, d dao.DAO, value *big.Int) error

ModifyAccountVotes modifies votes of the specified account by value (can be negative).

func (*NEO) Name

func (c *NEO) Name(_ *interop.Context, _ []stackitem.Item) stackitem.Item

func (*NEO) OnPersist

func (n *NEO) OnPersist(ic *interop.Context) error

OnPersist implements Contract interface.

func (*NEO) Symbol

func (c *NEO) Symbol(_ *interop.Context, _ []stackitem.Item) stackitem.Item

func (*NEO) TotalSupply

func (c *NEO) TotalSupply(ic *interop.Context, _ []stackitem.Item) stackitem.Item

func (*NEO) Transfer

func (c *NEO) Transfer(ic *interop.Context, args []stackitem.Item) stackitem.Item

func (*NEO) VoteInternal

func (n *NEO) VoteInternal(ic *interop.Context, h util.Uint160, pubs keys.PublicKeys) error

VoteInternal votes from account h for validarors specified in pubs.

type Policy

type Policy struct {
	interop.ContractMD
	// contains filtered or unexported fields
}

Policy represents Policy native contract.

func (*Policy) CheckPolicy

func (p *Policy) CheckPolicy(ic *interop.Context, tx *transaction.Transaction) (bool, error)

CheckPolicy checks whether transaction's script hashes for verifying are included into blocked accounts list.

func (*Policy) GetBlockedAccountsInternal

func (p *Policy) GetBlockedAccountsInternal(dao dao.DAO) (BlockedAccounts, error)

GetBlockedAccountsInternal returns list of blocked accounts hashes.

func (*Policy) GetFeePerByteInternal

func (p *Policy) GetFeePerByteInternal(dao dao.DAO) int64

GetFeePerByteInternal returns required transaction's fee per byte.

func (*Policy) GetMaxTransactionsPerBlockInternal

func (p *Policy) GetMaxTransactionsPerBlockInternal(dao dao.DAO) uint32

GetMaxTransactionsPerBlockInternal returns the upper limit of transactions per block.

func (*Policy) Initialize

func (p *Policy) Initialize(ic *interop.Context) error

Initialize initializes Policy native contract and implements Contract interface.

func (*Policy) Metadata

func (p *Policy) Metadata() *interop.ContractMD

Metadata implements Contract interface.

func (*Policy) OnPersist

func (p *Policy) OnPersist(ic *interop.Context) error

OnPersist implements Contract interface.

func (*Policy) OnPersistEnd

func (p *Policy) OnPersistEnd(dao dao.DAO)

OnPersistEnd updates cached Policy values if they've been changed

type ValidatorsCount

type ValidatorsCount [MaxValidatorsVoted]big.Int

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

func ValidatorsCountFromBytes

func ValidatorsCountFromBytes(b []byte) (*ValidatorsCount, error)

ValidatorsCountFromBytes converts serialized ValidatorsCount to structure.

func (*ValidatorsCount) Bytes

func (vc *ValidatorsCount) Bytes() []byte

Bytes returns serialized ValidatorsCount.

func (*ValidatorsCount) DecodeBinary

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

DecodeBinary implements io.Serializable interface.

func (*ValidatorsCount) EncodeBinary

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

EncodeBinary implements io.Serializable interface.

func (*ValidatorsCount) GetWeightedAverage

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