block

package
v0.0.0-...-de85661 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: Unlicense Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ReceiptStatusFailed是执行失败时事务的状态代码。
	ReceiptStatusFailed = uint64(0)

	// ReceiptStatusSuccessful是执行成功时事务的状态代码。
	ReceiptStatusSuccessful = uint64(1)
)
View Source
const (
	LegacyTxType = iota
	AccessListTxType
	DynamicFeeTxType
)

Variables

View Source
var (
	EmptyRootHash  = entity.HexToHash("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")
	EmptyUncleHash = RlpHash([]*Header(nil))
)
View Source
var (
	ErrInvalidSig           = errors.New("invalid transaction v, r, s values")
	ErrUnexpectedProtection = errors.New("transaction type does not supported EIP-155 protected signatures")
	ErrInvalidTxType        = errors.New("transaction type not valid in this context")
	ErrTxTypeNotSupported   = errors.New("transaction type not supported")
	ErrGasFeeCapTooLow      = errors.New("fee cap less than base fee")
)
View Source
var ErrInvalidChainId = errors.New("invalid chain id for signer")

Functions

func BigMin

func BigMin(x, y *big.Int) *big.Int

返回x或y中的较小值。

func CalcUncleHash

func CalcUncleHash(uncles []*Header) entity.Hash

func ConvertLegacyStoredReceipts

func ConvertLegacyStoredReceipts(raw []byte) ([]byte, error)

ConvertLegacyStoredReceipts takes the RLP encoding of an array of legacy stored receipts and returns a fresh RLP-encoded stored receipt.

func DeriveSha

func DeriveSha(list DerivableList, hasher TrieHasher) entity.Hash

DeriveSha在块头中创建事务和收据的树哈希。

func HashDifference

func HashDifference(a, b []entity.Hash) []entity.Hash

HashDifference返回一个新集,即a和b之间的差。

func HeaderParentHashFromRLP

func HeaderParentHashFromRLP(header []byte) entity.Hash

HeaderParentHashFromRLP返回RLP编码头的parentHash。 如果“header”无效,则返回零哈希。

func IsLegacyStoredReceipts

func IsLegacyStoredReceipts(raw []byte) (bool, error)

IsLegacyStoredReceipts tries to parse the RLP-encoded blob first as an array of v3 stored receipt, then v4 stored receipt and returns true if successful.

func PrefixedRlpHash

func PrefixedRlpHash(prefix byte, x interface{}) (h entity.Hash)

prefixedRlpHash在rlp编码x之前将前缀写入哈希器。它用于类型化事务。

func RlpHash

func RlpHash(x interface{}) (h entity.Hash)

rlpHash对x进行编码,并对编码的字节进行哈希运算。

func Sender

func Sender(signer Signer, tx *Transaction) (entity.Address, error)

Types

type Block

type Block struct {

	// 包eth使用这些字段来跟踪对等块中继。
	ReceivedAt   time.Time
	ReceivedFrom interface{}
	// contains filtered or unexported fields
}

func NewBlock

func NewBlock(header *Header, txs []*Transaction, receipts []*Receipt, hasher TrieHasher) *Block

新块创建新块。复制输入数据,对标题和字段值的更改不会影响块。 头中的TxHash、uncleshash、ReceiptHash和Bloom的值将被忽略,并设置为从给定的txs、uncles和receipts派生的值。

func NewBlockWithHeader

func NewBlockWithHeader(header *Header) *Block

NewBlockWithHeader使用给定的标头数据创建块。复制标头数据,对标头和字段值的更改不会影响块。

func (*Block) BaseFee

func (b *Block) BaseFee() *big.Int

func (*Block) Body

func (b *Block) Body() *Body

Body returns the non-header content of the block.

func (*Block) Coinbase

func (b *Block) Coinbase() entity.Address

func (*Block) Difficulty

func (b *Block) Difficulty() *big.Int

func (*Block) EncodeRLP

func (b *Block) EncodeRLP(w io.Writer) error

编码器RLP将b序列化为辐射章鱼RLP块格式。

func (*Block) GasLimit

func (b *Block) GasLimit() uint64

func (*Block) GasUsed

func (b *Block) GasUsed() uint64

