iotex-core: github.com/iotexproject/iotex-core/action Index | Files | Directories

package action

import "github.com/iotexproject/iotex-core/action"

Index

Package Files

actctx.go action.go builder.go claimreward.go const.go depositreward.go execution.go grantreward.go putpollresult.go receipt.go transfer.go

Constants

const (
    // EmptyAddress is the empty string
    EmptyAddress = ""
    // ExecutionDataGas represents the execution data gas per uint
    ExecutionDataGas = uint64(100)
    // ExecutionBaseIntrinsicGas represents the base intrinsic gas for execution
    ExecutionBaseIntrinsicGas = uint64(10000)
)
const (
    // BlockReward indicates that the action is to grant block reward
    BlockReward = iota
    // EpochReward indicates that the action is to grant epoch reward
    EpochReward
)
const (
    // TransferPayloadGas represents the transfer payload gas per uint
    TransferPayloadGas = uint64(100)
    // TransferBaseIntrinsicGas represents the base intrinsic gas for transfer
    TransferBaseIntrinsicGas = uint64(10000)
)
const SignatureLength = 65

SignatureLength indicates the length of signature generated by SECP256K1 crypto library

Variables

var (
    // ErrAction indicates error for an action
    ErrAction = errors.New("action error")
    // ErrAddress indicates error of address
    ErrAddress = errors.New("address error")
)
var (
    // ClaimFromRewardingFundBaseGas represents the base intrinsic gas for claimFromRewardingFund
    ClaimFromRewardingFundBaseGas = uint64(10000)
    // ClaimFromRewardingFundGasPerByte represents the claimFromRewardingFund payload gas per uint
    ClaimFromRewardingFundGasPerByte = uint64(100)
)
var (
    // ErrActPool indicates the error of actpool
    ErrActPool = errors.New("invalid actpool")
    // ErrHitGasLimit is the error when hit gas limit
    ErrHitGasLimit = errors.New("Hit gas limit")
    // ErrInsufficientBalanceForGas is the error that the balance in executor account is lower than gas
    ErrInsufficientBalanceForGas = errors.New("Insufficient balance for gas")
    // ErrOutOfGas is the error when running out of gas
    ErrOutOfGas = errors.New("Out of gas")
    // ErrTransfer indicates the error of transfer
    ErrTransfer = errors.New("invalid transfer")
    // ErrNonce indicates the error of nonce
    ErrNonce = errors.New("invalid nonce")
    // ErrBalance indicates the error of balance
    ErrBalance = errors.New("invalid balance")
    // ErrGasPrice indicates the error of gas price
    ErrGasPrice = errors.New("invalid gas price")
    // ErrVotee indicates the error of votee
    ErrVotee = errors.New("votee is not a candidate")
    // ErrNotFound indicates the nonexistence of action
    ErrNotFound = errors.New("action not found")
)
var (
    // DepositToRewardingFundBaseGas represents the base intrinsic gas for depositToRewardingFund
    DepositToRewardingFundBaseGas = uint64(10000)
    // DepositToRewardingFundGasPerByte represents the depositToRewardingFund payload gas per uint
    DepositToRewardingFundGasPerByte = uint64(100)
)

func ClassifyActions Uses

func ClassifyActions(actions []SealedEnvelope) ([]*Transfer, []*Execution)

ClassifyActions classfies actions

func Verify Uses

func Verify(sealed SealedEnvelope) error

Verify verifies the action using sender's public key

type AbstractAction Uses

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

AbstractAction is an abstract implementation of Action interface

func (*AbstractAction) BasicActionSize Uses

func (act *AbstractAction) BasicActionSize() uint32

BasicActionSize returns the basic size of action

func (*AbstractAction) GasLimit Uses

func (act *AbstractAction) GasLimit() uint64

GasLimit returns the gas limit

func (*AbstractAction) GasPrice Uses

func (act *AbstractAction) GasPrice() *big.Int

GasPrice returns the gas price

func (*AbstractAction) Hash Uses

func (act *AbstractAction) Hash() hash.Hash256

Hash returns the hash value of referred SealedActionEnvelope hash.

func (*AbstractAction) Nonce Uses

