Documentation ¶
Index ¶
- Constants
- Variables
- func ChainIdValidate(chainId *big.Int) (bool, error)
- func EthBloom9(data []byte) []byte
- func EthBloomLookup(bin EthBloom, topic bytesBacked) bool
- func HashData(kh KeccakState, data []byte) (h common.Hash)
- func IntrinsicGas(clauses ...*Clause) (uint64, error)
- type BlockRef
- type Builder
- func (b *Builder) BlockRef(br BlockRef) *Builder
- func (b *Builder) Build() *Transaction
- func (b *Builder) ChainTag(tag byte) *Builder
- func (b *Builder) Clause(c *Clause) *Builder
- func (b *Builder) DependsOn(txID *meter.Bytes32) *Builder
- func (b *Builder) Expiration(exp uint32) *Builder
- func (b *Builder) Gas(gas uint64) *Builder
- func (b *Builder) GasPriceCoef(coef uint8) *Builder
- func (b *Builder) Nonce(nonce uint64) *Builder
- type Clause
- func (c *Clause) Data() []byte
- func (c *Clause) DecodeRLP(s *rlp.Stream) error
- func (c *Clause) EncodeRLP(w io.Writer) error
- func (c *Clause) IsCreatingContract() bool
- func (c *Clause) String() string
- func (c *Clause) To() *meter.Address
- func (c *Clause) Token() byte
- func (c *Clause) UniteHash() (hash meter.Bytes32)
- func (c *Clause) Value() *big.Int
- func (c *Clause) WithData(data []byte) *Clause
- func (c *Clause) WithToken(token byte) *Clause
- func (c *Clause) WithValue(value *big.Int) *Clause
- type EthBloom
- type Event
- type Events
- type KeccakState
- type Output
- type Receipt
- type Receipts
- type Transaction
- func (t *Transaction) BlockRef() (br BlockRef)
- func (t *Transaction) ChainTag() byte
- func (t *Transaction) Clauses() []*Clause
- func (t *Transaction) DecodeRLP(s *rlp.Stream) error
- func (t *Transaction) DependsOn() *meter.Bytes32
- func (t *Transaction) EncodeRLP(w io.Writer) error
- func (t *Transaction) EthTxValidate() (bool, error)
- func (t *Transaction) EvaluateWork(signer meter.Address) func(nonce uint64) *big.Int
- func (t *Transaction) Expiration() uint32
- func (t *Transaction) Gas() uint64
- func (t *Transaction) GasPrice(baseGasPrice *big.Int) *big.Int
- func (t *Transaction) GasPriceCoef() uint8
- func (t *Transaction) GetEthTx() (*types.Transaction, error)
- func (t *Transaction) HasReservedFields() bool
- func (t *Transaction) ID() (id meter.Bytes32)
- func (t *Transaction) IntrinsicGas() (uint64, error)
- func (t *Transaction) IsEthTx() bool
- func (t *Transaction) IsExpired(blockNum uint32) bool
- func (t *Transaction) MeterID() (id meter.Bytes32)
- func (t *Transaction) Nonce() uint64
- func (t *Transaction) OverallGasPrice(baseGasPrice *big.Int, headBlockNum uint32, ...) *big.Int
- func (t *Transaction) ProvedWork(headBlockNum uint32, getBlockID func(uint32) meter.Bytes32) *big.Int
- func (t *Transaction) Signature() []byte
- func (t *Transaction) Signer() (signer meter.Address, err error)
- func (t *Transaction) SigningHash() (hash meter.Bytes32)
- func (t *Transaction) Size() metric.StorageSize
- func (t *Transaction) String() string
- func (t *Transaction) UniteHash() (hash meter.Bytes32)
- func (t *Transaction) UnprovedWork() (w *big.Int)
- func (t *Transaction) WithSignature(sig []byte) *Transaction
- type Transactions
- type Transfer
- type Transfers
Constants ¶
const ( // EthBloomByteLength represents the number of bytes used in a header log bloom. EthBloomByteLength = 256 // EthBloomBitLength represents the number of bits used in a header log bloom. EthBloomBitLength = 8 * EthBloomByteLength )
Variables ¶
var (
RESERVED_PREFIX = []byte{0xee, 0xff}
)
Functions ¶
func EthBloomLookup ¶ added in v1.2.0
EthBloomLookup is a convenience-method to check presence int he bloom filter
func HashData ¶ added in v1.2.0
func HashData(kh KeccakState, data []byte) (h common.Hash)
HashData hashes the provided data using the KeccakState and returns a 32 byte hash
func IntrinsicGas ¶
IntrinsicGas calculate intrinsic gas cost for tx with such clauses.
Types ¶
type BlockRef ¶
type BlockRef [8]byte
BlockRef is block reference.
func NewBlockRef ¶
NewBlockRef create block reference with block number.
func NewBlockRefFromID ¶
NewBlockRefFromID create block reference from block id.
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder to make it easy to build transaction.
func (*Builder) Expiration ¶
Expiration set expiration.
func (*Builder) GasPriceCoef ¶
GasPriceCoef set gas price coef.
type Clause ¶
type Clause struct {
// contains filtered or unexported fields
}
Clause is the basic execution unit of a transaction.
func (*Clause) IsCreatingContract ¶
IsCreatingContract return if this clause is going to create a contract.
type EthBloom ¶ added in v1.2.0
type EthBloom [EthBloomByteLength]byte
EthBloom represents a 2048 bit bloom filter.
func BytesToEthBloom ¶ added in v1.2.0
BytesToEthBloom converts a byte slice to a bloom filter. It panics if b is not of suitable size.
func CreateEthBloom ¶ added in v1.2.0
CreateEthBloom creates a bloom filter out of the give Receipts (+Logs)
func (*EthBloom) Add ¶ added in v1.2.0
Add adds d to the filter. Future calls of Test(d) will return true.
func (EthBloom) Big ¶ added in v1.2.0
Big converts b to a big integer. Note: Converting a bloom filter to a big.Int and then calling GetBytes does not return the same bytes, since big.Int will trim leading zeroes
func (EthBloom) MarshalText ¶ added in v1.2.0
MarshalText encodes b as a hex string with 0x prefix.
func (*EthBloom) SetBytes ¶ added in v1.2.0
SetBytes sets the content of b to the given bytes. It panics if d is not of suitable size.
func (EthBloom) Test ¶ added in v1.2.0
Test checks if the given topic is present in the bloom filter
func (*EthBloom) UnmarshalText ¶ added in v1.2.0
UnmarshalText b as a hex string with 0x prefix.
type Event ¶
type Event struct { // address of the contract that generated the event Address meter.Address `json:"address"` // list of topics provided by the contract. Topics []meter.Bytes32 `json:"topics"` // supplied by the contract, usually ABI-encoded Data []byte `json:"data"` }
Event represents a contract event log. These events are generated by the LOG opcode and stored/indexed by the node.
type KeccakState ¶ added in v1.2.0
KeccakState wraps sha3.state. In addition to the usual hash methods, it also supports Read to get a variable amount of data from the hash state. Read is faster than Sum because it doesn't copy the internal state, but also modifies the internal state.
func NewKeccakState ¶ added in v1.2.0
func NewKeccakState() KeccakState
NewKeccakState creates a new KeccakState
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 meter.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 Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction is an immutable tx type.
func NewTransactionFromEthTx ¶ added in v1.2.0
func NewTransactionFromEthTx(ethTx *types.Transaction, chainTag byte, blockRef BlockRef, verbose bool) (*Transaction, error)
func (*Transaction) BlockRef ¶
func (t *Transaction) BlockRef() (br BlockRef)
BlockRef returns block reference, which is first 8 bytes of block hash.
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() *meter.Bytes32
DependsOn returns depended tx hash.
func (*Transaction) EncodeRLP ¶
func (t *Transaction) EncodeRLP(w io.Writer) error
EncodeRLP implements rlp.Encoder
func (*Transaction) EthTxValidate ¶ added in v1.2.0
func (t *Transaction) EthTxValidate() (bool, error)
func (*Transaction) EvaluateWork ¶
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) 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) GetEthTx ¶ added in v1.2.0
func (t *Transaction) GetEthTx() (*types.Transaction, error)
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 meter.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) IsEthTx ¶ added in v1.2.0
func (t *Transaction) IsEthTx() bool
func (*Transaction) IsExpired ¶
func (t *Transaction) IsExpired(blockNum uint32) bool
IsExpired returns whether the tx is expired according to the given blockNum.
func (*Transaction) MeterID ¶ added in v1.2.0
func (t *Transaction) MeterID() (id meter.Bytes32)
func (*Transaction) OverallGasPrice ¶
func (t *Transaction) OverallGasPrice(baseGasPrice *big.Int, headBlockNum uint32, getBlockID func(uint32) meter.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) meter.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 meter.Address, err error)
Signer extract signer of tx from signature.
func (*Transaction) SigningHash ¶
func (t *Transaction) SigningHash() (hash meter.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) UniteHash ¶ added in v1.2.0
func (t *Transaction) UniteHash() (hash meter.Bytes32)
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() meter.Bytes32
RootHash computes merkle root hash of transactions.