Documentation ¶
Index ¶
- Constants
- Variables
- func CanTransfer(am vm.AccountManager, addr common.Address, amount *big.Int) bool
- func ChangeVotesByBalance(am *account.Manager)
- func CheckRegisterTxProfile(profile types.Profile) error
- func GetHashFn(ref *types.Header, chain ParentBlockLoader) vm.GetHashFunc
- func InitCandidateProfile(registerAcc types.AccountAccessor, newProfile types.Profile)
- func IntrinsicGas(txType uint16, data []byte, txMessage string) (uint64, error)
- func NewEVMContext(tx *types.Transaction, header *types.Header, txIndex uint, ...) vm.Context
- func Refund(candidateAddress common.Address, am *account.Manager)
- func Transfer(am vm.AccountManager, sender, recipient common.Address, amount *big.Int)
- type BlockLoader
- type BoxTxEnv
- type CandidateVoteEnv
- type ModifySigners
- type ParentBlockLoader
- type RunAssetEnv
- func (r *RunAssetEnv) CreateAssetTx(sender common.Address, data []byte, txHash common.Hash) error
- func (r *RunAssetEnv) IssueAssetTx(sender, receiver common.Address, txHash common.Hash, data []byte) error
- func (r *RunAssetEnv) ModifyAssetProfileTx(sender common.Address, data []byte) error
- func (r *RunAssetEnv) ReplenishAssetTx(sender, receiver common.Address, data []byte) error
- type SetMultisigAccountEnv
- type TxProcessor
- func (p *TxProcessor) ApplyTxs(header *types.Header, txs types.Transactions, timeLimitSecond int64) (types.Transactions, types.Transactions, uint64)
- func (p *TxProcessor) Process(header *types.Header, txs types.Transactions) (uint64, error)
- func (p *TxProcessor) ReadContract(accM *account.ReadOnlyManager, header *types.Header, to common.Address, ...) ([]byte, error)
- func (p *TxProcessor) VerifyAssetTx(tx *types.Transaction) error
- func (p *TxProcessor) VerifyTxBeforeApply(tx *types.Transaction) error
Constants ¶
const ( NodeIDFieldLength = 130 MaxProfileFieldLength = 128 MaxIntroductionLength = 1024 MaxMarshalCandidateProfileLength = 1200 // candidate 中profile marshal之后得到的byte数组的最大长度 StandardNodeIdLength = 64 SignerWeightThreshold = 100 MaxSignersNumber = 100 )
Variables ¶
var ( ErrIssueAssetAmount = errors.New("issue asset amount can't be 0 or nil") ErrIssueAssetMetaData = errors.New("the length of metaData more than limit") ErrReplenishAssetAmount = errors.New("replenish asset amount can't be 0 or nil") ErrAssetIssuer = errors.New("issue asset transaction's sender must the asset issuer") ErrFrozenAsset = errors.New("can't replenish the frozen assets") ErrIsReplenishable = errors.New("asset's \"IsReplenishable\" is false") ErrIsDivisible = errors.New("this \"isDivisible == false\" kind of asset can't be replenished") ErrNotEqualAssetCode = errors.New("assetCode not equal") ErrModifyAssetInfo = errors.New("missing required field 'info' for ModifyAssetInfo") ErrMarshalAssetLength = errors.New("the length of data by marshal asset more than max length") ErrAssetCategory = errors.New("assert's Category not exist") ErrModifyAssetTxSender = errors.New("the sender does not have permission to modify this asset") )
var ( ErrAlreadyVoted = errors.New("already voted the same as candidate node") ErrOfNotCandidateNode = errors.New("node address is not candidate account") ErrOfRegisterNodeID = errors.New("can't get nodeId of RegisterInfo") ErrOfRegisterHost = errors.New("can't get host of RegisterInfo") ErrOfRegisterPort = errors.New("can't get port of RegisterInfo") ErrRegisterAgain = errors.New("cannot register again after unregistering") ErrIsCandidate = errors.New("get an unexpected character") ErrInsufficientBalance = errors.New("the balance is insufficient to deduct the deposit for candidate register") ErrMarshalProfileLength = errors.New("the data of candidate profile exceed the length limit 1200 Bytes") ErrInsufficientDepositAmount = errors.New("the deposit amount is not enough for candidate register") ErrParseDepositAmount = errors.New("parse deposit amount failed") ErrDepositPoolInsufficient = errors.New("insufficient deposit pool balance") ErrFailedGetDepositBalacne = errors.New("failed to get deposit balance") )
var ( ErrAddressRepeat = errors.New("cannot set two identical addresses") ErrWeight = errors.New("signer weight error") ErrTempAccount = errors.New("temp account format error") ErrSignersNumber = errors.New("cannot exceed the maximum number of signers") ErrRepeatSetTempAddress = errors.New("the temp address's multisig has been set up") )
var ( ErrInsufficientBalanceForGas = errors.New("insufficient balance to pay for gas") ErrInvalidTxInBlock = errors.New("block contains invalid transaction") ErrTxGasUsedNotEqual = errors.New("tx gas used not equal") ErrInvalidGenesis = errors.New("can't process genesis block") ErrInvalidProfile = errors.New("the length of candidate profile field in transaction is out of max length limit") ErrInvalidPort = errors.New("invalid port") ErrInvalidIntroduction = errors.New("the length of introduction field in transaction is out of max length limit") ErrInvalidAddress = errors.New("invalid address") ErrInvalidNodeId = errors.New("invalid nodeId") ErrTxNotSign = errors.New("the transaction is not signed") ErrTotalWeight = errors.New("insufficient total weight of signatories") ErrSignerAndFromUnequally = errors.New("the signer and from of transaction are not equal") ErrGasPayer = errors.New("the gasPayer error") ErrAddressType = errors.New("address type wrong") ErrTempAddress = errors.New("the issuer part in temp address is incorrect") )
var (
ErrApplyBoxTxsTimeout = errors.New("apply box txs timeout")
)
Functions ¶
func CanTransfer ¶
CanTransfer checks whether there are enough funds in the address' account to make a transfer. This does not take the necessary gas in to account to make the transfer valid.
func ChangeVotesByBalance ¶ added in v1.4.0
ChangeVotesByBalance 设置余额变化导致的候选节点票数的变化
func CheckRegisterTxProfile ¶ added in v1.4.0
检查: 1. nodeID必须存在并检验是否可用。 2. 如果有introduction长度必须小于10245,其他字段长度必须小于130. 3. incomeAddress host port 限制性判断
CheckRegisterTxProfile
func GetHashFn ¶
func GetHashFn(ref *types.Header, chain ParentBlockLoader) vm.GetHashFunc
GetHashFn returns a GetHashFunc which retrieves header hashes by number
func InitCandidateProfile ¶ added in v1.4.0
func InitCandidateProfile(registerAcc types.AccountAccessor, newProfile types.Profile)
InitCandidateProfile
func IntrinsicGas ¶
IntrinsicGas computes the 'intrinsic gas' for a message with the given data.
func NewEVMContext ¶
func NewEVMContext(tx *types.Transaction, header *types.Header, txIndex uint, blockHash common.Hash, chain ParentBlockLoader) vm.Context
NewEVMContext creates a new context for use in the EVM.
Types ¶
type BlockLoader ¶
type BlockLoader interface { // GetBlockByHash returns the hash corresponding to their hash. GetBlockByHash(hash common.Hash) *types.Block // GetBlockByHash returns the hash corresponding to their hash. GetParentByHeight(height uint32, sonBlockHash common.Hash) *types.Block }
BlockLoader supports retrieving headers and consensus parameters from the current blockchain to be used during transaction processing.
type BoxTxEnv ¶
type BoxTxEnv struct {
// contains filtered or unexported fields
}
func NewBoxTxEnv ¶
func NewBoxTxEnv(p *TxProcessor) *BoxTxEnv
type CandidateVoteEnv ¶
type CandidateVoteEnv struct { CanTransfer func(vm.AccountManager, common.Address, *big.Int) bool Transfer func(vm.AccountManager, common.Address, common.Address, *big.Int) // contains filtered or unexported fields }
func NewCandidateVoteEnv ¶
func NewCandidateVoteEnv(am *account.Manager, dm *deputynode.Manager) *CandidateVoteEnv
func (*CandidateVoteEnv) CallVoteTx ¶
func (c *CandidateVoteEnv) CallVoteTx(voter, newCandidateAddr common.Address, initialBalance *big.Int) error
CallVoteTx voting transaction call
func (*CandidateVoteEnv) RegisterOrUpdateToCandidate ¶
func (c *CandidateVoteEnv) RegisterOrUpdateToCandidate(tx *types.Transaction) error
RegisterOrUpdateToCandidate candidate node account transaction call
type ModifySigners ¶
func (ModifySigners) MarshalJSON ¶ added in v1.4.0
func (m ModifySigners) MarshalJSON() ([]byte, error)
MarshalJSON marshals as JSON.
func (*ModifySigners) UnmarshalJSON ¶ added in v1.4.0
func (m *ModifySigners) UnmarshalJSON(input []byte) error
UnmarshalJSON unmarshals from JSON.
type ParentBlockLoader ¶ added in v1.4.0
type ParentBlockLoader interface { // GetParentByHeight returns the parent block corresponding to their hash. GetParentByHeight(height uint32, sonBlockHash common.Hash) *types.Block }
ParentBlockLoader is the interface of BlockChain
type RunAssetEnv ¶
type RunAssetEnv struct {
// contains filtered or unexported fields
}
func NewRunAssetEnv ¶
func NewRunAssetEnv(am *account.Manager) *RunAssetEnv
func (*RunAssetEnv) CreateAssetTx ¶
CreateAssetTx
func (*RunAssetEnv) IssueAssetTx ¶
func (r *RunAssetEnv) IssueAssetTx(sender, receiver common.Address, txHash common.Hash, data []byte) error
IssueAssetTx
func (*RunAssetEnv) ModifyAssetProfileTx ¶
func (r *RunAssetEnv) ModifyAssetProfileTx(sender common.Address, data []byte) error
ModifyAssetProfileTx
func (*RunAssetEnv) ReplenishAssetTx ¶
func (r *RunAssetEnv) ReplenishAssetTx(sender, receiver common.Address, data []byte) error
ReplenishAssetTx
type SetMultisigAccountEnv ¶
type SetMultisigAccountEnv struct {
// contains filtered or unexported fields
}
func NewSetMultisigAccountEnv ¶
func NewSetMultisigAccountEnv(am *account.Manager) *SetMultisigAccountEnv
func (*SetMultisigAccountEnv) ModifyMultisigTx ¶
func (s *SetMultisigAccountEnv) ModifyMultisigTx(from, to common.Address, data []byte) error
ModifyMultisigTx
type TxProcessor ¶
type TxProcessor struct { ChainID uint16 // contains filtered or unexported fields }
func NewTxProcessor ¶
func NewTxProcessor(issueRewardAddress common.Address, chainID uint16, blockLoader ParentBlockLoader, am *account.Manager, db protocol.ChainDB, dm *deputynode.Manager) *TxProcessor
func (*TxProcessor) ApplyTxs ¶
func (p *TxProcessor) ApplyTxs(header *types.Header, txs types.Transactions, timeLimitSecond int64) (types.Transactions, types.Transactions, uint64)
ApplyTxs picks and processes transactions from miner's tx pool.
func (*TxProcessor) Process ¶
func (p *TxProcessor) Process(header *types.Header, txs types.Transactions) (uint64, error)
Process processes all transactions in a block. Change accounts' data and execute contract codes.
func (*TxProcessor) ReadContract ¶ added in v1.4.0
func (p *TxProcessor) ReadContract(accM *account.ReadOnlyManager, header *types.Header, to common.Address, data hexutil.Bytes, timeout time.Duration) ([]byte, error)
ReadContract pre-execute transactions and contracts.
func (*TxProcessor) VerifyAssetTx ¶ added in v1.4.0
func (p *TxProcessor) VerifyAssetTx(tx *types.Transaction) error
VerifyAssetTx
func (*TxProcessor) VerifyTxBeforeApply ¶ added in v1.4.0
func (p *TxProcessor) VerifyTxBeforeApply(tx *types.Transaction) error
VerifyTxBeforeApply 执行交易之前的交易校验