func (act *AbstractAction) Nonce() uint64

Nonce returns the nonce

func (*AbstractAction) SetEnvelopeContext Uses

func (act *AbstractAction) SetEnvelopeContext(selp SealedEnvelope)

SetEnvelopeContext sets the SealedEnvelope context to action context.

func (*AbstractAction) SrcPubkey Uses

func (act *AbstractAction) SrcPubkey() crypto.PublicKey

SrcPubkey returns the source public key

func (*AbstractAction) Version Uses

func (act *AbstractAction) Version() uint32

Version returns the version

type Action Uses

type Action interface {
    SetEnvelopeContext(SealedEnvelope)
}

Action is the action can be Executed in protocols. The method is added to avoid mistakenly used empty interface as action.

type Builder Uses

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

Builder is used to build an action.

func (*Builder) Build Uses

func (b *Builder) Build() AbstractAction

Build builds a new action.

func (*Builder) SetGasLimit Uses

func (b *Builder) SetGasLimit(l uint64) *Builder

SetGasLimit sets action's gas limit.

func (*Builder) SetGasPrice Uses

func (b *Builder) SetGasPrice(p *big.Int) *Builder

SetGasPrice sets action's gas price.

func (*Builder) SetGasPriceByBytes Uses

func (b *Builder) SetGasPriceByBytes(buf []byte) *Builder

SetGasPriceByBytes sets action's gas price from a byte slice source.

func (*Builder) SetNonce Uses

func (b *Builder) SetNonce(n uint64) *Builder

SetNonce sets action's nonce.

func (*Builder) SetSourcePublicKey Uses

func (b *Builder) SetSourcePublicKey(key crypto.PublicKey) *Builder

SetSourcePublicKey sets action's source's public key.

func (*Builder) SetVersion Uses

func (b *Builder) SetVersion(v uint32) *Builder

SetVersion sets action's version.

type ClaimFromRewardingFund Uses

type ClaimFromRewardingFund struct {
    AbstractAction
    // contains filtered or unexported fields
}

ClaimFromRewardingFund is the action to claim reward from the rewarding fund

func (*ClaimFromRewardingFund) Amount Uses

func (c *ClaimFromRewardingFund) Amount() *big.Int

Amount returns the amount to claim

func (*ClaimFromRewardingFund) Cost Uses

func (c *ClaimFromRewardingFund) Cost() (*big.Int, error)

Cost returns the total cost of a claim action

func (*ClaimFromRewardingFund) Data Uses

func (c *ClaimFromRewardingFund) Data() []byte

Data returns the additional data

func (*ClaimFromRewardingFund) IntrinsicGas Uses

func (c *ClaimFromRewardingFund) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of a claim action

func (*ClaimFromRewardingFund) LoadProto Uses

func (c *ClaimFromRewardingFund) LoadProto(claim *iotextypes.ClaimFromRewardingFund) error

LoadProto converts a claim action protobuf to a claim action struct

func (*ClaimFromRewardingFund) Proto Uses

func (c *ClaimFromRewardingFund) Proto() *iotextypes.ClaimFromRewardingFund

Proto converts a claim action struct to a claim action protobuf

func (*ClaimFromRewardingFund) Serialize Uses

func (c *ClaimFromRewardingFund) Serialize() []byte

Serialize returns a raw byte stream of a claim action

type ClaimFromRewardingFundBuilder Uses

type ClaimFromRewardingFundBuilder struct {
    Builder
    // contains filtered or unexported fields
}

ClaimFromRewardingFundBuilder is the struct to build ClaimFromRewardingFund

func (*ClaimFromRewardingFundBuilder) Build Uses

func (b *ClaimFromRewardingFundBuilder) Build() ClaimFromRewardingFund

Build builds a new claim from rewarding fund action

func (*ClaimFromRewardingFundBuilder) SetAmount Uses

func (b *ClaimFromRewardingFundBuilder) SetAmount(amount *big.Int) *ClaimFromRewardingFundBuilder

SetAmount sets the amount to claim

func (*ClaimFromRewardingFundBuilder) SetData Uses

func (b *ClaimFromRewardingFundBuilder) SetData(data []byte) *ClaimFromRewardingFundBuilder

