erigon-pulse/cmd/devnettest/commands/event.go
leonardchinonso fbb62c7a35
Chore/test log subscription (#3786)
* saving

* Implemented and tested subscription of logs

* Fixed lint errors

* fixed compilation error

* Removed print statements across code

* made review changes

* Validated hex addresses
2022-03-31 13:40:09 +01:00

30 lines
774 B
Go

package commands
import (
"fmt"
"github.com/ledgerwatch/erigon/cmd/devnettest/services"
"github.com/spf13/cobra"
)
var (
eventAddr []string
eventTopics []string
)
func init() {
LogsCmd.Flags().StringSliceVar(&eventAddr, "addr", []string{}, "an address or a list of addresses separated by commas")
LogsCmd.Flags().StringSliceVar(&eventTopics, "topics", []string{}, "a topic or a list of topics separated by commas")
rootCmd.AddCommand(LogsCmd)
}
var LogsCmd = &cobra.Command{
Use: "logs",
Short: "Subscribes to log event sends a notification each time a new log appears",
Run: func(cmd *cobra.Command, args []string) {
if err := services.Logs(eventAddr, eventTopics); err != nil {
fmt.Printf("could not subscribe to log events: %v\n", err)
}
},
}