func (*Block) Hash

func (b *Block) Hash() entity.Hash

func (*Block) Header

func (b *Block) Header() *Header

func (*Block) Nonce

func (b *Block) Nonce() uint64

func (*Block) Number

func (b *Block) Number() *big.Int

func (*Block) NumberU64

func (b *Block) NumberU64() uint64

func (*Block) ParentHash

func (b *Block) ParentHash() entity.Hash

func (*Block) ReceiptHash

func (b *Block) ReceiptHash() entity.Hash

func (*Block) Root

func (b *Block) Root() entity.Hash

func (*Block) SanityCheck

func (b *Block) SanityCheck() error

SanityCheck可用于防止无界字段塞满垃圾数据,从而增加处理开销

func (*Block) Size

func (b *Block) Size() utils.StorageSize

Size通过编码并返回块,或返回先前缓存的值,返回块的真实RLP编码存储大小。

func (*Block) Time

func (b *Block) Time() uint64

func (*Block) Transactions

func (b *Block) Transactions() Transactions

获取交易集

func (*Block) TxHash

func (b *Block) TxHash() entity.Hash

func (*Block) UncleHash

func (b *Block) UncleHash() entity.Hash

func (*Block) Uncles

func (b *Block) Uncles() []*Header

func (*Block) WithBody

func (b *Block) WithBody(transactions []*Transaction, uncles []*Header) *Block

WithBody返回具有给定事务和叔叔内容的新块.

func (*Block) WithSeal

func (b *Block) WithSeal(header *Header) *Block

WithSeal返回一个新块,其中包含来自b的数据,但标头替换为密封的数据块。

type BlockNonce

type BlockNonce [8]byte

func EncodeNonce

func EncodeNonce(i uint64) BlockNonce

EncodeNonce将给定整数转换为块nonce。

func (BlockNonce) Uint64

func (n BlockNonce) Uint64() uint64

Uint64返回块nonce的整数值。

type Blocks

type Blocks []*Block

type Body

type Body struct {
	Transactions []*Transaction
	Uncles       []*Header
}

数据容器

type DerivableList

type DerivableList interface {
	Len() int
	EncodeIndex(int, *bytes.Buffer)
}

可派生列表是DeriveSha的输入。 它由“交易”和“收据”类型实现。 这是内部的,不要使用这些方法。

type DynamicFeeTx

type DynamicFeeTx struct {
	ChainID   *big.Int
	Nonce     uint64
	GasTipCap *big.Int // a.k.a. maxPriorityFeePerGas
	GasFeeCap *big.Int // a.k.a. maxFeePerGas
	Gas       uint64
	To        *entity.Address `rlp:"nil"` // nil表示合同创建
	Value     *big.Int
	Data      []byte

	// 签名值
	V *big.Int `json:"v" gencodec:"required"`
	R *big.Int `json:"r" gencodec:"required"`
	S *big.Int `json:"s" gencodec:"required"`
}

type EIP155Signer

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

EIP155Signer使用EIP-155规则实现签名者。这接受受重播保护的交易以及未受保护的宅地交易。

func NewEIP155Signer

func NewEIP155Signer(chainId *big.Int) EIP155Signer

func (EIP155Signer) ChainID

func (s EIP155Signer) ChainID() *big.Int

func (EIP155Signer) Equal

func (s EIP155Signer) Equal(s2 Signer) bool

func (EIP155Signer) Hash

func (s EIP155Signer) Hash(tx *Transaction) entity.Hash

散列返回要由发送方签名的散列。它不能唯一标识交易。

func (EIP155Signer) Sender

func (s EIP155Signer) Sender(tx *Transaction) (entity.Address, error)

func (EIP155Signer) SignatureValues

func (s EIP155Signer) SignatureValues(tx *Transaction, sig []byte) (R, S, V *big.Int, err error)

SignatureValue返回签名值。此签名需要采用[R | | S | V]格式,其中V为0或1。

type FrontierSigner

type FrontierSigner struct{}

func (FrontierSigner) ChainID

func (s FrontierSigner) ChainID() *big.Int

func (FrontierSigner) Equal

func (s FrontierSigner) Equal(s2 Signer) bool