SetData sets the additional data

type DepositToRewardingFund Uses

type DepositToRewardingFund struct {
    AbstractAction
    // contains filtered or unexported fields
}

DepositToRewardingFund is the action to deposit to the rewarding fund

func (*DepositToRewardingFund) Amount Uses

func (d *DepositToRewardingFund) Amount() *big.Int

Amount returns the amount to deposit

func (*DepositToRewardingFund) Cost Uses

func (d *DepositToRewardingFund) Cost() (*big.Int, error)

Cost returns the total cost of a deposit action

func (*DepositToRewardingFund) Data Uses

func (d *DepositToRewardingFund) Data() []byte

Data returns the additional data

func (*DepositToRewardingFund) IntrinsicGas Uses

func (d *DepositToRewardingFund) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of a deposit action

func (*DepositToRewardingFund) LoadProto Uses

func (d *DepositToRewardingFund) LoadProto(deposit *iotextypes.DepositToRewardingFund) error

LoadProto converts a deposit action protobuf to a deposit action struct

func (*DepositToRewardingFund) Proto Uses

func (d *DepositToRewardingFund) Proto() *iotextypes.DepositToRewardingFund

Proto converts a deposit action struct to a deposit action protobuf

func (*DepositToRewardingFund) Serialize Uses

func (d *DepositToRewardingFund) Serialize() []byte

Serialize returns a raw byte stream of a deposit action

type DepositToRewardingFundBuilder Uses

type DepositToRewardingFundBuilder struct {
    Builder
    // contains filtered or unexported fields
}

DepositToRewardingFundBuilder is the struct to build DepositToRewardingFund

func (*DepositToRewardingFundBuilder) Build Uses

func (b *DepositToRewardingFundBuilder) Build() DepositToRewardingFund

Build builds a new deposit to rewarding fund action

func (*DepositToRewardingFundBuilder) SetAmount Uses

func (b *DepositToRewardingFundBuilder) SetAmount(amount *big.Int) *DepositToRewardingFundBuilder

SetAmount sets the amount to deposit

func (*DepositToRewardingFundBuilder) SetData Uses

func (b *DepositToRewardingFundBuilder) SetData(data []byte) *DepositToRewardingFundBuilder

SetData sets the additional data

type Envelope Uses

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

Envelope defines an envelope wrapped on action with some envelope metadata.

func (*Envelope) Action Uses

func (elp *Envelope) Action() Action

Action returns the action payload.

func (*Envelope) Cost Uses

func (elp *Envelope) Cost() (*big.Int, error)

Cost returns cost of actions

func (*Envelope) Destination Uses

func (elp *Envelope) Destination() (string, bool)

Destination returns the destination address

func (*Envelope) GasLimit Uses

func (elp *Envelope) GasLimit() uint64

GasLimit returns the gas limit

func (*Envelope) GasPrice Uses

func (elp *Envelope) GasPrice() *big.Int

GasPrice returns the gas price

func (*Envelope) Hash Uses

func (elp *Envelope) Hash() hash.Hash256

Hash returns the hash value of SealedEnvelope.

func (*Envelope) IntrinsicGas Uses

func (elp *Envelope) IntrinsicGas() (uint64, error)

IntrinsicGas returns intrinsic gas of action.

func (*Envelope) LoadProto Uses

func (elp *Envelope) LoadProto(pbAct *iotextypes.ActionCore) error

LoadProto loads fields from protobuf format.

func (*Envelope) Nonce Uses

func (elp *Envelope) Nonce() uint64

Nonce returns the nonce

func (*Envelope) Proto Uses

func (elp *Envelope) Proto() *iotextypes.ActionCore

Proto convert Envelope to protobuf format.

func (*Envelope) Serialize Uses

func (elp *Envelope) Serialize() []byte

Serialize returns encoded binary.

func (*Envelope) Version Uses

func (elp *Envelope) Version() uint32

Version returns the version

type EnvelopeBuilder Uses

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

EnvelopeBuilder is the builder to build Envelope.

func (*EnvelopeBuilder) Build Uses

func (b *EnvelopeBuilder) Build() Envelope

Build builds a new action.

