README
¶
go-utils
Various reusable Go utilities and modules
cli
Various minor command-line interface helpers: cli.go
httplogger
Logging middleware for HTTP requests using go-ethereum/log
.
See examples/httplogger/main.go
Install:
go get github.com/flashbots/go-utils/httplogger
Use:
mux := http.NewServeMux()
mux.HandleFunc("/v1/hello", HelloHandler)
loggedRouter := httplogger.LoggingMiddleware(r)
jsonrpc
Minimal JSON-RPC client implementation.
blocksub
Subscribe for new Ethereum block headers by polling and/or websocket subscription
See examples/blocksub/main.go
and examples/blocksub/multisub.go
Install:
go get github.com/flashbots/go-utils/blocksub
Use:
blocksub := blocksub.NewBlockSub(context.Background(), httpURI, wsURI)
if err := blocksub.Start(); err != nil {
panic(err)
}
// Subscribe to new headers
sub := blocksub.Subscribe(context.Background())
for header := range sub.C {
fmt.Println("new header", header.Number.Uint64(), header.Hash().Hex())
}
Directories
¶
Path | Synopsis |
---|---|
Package blocksub implements an Ethereum block subscriber that works with polling and/or websockets.
|
Package blocksub implements an Ethereum block subscriber that works with polling and/or websockets. |
Package cli implements various reusable utility functions for command-line interfaces.
|
Package cli implements various reusable utility functions for command-line interfaces. |
examples
|
|
blocksub
Example for multiple subscribers
|
Example for multiple subscribers |
Package httplogger implements a middleware that logs the incoming HTTP request & its duration using go-ethereum-log or logrus
|
Package httplogger implements a middleware that logs the incoming HTTP request & its duration using go-ethereum-log or logrus |
Package jsonrpc is a minimal JSON-RPC implementation
|
Package jsonrpc is a minimal JSON-RPC implementation |
Click to show internal directories.
Click to hide internal directories.