func (FrontierSigner) Hash

func (fs FrontierSigner) Hash(tx *Transaction) entity.Hash

散列返回要由发送方签名的散列。它不能唯一标识事务。

func (FrontierSigner) Sender

func (fs FrontierSigner) Sender(tx *Transaction) (entity.Address, error)

func (FrontierSigner) SignatureValues

func (fs FrontierSigner) SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error)

SignatureValue返回签名值。此签名需要采用[R | | S | V]格式,其中V为0或1。

type Header struct {
	ParentHash  entity.Hash    `autoInjectCfg:"octopus.blockchain.binding.genesis.header.parentHash"` //父hash
	UncleHash   entity.Hash    `autoInjectCfg:"octopus.blockchain.binding.genesis.header.uncleHash"`  //叔hash
	Coinbase    entity.Address //工作者地址值
	Root        entity.Hash    `autoInjectCfg:"octopus.blockchain.binding.genesis.header.root"`        //根hash
	TxHash      entity.Hash    `autoInjectCfg:"octopus.blockchain.binding.genesis.header.txhash"`      //交易hash
	ReceiptHash entity.Hash    `autoInjectCfg:"octopus.blockchain.binding.genesis.header.receiptHash"` //收据hash
	//Bloom       Bloom
	Difficulty *big.Int `autoInjectCfg:"octopus.blockchain.binding.genesis.header.difficulty"` //难度值
	Number     *big.Int `autoInjectCfg:"octopus.blockchain.binding.genesis.header.number"`     //数量
	GasLimit   uint64   `autoInjectCfg:"octopus.blockchain.binding.genesis.header.gasLimit"`   //gas限制
	GasUsed    uint64   `autoInjectCfg:"octopus.blockchain.binding.genesis.header.gasUsed"`    //gas总和
	Time       uint64   `autoInjectCfg:"octopus.blockchain.binding.genesis.header.time"`       //时间戳
	Extra      []byte
	MixDigest  entity.Hash `autoInjectCfg:"octopus.blockchain.binding.genesis.header.mixDigest"` //mixhash
	Nonce      BlockNonce  `autoInjectCfg:"octopus.blockchain.binding.genesis.header.nonce"`     //唯一标识s

	//基本费用
	BaseFee *big.Int `autoInjectCfg:"octopus.blockchain.binding.genesis.header.baseFee"`
}

区块头结构体

func CopyHeader

func CopyHeader(h *Header) *Header

func (*Header) EmptyBody

func (h *Header) EmptyBody() bool

如果没有额外的“body”来完成标头,则EmptyBody返回true,即:没有事务和未结项。

func (*Header) EmptyReceipts

func (h *Header) EmptyReceipts() bool

如果此标头/块没有收据,则EmptyReceipts返回true。

func (*Header) Hash

func (h *Header) Hash() entity.Hash

func (*Header) SanityCheck

func (h *Header) SanityCheck() error

SanityCheck检查了一些基本的东西——这些检查远远超出了任何“正常”生产值应该具备的范围, 主要用于防止无界字段塞满垃圾数据,从而增加处理开销

func (*Header) Size

func (h *Header) Size() utils.StorageSize

大小返回所有内部内容使用的近似内存。它用于近似和限制各种缓存的内存消耗。

type HomesteadSigner

type HomesteadSigner struct{ FrontierSigner }

HomesteadTransaction使用homestead规则实现TransactionInterface。

func (HomesteadSigner) ChainID

func (s HomesteadSigner) ChainID() *big.Int

func (HomesteadSigner) Equal

func (s HomesteadSigner) Equal(s2 Signer) bool

func (HomesteadSigner) Hash

func (s HomesteadSigner) Hash(tx *Transaction) entity.Hash

func (HomesteadSigner) Sender

func (hs HomesteadSigner) Sender(tx *Transaction) (entity.Address, error)

func (HomesteadSigner) SignatureValues

func (hs HomesteadSigner) SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error)

SignatureValue返回签名值。此签名需要采用[R | | S | V]格式,其中V为0或1。

type LegacyTx

