native

package
v0.91.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2020 License: MIT Imports: 27 Imported by: 6

Documentation

Index

Constants

View Source
const GASFactor = NEOTotalSupply

GASFactor is a divisor for finding GAS integral value.

View Source
const (

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

Variables

This section is empty.

Functions

func Call added in v0.91.0

func Call(ic *interop.Context) error

Call calls specified native contract method.

func Deploy

func Deploy(ic *interop.Context) 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) 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

func (*GAS) TransferInternal added in v0.91.0

func (c *GAS) TransferInternal(ic *interop.Context, from, to util.Uint160, amount *big.Int) error

TransferInternal transfers NEO between accounts.

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) GetCandidates added in v0.91.0

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

GetCandidates returns current registered validators list with keys and votes.

func (*NEO) GetNextBlockValidatorsInternal

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

GetNextBlockValidatorsInternal returns next block validators.

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, typ int) error

ModifyAccountVotes modifies votes of the specified account by value (can be negative). typ specifies if this modify is occurring during transfer or vote (with old or new validator).

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) RegisterCandidateInternal added in v0.91.0

func (n *NEO) RegisterCandidateInternal(ic *interop.Context, pub *keys.PublicKey) error

RegisterCandidateInternal registers pub as a new candidate.

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) TransferInternal added in v0.91.0

func (c *NEO) TransferInternal(ic *interop.Context, from, to util.Uint160, amount *big.Int) error

TransferInternal transfers NEO between accounts.

func (*NEO) UnregisterCandidateInternal added in v0.91.0

func (n *NEO) UnregisterCandidateInternal(ic *interop.Context, pub *keys.PublicKey) error

UnregisterCandidateInternal unregisters pub as a candidate.

func (*NEO) VoteInternal

func (n *NEO) VoteInternal(ic *interop.Context, h util.Uint160, pub *keys.PublicKey) 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(d dao.DAO, tx *transaction.Transaction) error

CheckPolicy checks whether transaction conforms to current policy restrictions like not being signed by blocked account or not exceeding block-level system fee limit.

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) GetMaxBlockSizeInternal added in v0.91.0

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

GetMaxBlockSizeInternal returns maximum block size.

func (*Policy) GetMaxBlockSystemFeeInternal added in v0.91.0

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

GetMaxBlockSystemFeeInternal the maximum overall system fee per block.

func (*Policy) GetMaxTransactionsPerBlockInternal

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

GetMaxTransactionsPerBlockInternal returns the upper limit of transactions per block.

func (*Policy) GetMaxVerificationGas added in v0.91.0

func (p *Policy) GetMaxVerificationGas(_ dao.DAO) int64

GetMaxVerificationGas returns maximum gas allowed to be burned during verificaion.

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

Jump to

Keyboard shortcuts

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