Documentation ¶
Overview ¶
Package util contains eth type utils
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LogPointer ¶ added in v0.0.5
LogPointer wraps a log in a pointer.
func LogsPointer ¶ added in v0.0.5
LogsPointer wraps logs in a pointer TODO: consider abstracting this out into a generic.
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.
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