type LegacyTx struct {
	Nonce    uint64          // 发件人帐户的nonce
	GasPrice *big.Int        // gas价格
	Gas      uint64          // gas限制
	To       *entity.Address `rlp:"nil"` // nil表示合同创建
	Value    *big.Int        // wei金额
	Data     []byte          // 合同调用输入数据
	V, R, S  *big.Int        // 签名值
}

LegacyTx是常规以太坊事务的事务数据。

type Log

type Log struct {
	// Consensus fields:
	// address of the contract that generated the event
	Address entity.Address `json:"address" gencodec:"required"`
	// list of topics provided by the contract.
	Topics []entity.Hash `json:"topics" gencodec:"required"`
	// supplied by the contract, usually ABI-encoded
	Data []byte `json:"data" gencodec:"required"`

	// Derived fields. These fields are filled in by the node
	// but not secured by consensus.
	// block in which the transaction was included
	BlockNumber uint64 `json:"blockNumber"`
	// hash of the transaction
	TxHash entity.Hash `json:"transactionHash" gencodec:"required"`
	// index of the transaction in the block
	TxIndex uint `json:"transactionIndex"`
	// hash of the block in which the transaction was included
	BlockHash entity.Hash `json:"blockHash"`
	// index of the log in the block
	Index uint `json:"logIndex"`

	// The Removed field is true if this log was reverted due to a chain reorganisation.
	// You must pay attention to this field if you receive logs through a filter query.
	Removed bool `json:"removed"`
}

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

func (*Log) DecodeRLP

func (l *Log) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder.

func (*Log) EncodeRLP

func (l *Log) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder.

type LogForStorage

type LogForStorage Log

LogForStorage is a wrapper around a Log that handles backward compatibility with prior storage formats.

func (*LogForStorage) DecodeRLP

func (l *LogForStorage) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder.

Note some redundant fields(e.g. block number, tx hash etc) will be assembled later.

func (*LogForStorage) EncodeRLP

func (l *LogForStorage) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder.

type Message

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

交易消息结构体

func NewMessage

func NewMessage(from entity.Address, to *entity.Address, nonce uint64, amount *big.Int, gasLimit uint64, gasPrice, gasFeeCap, gasTipCap *big.Int, data []byte, isFake bool) Message

func (Message) Data

func (m Message) Data() []byte

func (Message) From

func (m Message) From() entity.Address

func (Message) Gas

func (m Message) Gas() uint64

func (Message) GasFeeCap

func (m Message) GasFeeCap() *big.Int

func (Message) GasPrice

func (m Message) GasPrice() *big.Int

func (Message) GasTipCap

func (m Message) GasTipCap() *big.Int

func (Message) IsFake

func (m Message) IsFake() bool

func (Message) Nonce

func (m Message) Nonce() uint64

func (Message) To

func (m Message) To() *entity.Address

func (Message) Value

func (m Message) Value() *big.Int

type Receipt

type Receipt struct {
	// 共识领域:这些领域由黄皮书定义
	Type              uint8  `json:"type,omitempty"`
	PostState         []byte `json:"root"`
	Status            uint64 `json:"status"`
	CumulativeGasUsed uint64 `json:"cumulativeGasUsed" gencodec:"required"`
	//Bloom             Bloom  `json:"logsBloom"         gencodec:"required"`
	Logs []*Log `json:"logs"              gencodec:"required"`

	// 实现字段:这些字段由geth在处理事务时添加。它们存储在链数据库中。
	TxHash          entity.Hash    `json:"transactionHash" gencodec:"required"`
	ContractAddress entity.Address `json:"contractAddress"`
	GasUsed         uint64         `json:"gasUsed" gencodec:"required"`

	// 包含信息:这些字段提供有关包含与此收据对应的交易的信息。
	BlockHash        entity.Hash `json:"blockHash,omitempty"`
	BlockNumber      *big.Int    `json:"blockNumber,omitempty"`
	TransactionIndex uint        `json:"transactionIndex"`
}

收据代表交易的返回结果

func (*Receipt) MarshalBinary

func (r *Receipt) MarshalBinary() ([]byte, error)

MarshalBinary返回回执的一致编码。

func (*Receipt) Size

func (r *Receipt) Size() utils.StorageSize

大小返回所有内部内容使用的近似内存。它用于近似和限制各种缓存的内存消耗。