func (*EnvelopeBuilder) SetAction Uses

func (b *EnvelopeBuilder) SetAction(action actionPayload) *EnvelopeBuilder

SetAction sets the action payload for the Envelope Builder is building.

func (*EnvelopeBuilder) SetGasLimit Uses

func (b *EnvelopeBuilder) SetGasLimit(l uint64) *EnvelopeBuilder

SetGasLimit sets action's gas limit.

func (*EnvelopeBuilder) SetGasPrice Uses

func (b *EnvelopeBuilder) SetGasPrice(p *big.Int) *EnvelopeBuilder

SetGasPrice sets action's gas price.

func (*EnvelopeBuilder) SetGasPriceByBytes Uses

func (b *EnvelopeBuilder) SetGasPriceByBytes(buf []byte) *EnvelopeBuilder

SetGasPriceByBytes sets action's gas price from a byte slice source.

func (*EnvelopeBuilder) SetNonce Uses

func (b *EnvelopeBuilder) SetNonce(n uint64) *EnvelopeBuilder

SetNonce sets action's nonce.

func (*EnvelopeBuilder) SetVersion Uses

func (b *EnvelopeBuilder) SetVersion(v uint32) *EnvelopeBuilder

SetVersion sets action's version.

type Execution Uses

type Execution struct {
    AbstractAction
    // contains filtered or unexported fields
}

Execution defines the struct of account-based contract execution

func NewExecution Uses

func NewExecution(
    contractAddress string,
    nonce uint64,
    amount *big.Int,
    gasLimit uint64,
    gasPrice *big.Int,
    data []byte,
) (*Execution, error)

NewExecution returns a Execution instance

func (*Execution) Amount Uses

func (ex *Execution) Amount() *big.Int

Amount returns the amount

func (*Execution) Contract Uses

func (ex *Execution) Contract() string

Contract returns a contract address

func (*Execution) Cost Uses

func (ex *Execution) Cost() (*big.Int, error)

Cost returns the cost of an execution

func (*Execution) Data Uses

func (ex *Execution) Data() []byte

Data returns the data bytes

func (*Execution) Destination Uses

func (ex *Execution) Destination() string

Destination returns a contract address

func (*Execution) ExecutorPublicKey Uses

func (ex *Execution) ExecutorPublicKey() crypto.PublicKey

ExecutorPublicKey returns the executor's public key

func (*Execution) IntrinsicGas Uses

func (ex *Execution) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of an execution

func (*Execution) LoadProto Uses

func (ex *Execution) LoadProto(pbAct *iotextypes.Execution) error

LoadProto converts a protobuf's Execution to Execution

func (*Execution) Proto Uses

func (ex *Execution) Proto() *iotextypes.Execution

Proto converts Execution to protobuf's Execution

func (*Execution) Serialize Uses

func (ex *Execution) Serialize() []byte

Serialize returns a raw byte stream of this Transfer

func (*Execution) TotalSize Uses

func (ex *Execution) TotalSize() uint32

TotalSize returns the total size of this Execution

type GrantReward Uses

type GrantReward struct {
    AbstractAction
    // contains filtered or unexported fields
}

GrantReward is the action to grant either block or epoch reward

func (*GrantReward) Cost Uses

func (*GrantReward) Cost() (*big.Int, error)

Cost returns the total cost of a grant reward action

func (*GrantReward) Height Uses

func (g *GrantReward) Height() uint64

Height returns the block height to grant reward

func (*GrantReward) IntrinsicGas Uses

func (*GrantReward) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of a grant reward action, which is 0

func (*GrantReward) LoadProto Uses

func (g *GrantReward) LoadProto(gProto *iotextypes.GrantReward) error

LoadProto converts a grant reward action protobuf to a grant reward action struct

func (*GrantReward) Proto Uses

func (g *GrantReward) Proto() *iotextypes.GrantReward

Proto converts a grant reward action struct to a grant reward action protobuf

func (*GrantReward) RewardType Uses

func (g *GrantReward) RewardType() int

RewardType returns the grant reward type

func (*GrantReward) Serialize Uses

func (g *GrantReward) Serialize() []byte

Serialize returns a raw byte stream of a grant reward action

