Documentation ¶
Index ¶
- Constants
- Variables
- func BigMin(x, y *big.Int) *big.Int
- func CalcUncleHash(uncles []*Header) entity.Hash
- func ConvertLegacyStoredReceipts(raw []byte) ([]byte, error)
- func DeriveSha(list DerivableList, hasher TrieHasher) entity.Hash
- func HashDifference(a, b []entity.Hash) []entity.Hash
- func HeaderParentHashFromRLP(header []byte) entity.Hash
- func IsLegacyStoredReceipts(raw []byte) (bool, error)
- func PrefixedRlpHash(prefix byte, x interface{}) (h entity.Hash)
- func RlpHash(x interface{}) (h entity.Hash)
- func Sender(signer Signer, tx *Transaction) (entity.Address, error)
- type Block
- func (b *Block) BaseFee() *big.Int
- func (b *Block) Body() *Body
- func (b *Block) Coinbase() entity.Address
- func (b *Block) Difficulty() *big.Int
- func (b *Block) EncodeRLP(w io.Writer) error
- func (b *Block) GasLimit() uint64
- func (b *Block) GasUsed() uint64
- func (b *Block) Hash() entity.Hash
- func (b *Block) Header() *Header
- func (b *Block) Nonce() uint64
- func (b *Block) Number() *big.Int
- func (b *Block) NumberU64() uint64
- func (b *Block) ParentHash() entity.Hash
- func (b *Block) ReceiptHash() entity.Hash
- func (b *Block) Root() entity.Hash
- func (b *Block) SanityCheck() error
- func (b *Block) Size() utils.StorageSize
- func (b *Block) Time() uint64
- func (b *Block) Transactions() Transactions
- func (b *Block) TxHash() entity.Hash
- func (b *Block) UncleHash() entity.Hash
- func (b *Block) Uncles() []*Header
- func (b *Block) WithBody(transactions []*Transaction, uncles []*Header) *Block
- func (b *Block) WithSeal(header *Header) *Block
- type BlockNonce
- type Blocks
- type Body
- type DerivableList
- type DynamicFeeTx
- type EIP155Signer
- func (s EIP155Signer) ChainID() *big.Int
- func (s EIP155Signer) Equal(s2 Signer) bool
- func (s EIP155Signer) Hash(tx *Transaction) entity.Hash
- func (s EIP155Signer) Sender(tx *Transaction) (entity.Address, error)
- func (s EIP155Signer) SignatureValues(tx *Transaction, sig []byte) (R, S, V *big.Int, err error)
- type FrontierSigner
- func (s FrontierSigner) ChainID() *big.Int
- func (s FrontierSigner) Equal(s2 Signer) bool
- func (fs FrontierSigner) Hash(tx *Transaction) entity.Hash
- func (fs FrontierSigner) Sender(tx *Transaction) (entity.Address, error)
- func (fs FrontierSigner) SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error)
- type Header
- type HomesteadSigner
- func (s HomesteadSigner) ChainID() *big.Int
- func (s HomesteadSigner) Equal(s2 Signer) bool
- func (s HomesteadSigner) Hash(tx *Transaction) entity.Hash
- func (hs HomesteadSigner) Sender(tx *Transaction) (entity.Address, error)
- func (hs HomesteadSigner) SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error)
- type LegacyTx
- type Log
- type LogForStorage
- type Message
- func (m Message) Data() []byte
- func (m Message) From() entity.Address
- func (m Message) Gas() uint64
- func (m Message) GasFeeCap() *big.Int
- func (m Message) GasPrice() *big.Int
- func (m Message) GasTipCap() *big.Int
- func (m Message) IsFake() bool
- func (m Message) Nonce() uint64
- func (m Message) To() *entity.Address
- func (m Message) Value() *big.Int
- type Receipt
- type ReceiptForStorage
- type Receipts
- type Signer
- type Transaction
- func (tx *Transaction) AsMessage(s Signer, baseFee *big.Int) (Message, error)
- func (tx *Transaction) ChainId() *big.Int
- func (tx *Transaction) Cost() *big.Int
- func (tx *Transaction) Data() []byte
- func (tx *Transaction) EffectiveGasTip(baseFee *big.Int) (*big.Int, error)
- func (tx *Transaction) EffectiveGasTipCmp(other *Transaction, baseFee *big.Int) int
- func (tx *Transaction) EffectiveGasTipValue(baseFee *big.Int) *big.Int
- func (tx *Transaction) Gas() uint64
- func (tx *Transaction) GasFeeCap() *big.Int
- func (tx *Transaction) GasFeeCapCmp(other *Transaction) int
- func (tx *Transaction) GasFeeCapIntCmp(other *big.Int) int
- func (tx *Transaction) GasPrice() *big.Int
- func (tx *Transaction) GasTipCap() *big.Int
- func (tx *Transaction) GasTipCapCmp(other *Transaction) int
- func (tx *Transaction) GasTipCapIntCmp(other *big.Int) int
- func (tx *Transaction) Hash() entity.Hash
- func (tx *Transaction) MarshalBinary() ([]byte, error)
- func (tx *Transaction) Nonce() uint64
- func (tx *Transaction) Protected() bool
- func (tx *Transaction) RawSignatureValues() (v, r, s *big.Int)
- func (tx *Transaction) Size() utils.StorageSize
- func (tx *Transaction) To() *entity.Address
- func (tx *Transaction) Type() uint8
- func (tx *Transaction) UnmarshalBinary(b []byte) error
- func (tx *Transaction) Value() *big.Int
- func (tx *Transaction) WithSignature(signer Signer, sig []byte) (*Transaction, error)
- type TransactionArgs
- type Transactions
- type TransactionsByPriceAndNonce
- type TrieHasher
- type TxByNonce
- type TxByPriceAndTime
- type TxData
- type TxWithMinerFee
Constants ¶
const ( // ReceiptStatusFailed是执行失败时事务的状态代码。 ReceiptStatusFailed = uint64(0) // ReceiptStatusSuccessful是执行成功时事务的状态代码。 ReceiptStatusSuccessful = uint64(1) )
const ( LegacyTxType = iota AccessListTxType DynamicFeeTxType )
Variables ¶
var ( EmptyRootHash = entity.HexToHash("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421") EmptyUncleHash = RlpHash([]*Header(nil)) )
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") )
var ErrInvalidChainId = errors.New("invalid chain id for signer")
Functions ¶
func CalcUncleHash ¶
func ConvertLegacyStoredReceipts ¶
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 ¶
HashDifference返回一个新集,即a和b之间的差。
func HeaderParentHashFromRLP ¶
HeaderParentHashFromRLP返回RLP编码头的parentHash。 如果“header”无效,则返回零哈希。
func IsLegacyStoredReceipts ¶
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 ¶
prefixedRlpHash在rlp编码x之前将前缀写入哈希器。它用于类型化事务。
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 ¶
NewBlockWithHeader使用给定的标头数据创建块。复制标头数据,对标头和字段值的更改不会影响块。
func (*Block) Difficulty ¶
func (*Block) ParentHash ¶
func (*Block) ReceiptHash ¶
func (*Block) Size ¶
func (b *Block) Size() utils.StorageSize
Size通过编码并返回块,或返回先前缓存的值,返回块的真实RLP编码存储大小。
type BlockNonce ¶
type BlockNonce [8]byte
type DerivableList ¶
可派生列表是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 ¶
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 (*Header) EmptyReceipts ¶
如果此标头/块没有收据,则EmptyReceipts返回true。
func (*Header) SanityCheck ¶
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.
type LogForStorage ¶
type LogForStorage Log
LogForStorage is a wrapper around a Log that handles backward compatibility with prior storage formats.
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
交易消息结构体
func NewMessage ¶
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 ¶
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 ¶
EncodeIndex将第i个收据编码为w。
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 ¶
LatestSignerForChainID返回可用的“最允许的”签名者。具体而言,如果chainID为非nil,这将支持EIP-155重播保护和所有实现的EIP-2718事务类型。 在当前块号和fork配置未知的事务处理代码中使用此选项。 如果您有一个ChainConfig,请改用LatestSigner。如果您有一个ChainConfig并知道当前的块号,请改用MakeSigner。
func NewLondonSigner ¶
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 SignTx ¶
func SignTx(tx *Transaction, s Signer, prv *ecdsa.PrivateKey) (*Transaction, error)
SignTx使用给定的签名者和私钥对事务进行签名。
func (*Transaction) ChainId ¶
func (tx *Transaction) ChainId() *big.Int
ChainId返回事务的EIP155链ID。返回值将始终为非nil。对于不受重播保护的旧事务,返回值为零。
func (*Transaction) Data ¶
func (tx *Transaction) Data() []byte
func (*Transaction) EffectiveGasTip ¶
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) GasFeeCapCmp ¶
func (tx *Transaction) GasFeeCapCmp(other *Transaction) int
GasFeeCapCmp比较了两项交易的费用上限。
func (*Transaction) GasFeeCapIntCmp ¶
func (tx *Transaction) GasFeeCapIntCmp(other *big.Int) int
GasFeeCapIntCmp将交易的费用上限与给定的费用上限进行比较。
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) MarshalBinary ¶
func (tx *Transaction) MarshalBinary() ([]byte, error)
MarshalBinary返回事务的规范编码。 对于遗留事务,它返回RLP编码。对于EIP-2718类型的事务,它返回类型和负载。
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) UnmarshalBinary ¶
func (tx *Transaction) UnmarshalBinary(b []byte) error
解组二进制解码事务的规范编码。它支持传统RLP事务和EIP2718类型的事务。
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 ¶
func (t *TransactionsByPriceAndNonce) Peek() *Transaction
Peek按价格返回下一笔交易。
func (*TransactionsByPriceAndNonce) Pop ¶
func (t *TransactionsByPriceAndNonce) Pop()
Pop删除最佳交易,*而不是*将其替换为同一帐户中的下一个交易。 当交易无法执行时,应使用此选项,因此应从同一帐户中丢弃所有后续交易。
func (*TransactionsByPriceAndNonce) Shift ¶
func (t *TransactionsByPriceAndNonce) Shift()
Shift将当前的最佳头部替换为同一帐户中的下一个头部。
type TrieHasher ¶
TrieHasher是用于计算可派生列表的哈希的工具。
type TxByNonce ¶
type TxByNonce Transactions
txbynone实现了sort接口,允许按nonce对事务列表进行排序。这通常只在对单个帐户中的交易进行排序时有用,否则nonce比较没有多大意义。
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 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为负值,则返回错误。