type ReceiptForStorage

type ReceiptForStorage Receipt

ReceiptForStorage是使用RLP序列化的回执的包装器,它省略了Bloom字段,并进行了重新计算的反序列化。

type Receipts

type Receipts []*Receipt

收据列表

func (Receipts) DeriveFields

func (rs Receipts) DeriveFields(config *entity.ChainConfig, hash entity.Hash, number uint64, txs Transactions) error

DeriveFields使用基于共识数据和上下文信息(如包含块和事务)的计算字段填充收据。

func (Receipts) EncodeIndex

func (rs Receipts) EncodeIndex(i int, w *bytes.Buffer)

EncodeIndex将第i个收据编码为w。

func (Receipts) Len

func (rs Receipts) Len() int

Len返回此列表中的收据数。

type Signer

type Signer interface {
	// 发件人返回交易的发件人地址。
	Sender(tx *Transaction) (entity.Address, error)

	// 返回与给定签名相对应的原始R、S、V值。
	SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error)
	ChainID() *big.Int

	// 返回“签名哈希”,即由私钥签名的事务哈希。此哈希不能唯一标识事务。
	Hash(tx *Transaction) entity.Hash

	// 如果给定的签名者与接收方相同,则Equal返回true。
	Equal(Signer) bool
}

func LatestSigner

func LatestSigner() Signer

LatestSigner返回给定链配置可用的“最有权限”签名者。 具体而言,当EIP-155重播保护和EIP-2930访问列表事务各自的分叉计划在链配置中的任何块号上发生时,这将支持EIP-155重播保护和EIP-2930访问列表事务。 在当前块号未知的事务处理代码中使用此选项。如果当前块号可用,请改用MakeSigner。

func LatestSignerForChainID

func LatestSignerForChainID(chainID *big.Int) Signer

LatestSignerForChainID返回可用的“最允许的”签名者。具体而言,如果chainID为非nil,这将支持EIP-155重播保护和所有实现的EIP-2718事务类型。 在当前块号和fork配置未知的事务处理代码中使用此选项。 如果您有一个ChainConfig,请改用LatestSigner。如果您有一个ChainConfig并知道当前的块号,请改用MakeSigner。

func MakeSigner

func MakeSigner(blockNumber *big.Int) Signer

根据给定的链配置和块编号返回签名者。

func NewLondonSigner

func NewLondonSigner(chainId *big.Int) Signer

NewLondonSigner,返回接受 -EIP-1559动态费用交易 -EIP-2930访问列表事务, -EIP-155重播受保护的事务,以及 -遗留宅地交易。

type Transaction

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

func NewTransaction