type GrantRewardBuilder Uses

type GrantRewardBuilder struct {
    Builder
    // contains filtered or unexported fields
}

GrantRewardBuilder is the struct to build GrantReward

func (*GrantRewardBuilder) Build Uses

func (b *GrantRewardBuilder) Build() GrantReward

Build builds a new grant reward action

func (*GrantRewardBuilder) SetHeight Uses

func (b *GrantRewardBuilder) SetHeight(height uint64) *GrantRewardBuilder

SetHeight sets the grant reward block height

func (*GrantRewardBuilder) SetRewardType Uses

func (b *GrantRewardBuilder) SetRewardType(t int) *GrantRewardBuilder

SetRewardType sets the grant reward type

type Log Uses

type Log struct {
    Address     string
    Topics      []hash.Hash256
    Data        []byte
    BlockHeight uint64
    ActionHash  hash.Hash256
    Index       uint
    PreAleutian bool
}

Log stores an evm contract event

func (*Log) ConvertFromLogPb Uses

func (log *Log) ConvertFromLogPb(pbLog *iotextypes.Log)

ConvertFromLogPb converts a protobuf's LogPb to Log

func (*Log) ConvertToLogPb Uses

func (log *Log) ConvertToLogPb() *iotextypes.Log

ConvertToLogPb converts a Log to protobuf's Log

func (*Log) Deserialize Uses

func (log *Log) Deserialize(buf []byte) error

Deserialize parse the byte stream into Log

func (*Log) Serialize Uses

func (log *Log) Serialize() ([]byte, error)

Serialize returns a serialized byte stream for the Log

type PutPollResult Uses

type PutPollResult struct {
    AbstractAction
    // contains filtered or unexported fields
}

PutPollResult represents put the poll result from gravity chain.

func NewPutPollResult Uses

func NewPutPollResult(
    nonce uint64,
    height uint64,
    candidates state.CandidateList,
) *PutPollResult

NewPutPollResult instantiates a putting poll result action struct.

func (*PutPollResult) Candidates Uses

func (r *PutPollResult) Candidates() state.CandidateList

Candidates returns the list of candidates.

func (*PutPollResult) Cost Uses

func (r *PutPollResult) Cost() (*big.Int, error)

Cost returns the total cost of a put poll result action

func (*PutPollResult) Height Uses

func (r *PutPollResult) Height() uint64

Height returns put poll result height.

func (*PutPollResult) IntrinsicGas Uses

func (r *PutPollResult) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of a put poll result action

func (*PutPollResult) LoadProto Uses

func (r *PutPollResult) LoadProto(putPollResultPb *iotextypes.PutPollResult) error

LoadProto converts a proto message into put block action.

func (*PutPollResult) ProducerPublicKey Uses

func (r *PutPollResult) ProducerPublicKey() crypto.PublicKey

ProducerPublicKey return producer public key.

func (*PutPollResult) Proto Uses

func (r *PutPollResult) Proto() *iotextypes.PutPollResult

Proto converts put poll result action into a proto message.

func (*PutPollResult) Serialize Uses

func (r *PutPollResult) Serialize() []byte

Serialize returns the byte representation of put poll result action.

type Receipt Uses

type Receipt struct {
    Status          uint64
    BlockHeight     uint64
    ActionHash      hash.Hash256
    GasConsumed     uint64
    ContractAddress string
    Logs            []*Log
}

Receipt represents the result of a contract

func (*Receipt) ConvertFromReceiptPb Uses

func (receipt *Receipt) ConvertFromReceiptPb(pbReceipt *iotextypes.Receipt)

ConvertFromReceiptPb converts a protobuf's Receipt to Receipt

func (*Receipt) ConvertToReceiptPb Uses

func (receipt *Receipt) ConvertToReceiptPb() *iotextypes.Receipt

ConvertToReceiptPb converts a Receipt to protobuf's Receipt

func (*Receipt) Deserialize Uses

func (receipt *Receipt) Deserialize(buf []byte) error

Deserialize parse the byte stream into Receipt

func (*Receipt) Hash Uses

func (receipt *Receipt) Hash() hash.Hash256

Hash returns the hash of receipt

