tx

package
v0.0.0-...-75aef46 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2019 License: GPL-3.0 Imports: 15 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IntrinsicGas

func IntrinsicGas(clauses ...*Clause) (uint64, error)

IntrinsicGas calculate intrinsic gas cost for tx with such clauses.

Types

type BlockRef

type BlockRef [8]byte

BlockRef is block reference.

func NewBlockRef

func NewBlockRef(blockNum uint32) (br BlockRef)

NewBlockRef create block reference with block number.

func NewBlockRefFromID

func NewBlockRefFromID(blockID powerplay.Bytes32) (br BlockRef)

NewBlockRefFromID create block reference from block id.

func (BlockRef) Number

func (br BlockRef) Number() uint32

Number extracts block number.

type Builder

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

Builder to make it easy to build transaction.

func (*Builder) BlockRef

func (b *Builder) BlockRef(br BlockRef) *Builder

BlockRef set block reference.

func (*Builder) Build

func (b *Builder) Build() *Transaction

Build build tx object.

func (*Builder) ChainTag

func (b *Builder) ChainTag(tag byte) *Builder

ChainTag set chain tag.

func (*Builder) Clause

func (b *Builder) Clause(c *Clause) *Builder

Clause add a clause.

func (*Builder) DependsOn

func (b *Builder) DependsOn(txID *powerplay.Bytes32) *Builder

DependsOn set depended tx.

func (*Builder) Expiration

func (b *Builder) Expiration(exp uint32) *Builder

Expiration set expiration.

func (*Builder) Gas

func (b *Builder) Gas(gas uint64) *Builder

Gas set gas provision for tx.

func (*Builder) GasPriceCoef

func (b *Builder) GasPriceCoef(coef uint8) *Builder

GasPriceCoef set gas price coef.

func (*Builder) Nonce

func (b *Builder) Nonce(nonce uint64) *Builder

Nonce set nonce.

type Clause

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

Clause is the basic execution unit of a transaction.

func NewClause

func NewClause(to *powerplay.Address) *Clause

NewClause create a new clause instance.

func (*Clause) Data

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

Data returns 'Data'.

func (*Clause) DecodeRLP

func (c *Clause) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder

func (*Clause) EncodeRLP

func (c *Clause) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder

func (*Clause) IsCreatingContract

func (c *Clause) IsCreatingContract() bool

IsCreatingContract return if this clause is going to create a contract.

func (*Clause) String

func (c *Clause) String() string

func (*Clause) To

func (c *Clause) To() *powerplay.Address

To returns 'To' address.

func (*Clause) Value

func (c *Clause) Value() *big.Int

Value returns 'Value'.

func (*Clause) WithData

func (c *Clause) WithData(data []byte) *Clause

WithData create a new clause copy with data changed.

func (*Clause) WithValue

func (c *Clause) WithValue(value *big.Int) *Clause

WithValue create a new clause copy with value changed.

type Event

type Event struct {
	// address of the contract that generated the event
	Address powerplay.Address
	// list of topics provided by the contract.
	Topics []powerplay.Bytes32
	// supplied by the contract, usually ABI-encoded
	Data []byte
}

Event represents a contract event log. These events are generated by the LOG opcode and stored/indexed by the node.

type Events

type Events []*Event

Events slice of event logs.

type Output

type Output struct {
	// events produced by the clause
	Events Events
	// transfer occurred in clause
	Transfers Transfers
}

Output output of clause execution.

type Receipt

type Receipt struct {
	// gas used by this tx
	GasUsed uint64
	// the one who paid for gas
	GasPayer powerplay.Address
	// energy paid for used gas
	Paid *big.Int
	// energy reward given to block proposer
	Reward *big.Int
	// if the tx reverted
	Reverted bool
	// outputs of clauses in tx
	Outputs []*Output
}

Receipt represents the results of a transaction.

type Receipts

type Receipts []*Receipt

Receipts slice of receipts.

func (Receipts) RootHash

func (rs Receipts) RootHash() powerplay.Bytes32

RootHash computes merkle root hash of receipts.

type Transaction

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

Transaction is an immutable tx type.

func (*Transaction) BlockRef

func (t *Transaction) BlockRef() (br BlockRef)

BlockRef returns block reference, which is first 8 bytes of block hash.

func (*Transaction) ChainTag

