utils

package
v0.0.0-...-abe358f Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxNonceRetries is the maximum number of retry attempts for nonce retrieval
	MaxNonceRetries = 3

	// NonceRetryTimeout is the timeout for each nonce retrieval attempt
	NonceRetryTimeout = 10 * time.Second
)

Variables

This section is empty.

Functions

func AppendHashToFile

func AppendHashToFile(filename string, hash common.Hash) error

AppendHashToFile appends a single hash to the file

func AppendToFile

func AppendToFile(filename, content string) error

AppendToFile appends content to file

func EnsureDir

func EnsureDir(dirPath string) error

EnsureDir ensures a directory exists, creates it if it doesn't

func FileExists

func FileExists(filename string) bool

FileExists checks if a file exists

func GetNonceWithRetry

func GetNonceWithRetry(client *ethclient.Client, address common.Address, maxRetries int) (uint64, error)

GetNonceWithRetry gets nonce from the network with retry mechanism Based on fuzzer/tx_fuzzer.go implementation

func InitHashFile

func InitHashFile(filename, nodeName string) error

InitHashFile initializes a hash file with a node name header

func ParseJWTSecretFromHexString

func ParseJWTSecretFromHexString(hexString string) ([]byte, error)

parseJWTSecretFromHexString parses hexadecimal string directly

func ParseNonceValue

func ParseNonceValue(value string) (uint64, bool, error)

ParseNonceValue parses a nonce string value Returns (nonce, isAuto, error) - If value is "auto", returns (0, true, nil) - If value is numeric, returns (parsed_value, false, nil) - Otherwise returns (0, false, error)

func PrintHeaders

func PrintHeaders(headers *eth.BlockHeadersPacket)

PrintHeaders prints block headers

func PrintPooledTransactions

func PrintPooledTransactions(resp eth.PooledTransactionsResponse)

PrintPooledTransactions prints pooled transactions response

func PrintProgress

func PrintProgress(current, total int, message string)

PrintProgress prints a progress indicator

func PrintReceipts

func PrintReceipts(receipts []*eth.ReceiptList68)

PrintReceipts prints receipts

func PrintSeparator

func PrintSeparator()

PrintSeparator prints a visual separator

func PrintSingleReceipt

func PrintSingleReceipt(receipt *types.Receipt, index int)

PrintSingleReceipt prints a single receipt

func PrintTestSummary

func PrintTestSummary(testName string, stats map[string]interface{})

PrintTestSummary prints a formatted test summary

func PrintTransaction

func PrintTransaction(tx *types.Transaction)

PrintTransaction prints transaction details

func ResolveNonce

func ResolveNonce(client *ethclient.Client, nonceStr string, address common.Address) (uint64, error)

ResolveNonce resolves a nonce string to an actual nonce value - If nonceStr is "auto", retrieves nonce from the network - If nonceStr is numeric, parses and returns it - Returns error if unable to resolve

func ResolveNonceList

func ResolveNonceList(client *ethclient.Client, nonceStrs []string, addresses []common.Address) ([]uint64, error)

ResolveNonceList resolves a list of nonce strings for multiple accounts Returns a list of resolved nonces or error

func WriteHashesToFile

func WriteHashesToFile(hashes []common.Hash, filename string) error

WriteHashesToFile writes transaction hashes to the specified file The first hash overwrites the file, subsequent hashes are appended to the end of the file

func WriteStringToFile

func WriteStringToFile(filename, content string) error

WriteStringToFile writes string content to a file (overwrites if exists)

Types

type Logger

type Logger struct {
	*log.Logger
	// contains filtered or unexported fields
}

Logger wraps the standard logger with file output

func NewLogger

func NewLogger(logDir string) (*Logger, error)

NewLogger creates a new logger that writes to both console and file

func (*Logger) Close

func (l *Logger) Close() error

Close closes the log file

func (*Logger) Debug

func (l *Logger) Debug(format string, v ...interface{})

Debug logs a debug message

func (*Logger) Error

func (l *Logger) Error(format string, v ...interface{})

Error logs an error message

func (*Logger) Fatal

func (l *Logger) Fatal(format string, v ...interface{})

Fatal logs a fatal message and exits

func (*Logger) Info

func (l *Logger) Info(format string, v ...interface{})

Info logs an info message

func (*Logger) Warn

func (l *Logger) Warn(format string, v ...interface{})

Warn logs a warning message

Jump to

Keyboard shortcuts

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