func (*Receipt) Serialize Uses

func (receipt *Receipt) Serialize() ([]byte, error)

Serialize returns a serialized byte stream for the Receipt

type SealedEnvelope Uses

type SealedEnvelope struct {
    Envelope
    // contains filtered or unexported fields
}

SealedEnvelope is a signed action envelope.

func AssembleSealedEnvelope Uses

func AssembleSealedEnvelope(act Envelope, pk crypto.PublicKey, sig []byte) SealedEnvelope

AssembleSealedEnvelope assembles a SealedEnvelope use Envelope, Sender Address and Signature. This method should be only used in tests.

func FakeSeal Uses

func FakeSeal(act Envelope, pubk crypto.PublicKey) SealedEnvelope

FakeSeal creates a SealedActionEnvelope without signature. This method should be only used in tests.

func Sign Uses

func Sign(act Envelope, sk crypto.PrivateKey) (SealedEnvelope, error)

Sign signs the action using sender's private key

func (*SealedEnvelope) Hash Uses

func (sealed *SealedEnvelope) Hash() hash.Hash256

Hash returns the hash value of SealedEnvelope.

func (*SealedEnvelope) LoadProto Uses

func (sealed *SealedEnvelope) LoadProto(pbAct *iotextypes.Action) error

LoadProto loads from proto scheme.

func (SealedEnvelope) Proto Uses

func (sealed SealedEnvelope) Proto() *iotextypes.Action

Proto converts it to it's proto scheme.

func (*SealedEnvelope) Signature Uses

func (sealed *SealedEnvelope) Signature() []byte

Signature returns signature bytes

func (*SealedEnvelope) SrcPubkey Uses

func (sealed *SealedEnvelope) SrcPubkey() crypto.PublicKey

SrcPubkey returns the source public key

type Transfer Uses

type Transfer struct {
    AbstractAction
    // contains filtered or unexported fields
}

Transfer defines the struct of account-based transfer

func NewTransfer Uses

func NewTransfer(
    nonce uint64,
    amount *big.Int,
    recipient string,
    payload []byte,
    gasLimit uint64,
    gasPrice *big.Int,
) (*Transfer, error)

NewTransfer returns a Transfer instance

func (*Transfer) Amount Uses

func (tsf *Transfer) Amount() *big.Int

Amount returns the amount

func (*Transfer) Cost Uses

func (tsf *Transfer) Cost() (*big.Int, error)

Cost returns the total cost of a transfer

func (*Transfer) Destination Uses

func (tsf *Transfer) Destination() string

Destination returns the recipient address as destination.

func (*Transfer) IntrinsicGas Uses

func (tsf *Transfer) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of a transfer

func (*Transfer) LoadProto Uses

func (tsf *Transfer) LoadProto(pbAct *iotextypes.Transfer) error

LoadProto converts a protobuf's Action to Transfer

func (*Transfer) Payload Uses

func (tsf *Transfer) Payload() []byte

Payload returns the payload bytes

func (*Transfer) Proto Uses

func (tsf *Transfer) Proto() *iotextypes.Transfer

Proto converts Transfer to protobuf's Action

func (*Transfer) Recipient Uses

func (tsf *Transfer) Recipient() string

Recipient returns the recipient address. It's the wrapper of Action.DstAddr

func (*Transfer) SenderPublicKey Uses

func (tsf *Transfer) SenderPublicKey() crypto.PublicKey

SenderPublicKey returns the sender public key. It's the wrapper of Action.SrcPubkey

func (*Transfer) Serialize Uses

func (tsf *Transfer) Serialize() []byte

Serialize returns a raw byte stream of this Transfer

func (*Transfer) TotalSize Uses

func (tsf *Transfer) TotalSize() uint32

TotalSize returns the total size of this Transfer

Directories

PathSynopsis
protocol
protocol/account
protocol/account/accountpb
protocol/account/util
protocol/execution
protocol/execution/evm
protocol/poll
protocol/rewarding
protocol/rewarding/rewardingpb
protocol/rolldpos
protocol/vote/candidatesutil

Package action imports 11 packages (graph) and is imported by 26 packages. Updated 2019-11-15. Refresh now. Tools for package owners.