func (t *Transaction) ChainTag() byte

ChainTag returns chain tag.

func (*Transaction) Clauses

func (t *Transaction) Clauses() []*Clause

Clauses returns caluses in tx.

func (*Transaction) DecodeRLP

func (t *Transaction) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder

func (*Transaction) DependsOn

func (t *Transaction) DependsOn() *powerplay.Bytes32

DependsOn returns depended tx hash.

func (*Transaction) EncodeRLP

func (t *Transaction) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder

func (*Transaction) EvaluateWork

func (t *Transaction) EvaluateWork(signer powerplay.Address) func(nonce uint64) *big.Int

EvaluateWork try to compute work when tx signer assumed.

func (*Transaction) Expiration

func (t *Transaction) Expiration() uint32

Expiration returns expiration in unit block. A valid transaction requires: blockNum in [blockRef.Num... blockRef.Num + Expiration]

func (*Transaction) Gas

func (t *Transaction) Gas() uint64

Gas returns gas provision for this tx.

func (*Transaction) GasPrice

func (t *Transaction) GasPrice(baseGasPrice *big.Int) *big.Int

GasPrice returns gas price. gasPrice = baseGasPrice + baseGasPrice * gasPriceCoef / 255

func (*Transaction) GasPriceCoef

func (t *Transaction) GasPriceCoef() uint8

GasPriceCoef returns gas price coef. gas price = bgp + bgp * gpc / 255.

func (*Transaction) HasReservedFields

func (t *Transaction) HasReservedFields() bool

HasReservedFields returns if there're reserved fields. Reserved fields are for backward compatibility purpose.

func (*Transaction) ID

func (t *Transaction) ID() (id powerplay.Bytes32)

ID returns id of tx. ID = hash(signingHash, signer). It returns zero Bytes32 if signer not available.

func (*Transaction) IntrinsicGas

func (t *Transaction) IntrinsicGas() (uint64, error)

IntrinsicGas returns intrinsic gas of tx.

func (*Transaction) IsExpired

func (t *Transaction) IsExpired(blockNum uint32) bool

IsExpired returns whether the tx is expired according to the given blockNum.

func (*Transaction) Nonce

func (t *Transaction) Nonce() uint64

Nonce returns nonce value.

func (*Transaction) OverallGasPrice

func (t *Transaction) OverallGasPrice(baseGasPrice *big.Int, headBlockNum uint32, getBlockID func(uint32) powerplay.Bytes32) *big.Int

OverallGasPrice calculate overall gas price. overallGasPrice = gasPrice + baseGasPrice * wgas/gas.

func (*Transaction) ProvedWork

func (t *Transaction) ProvedWork(headBlockNum uint32, getBlockID func(uint32) powerplay.Bytes32) *big.Int

ProvedWork returns proved work. Unproved work will be considered as proved work if block ref is do the prefix of a block's ID, and tx delay is less equal to MaxTxWorkDelay.

func (*Transaction) Signature

func (t *Transaction) Signature() []byte

Signature returns signature.

func (*Transaction) Signer

func (t *Transaction) Signer() (signer powerplay.Address, err error)

Signer extract signer of tx from signature.

func (*Transaction) SigningHash

func (t *Transaction) SigningHash() (hash powerplay.Bytes32)

SigningHash returns hash of tx excludes signature.

func (*Transaction) Size

func (t *Transaction) Size() metric.StorageSize

Size returns size in bytes when RLP encoded.

func (*Transaction) String

func (t *Transaction) String() string

func (*Transaction) UnprovedWork

func (t *Transaction) UnprovedWork() (w *big.Int)

UnprovedWork returns unproved work of this tx. It returns 0, if tx is not signed.

func (*Transaction) WithSignature

func (t *Transaction) WithSignature(sig []byte) *Transaction

WithSignature create a new tx with signature set.

type Transactions

type Transactions []*Transaction

Transactions a slice of transactions.

func (Transactions) RootHash

func (txs Transactions) RootHash() powerplay.Bytes32

RootHash computes merkle root hash of transactions.

type Transfer

type Transfer struct {
	Sender    powerplay.Address
	Recipient powerplay.Address
	Amount    *big.Int
}

Transfer token transfer log.

type Transfers

type Transfers []*Transfer

Transfers slisce of transfer logs.

Jump to

Keyboard shortcuts

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