Documentation ¶
Overview ¶
Package util contains eth type utils
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyTX ¶ added in v0.0.76
func CopyTX(unsignedTx *types.Transaction, options ...CopyOption) (*types.Transaction, error)
CopyTX copies a transaction and sets the nonce to the given value. Note: when copying from a dynamic tx to a legacy tx, the chain id cannot be copied over since it's embedded in the signature rather than the rlp envelope. Resigning will fix this. nolint: cyclop
func TxToCall ¶
func TxToCall(transaction *types.Transaction) (*ethereum.CallMsg, error)
TxToCall converts a transaction to a call.
Types ¶
type Chunk ¶
type Chunk struct { // StartBlock for this chunk. It is less then end block in ascending txes and greater in descending. StartBlock *big.Int // EndBlock for this chunk EndBlock *big.Int // contains filtered or unexported fields }
Chunk represents an individual chunk of startBlock-startBlock. TODO: this needs to be moved to scribe.
Example ¶
ExampleChunk demonstrates ascending and descending chunking.
// a ascending chunk iterator chunkIterator := util.NewChunkIterator(big.NewInt(1), big.NewInt(10), 1, true) var minMaxChunk, startEndChunks string for { nextChunk := chunkIterator.NextChunk() if nextChunk == nil { break } minMaxChunk += fmt.Sprintf("[%d-%d],", nextChunk.MinBlock(), nextChunk.MaxBlock()) startEndChunks += fmt.Sprintf("[%d-%d],", nextChunk.StartBlock, nextChunk.EndBlock) } fmt.Println(strings.TrimSuffix(minMaxChunk, ",")) fmt.Println(strings.TrimSuffix(startEndChunks, ",")) // a descending chunk iterator chunkIterator = util.NewChunkIterator(big.NewInt(1), big.NewInt(10), 1, false) minMaxChunk = "" startEndChunks = "" for { nextChunk := chunkIterator.NextChunk() if nextChunk == nil { break } minMaxChunk += fmt.Sprintf("[%d-%d],", nextChunk.MinBlock(), nextChunk.MaxBlock()) startEndChunks += fmt.Sprintf("[%d-%d],", nextChunk.StartBlock, nextChunk.EndBlock) } fmt.Println(strings.TrimSuffix(minMaxChunk, ",")) fmt.Println(strings.TrimSuffix(startEndChunks, ","))
Output: [1-2],[3-4],[5-6],[7-8],[9-10] [1-2],[3-4],[5-6],[7-8],[9-10] [9-10],[7-8],[5-6],[3-4],[1-2] [10-9],[8-7],[6-5],[4-3],[2-1]
type ChunkIterator ¶
type ChunkIterator interface { // NextChunk gets the next chunk. If the iterator has completed null will be returned. NextChunk() *Chunk }
ChunkIterator is an instantiation of a stateful iterator that groups startBlock-endBlock blocks into length chunkSize.
func NewChunkIterator ¶
func NewChunkIterator(startBlock, endBlock *big.Int, chunkSize int, ascending bool) ChunkIterator
NewChunkIterator creates an iterator for a range of elements (startBlock-endBlock) split into groups the length of chunkSize the final chunk has any remaining elements. An iterator is used here as opposed to a slice to save memory while iterating over *very large* chunks.This follows the stateful iterator pattern: https://ewencp.org/blog/golang-iterators/index.html
type CopyOption ¶ added in v0.0.76
type CopyOption func(*copyOptions)
CopyOption is a function that sets a copy option Certain options are not supported for certain transaction types on purpose please exercise caution before adding new options.
func WithGasFeeCap ¶ added in v0.0.76
func WithGasFeeCap(gasFeeCap *big.Int) CopyOption
WithGasFeeCap sets the gas fee cap for the copy.
func WithGasPrice ¶ added in v0.0.76
func WithGasPrice(gasPrice *big.Int) CopyOption
WithGasPrice sets the gas price for the copy.
func WithGasTipCap ¶ added in v0.0.76
func WithGasTipCap(gasTipCap *big.Int) CopyOption
WithGasTipCap sets the gas tip cap for the copy.
func WithNonce ¶ added in v0.0.76
func WithNonce(nonce uint64) CopyOption
WithNonce sets the nonce for the copy.
func WithTxType ¶ added in v0.0.76
func WithTxType(txType uint8) CopyOption
WithTxType sets the tx type for the copy. should be one of one of types.LegacyTxType, types.AccessListTxType, types.DynamicFeeTxType Warning: txtype conversions are not well supported and should be avoided if possible.