func NewTransaction(nonce uint64, to entity.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction

NewTransaction创建未签名的旧事务。不推荐使用:改用NewTx。

func NewTx

func NewTx(inner TxData) *Transaction

NewTx创建一个新事务。

func SignTx

func SignTx(tx *Transaction, s Signer, prv *ecdsa.PrivateKey) (*Transaction, error)

SignTx使用给定的签名者和私钥对事务进行签名。

func (*Transaction) AsMessage

func (tx *Transaction) AsMessage(s Signer, baseFee *big.Int) (Message, error)

作为核心信息返回

func (*Transaction) ChainId

func (tx *Transaction) ChainId() *big.Int

ChainId返回事务的EIP155链ID。返回值将始终为非nil。对于不受重播保护的旧事务,返回值为零。

func (*Transaction) Cost

func (tx *Transaction) Cost() *big.Int

成本返回gas*gasPrice+价值。

func (*Transaction) Data

func (tx *Transaction) Data() []byte

func (*Transaction) EffectiveGasTip

func (tx *Transaction) EffectiveGasTip(baseFee *big.Int) (*big.Int, error)

EffectiveGasTip返回给定基本费用的有工作者gasticpap。注意:如果有效gasTipCap为负值,此方法将同时返回实际负值error和ErrGasFeeCapTooLow

func (*Transaction) EffectiveGasTipCmp

func (tx *Transaction) EffectiveGasTipCmp(other *Transaction, baseFee *big.Int) int

effectivegasticpmp比较假定给定基本费用的两个事务的有效gasticpap。

func (*Transaction) EffectiveGasTipValue

func (tx *Transaction) EffectiveGasTipValue(baseFee *big.Int) *big.Int

EffectiveGasTipValue与EffectiveGasTip相同,但如果有效gasTipCap为负值,则不会返回错误

func (*Transaction) Gas

func (tx *Transaction) Gas() uint64

返回交易的gas限制

func (*Transaction) GasFeeCap

func (tx *Transaction) GasFeeCap() *big.Int

返回交易中每个gas的费用上限

func (*Transaction) GasFeeCapCmp

func (tx *Transaction) GasFeeCapCmp(other *Transaction) int

GasFeeCapCmp比较了两项交易的费用上限。

func (*Transaction) GasFeeCapIntCmp

func (tx *Transaction) GasFeeCapIntCmp(other *big.Int) int

GasFeeCapIntCmp将交易的费用上限与给定的费用上限进行比较。

func (*Transaction) GasPrice

func (tx *Transaction) GasPrice() *big.Int

返回交易的gas价格

func (*Transaction) GasTipCap

func (tx *Transaction) GasTipCap() *big.Int

返回交易的gas价格上限

func (*Transaction) GasTipCapCmp

func (tx *Transaction) GasTipCapCmp(other *Transaction) int

gasticpapcmp比较两个事务的gasticpap。

func (*Transaction) GasTipCapIntCmp

func (tx *Transaction) GasTipCapIntCmp(other *big.Int) int

gasticpapintcmp将事务的gasticpap与给定的gasticpap进行比较。

func (*Transaction) Hash

func (tx *Transaction) Hash() entity.Hash

返回交易hash

func (*Transaction) MarshalBinary

func (tx *Transaction) MarshalBinary() ([]byte, error)

MarshalBinary返回事务的规范编码。 对于遗留事务,它返回RLP编码。对于EIP-2718类型的事务,它返回类型和负载。

func (*Transaction) Nonce

func (tx *Transaction) Nonce() uint64

返回交易的发送方账户nonce

func (*Transaction) Protected

func (tx *Transaction) Protected() bool

Protected表示事务是否受重播保护。

func (*Transaction) RawSignatureValues

func (tx *Transaction) RawSignatureValues() (v, r, s *big.Int)

RawSignatureValue返回事务的V、R、S签名值。调用者不应修改返回值。

func (*Transaction) Size

func (tx *Transaction) Size() utils.StorageSize

Size通过编码并返回事务的真实RLP编码存储大小,或返回以前缓存的值。

func (*Transaction) To

func (tx *Transaction) To() *entity.Address

返回交易的收件人地址

func (*Transaction) Type

func (tx *Transaction) Type() uint8

类型返回事务类型。

func (*Transaction) UnmarshalBinary

func (tx *Transaction) UnmarshalBinary(b []byte) error

解组二进制解码事务的规范编码。它支持传统RLP事务和EIP2718类型的事务。

func (*Transaction) Value

func (tx *Transaction) Value() *big.Int

返回交易的金额

func (*Transaction) WithSignature

func (tx *Transaction) WithSignature(signer Signer, sig []byte) (*Transaction, error)

WithSignature返回具有给定签名的新事务。此签名需要采用[R | | S | V]格式,其中V为0或1。

type TransactionArgs

type TransactionArgs struct {
	From                 *entity.Address        `json:"from"`
	To                   *entity.Address        `json:"to"`
	Gas                  *operationutils.Uint64 `json:"gas"`
	GasPrice             *operationutils.Big    `json:"gasPrice"`
	MaxFeePerGas         *operationutils.Big    `json:"maxFeePerGas"`
	MaxPriorityFeePerGas *operationutils.Big    `json:"maxPriorityFeePerGas"`
	Value                *operationutils.Big    `json:"value"`
	Nonce                *operationutils.Uint64 `json:"nonce"`

	// 出于向后兼容性的原因,我们接受“数据”和“输入”。“input”是一个较新的名称,客户端应首选它。
	Data  *operationutils.Bytes `json:"data"`
	Input *operationutils.Bytes `json:"input"`

	// 由AccessListTxType事务引入。AccessList*类型。AccessList `json:“AccessList,省略empty”`
	ChainID *operationutils.Big `json:"chainId,omitempty"`
}

TransactionArgs表示构造新事务或消息调用的参数。

func (*TransactionArgs) FromAddr

func (args *TransactionArgs) FromAddr() entity.Address

从检索事务发送方地址。

func (*TransactionArgs) ToTransaction

func (args *TransactionArgs) ToTransaction() *Transaction

toTransaction将参数转换为事务。这假定已调用setDefaults。

type Transactions

type Transactions []*Transaction

func TxDifference

func TxDifference(a, b Transactions) Transactions

TxDifference返回一个新的集合,即a和b之间的差值。

func (Transactions) EncodeIndex

func (s Transactions) EncodeIndex(i int, w *bytes.Buffer)

EncodeIndex将第i个事务编码为w。请注意,这不会检查错误,因为我们假设*事务将只包含通过解码或通过此包中的公共API构造的有效TX。

func (Transactions) Len

func (s Transactions) Len() int

type TransactionsByPriceAndNonce

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

TransactionsByPriceAndNonce表示一组事务,这些事务可以按利润最大化的排序顺序返回事务,同时支持删除不可执行帐户的整批事务。

func NewTransactionsByPriceAndNonce

func NewTransactionsByPriceAndNonce(signer Signer, txs map[entity.Address]Transactions, baseFee *big.Int) *TransactionsByPriceAndNonce

NewTransactionsByPriceAndOnce创建一个交易集,该交易集可以以暂时兑现的方式检索按价格排序的交易。 注意,输入映射被重新拥有,因此调用方在将其提供给构造函数后不应再与if进行交互。

func (*TransactionsByPriceAndNonce) Peek

Peek按价格返回下一笔交易。

func (*TransactionsByPriceAndNonce) Pop

func (t *TransactionsByPriceAndNonce) Pop()

Pop删除最佳交易,*而不是*将其替换为同一帐户中的下一个交易。 当交易无法执行时,应使用此选项,因此应从同一帐户中丢弃所有后续交易。

func (*TransactionsByPriceAndNonce) Shift

func (t *TransactionsByPriceAndNonce) Shift()

Shift将当前的最佳头部替换为同一帐户中的下一个头部。

type TrieHasher

type TrieHasher interface {
	Reset()
	Update([]byte, []byte)
	Hash() entity.Hash
}

TrieHasher是用于计算可派生列表的哈希的工具。

type TxByNonce

type TxByNonce Transactions

txbynone实现了sort接口,允许按nonce对事务列表进行排序。这通常只在对单个帐户中的交易进行排序时有用,否则nonce比较没有多大意义。

func (TxByNonce) Len

func (s TxByNonce) Len() int

func (TxByNonce) Less

func (s TxByNonce) Less(i, j int) bool

func (TxByNonce) Swap

func (s TxByNonce) Swap(i, j int)

type TxByPriceAndTime

type TxByPriceAndTime []*TxWithMinerFee

TxByPriceAndTime实现了sort和heap接口,这使得它对于一次性排序以及单独添加和删除元素非常有用。

func (TxByPriceAndTime) Len

func (s TxByPriceAndTime) Len() int

func (TxByPriceAndTime) Less

func (s TxByPriceAndTime) Less(i, j int) bool

func (*TxByPriceAndTime) Pop

func (s *TxByPriceAndTime) Pop() interface{}

func (*TxByPriceAndTime) Push

func (s *TxByPriceAndTime) Push(x interface{})

func (TxByPriceAndTime) Swap

func (s TxByPriceAndTime) Swap(i, j int)

type TxData

type TxData interface {
	// contains filtered or unexported methods
}

type TxWithMinerFee

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

TxWithMinerFee用其天然气价格或有效的miner Gasticap来包装交易

func NewTxWithMinerFee

func NewTxWithMinerFee(tx *Transaction, baseFee *big.Int) (*TxWithMinerFee, error)

NewTxWithMinerFee创建一个打包的事务,如果提供了基本费用,则计算有效的miner Gasticap。如果有效miner gasTipCap为负值,则返回错误。

Jump to

Keyboard shortcuts

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