2022-03-31 12:40:09 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"github.com/ledgerwatch/erigon/cmd/devnettest/services"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2022-05-26 12:08:25 +00:00
|
|
|
eventAddrs = []string{devAddress, recvAddr}
|
2022-03-31 12:40:09 +00:00
|
|
|
eventTopics []string
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
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) {
|
2022-05-26 12:08:25 +00:00
|
|
|
callLogs()
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
func callLogs() {
|
|
|
|
go func() {
|
|
|
|
if err := services.Logs(eventAddrs, eventTopics); err != nil {
|
2022-03-31 12:40:09 +00:00
|
|
|
fmt.Printf("could not subscribe to log events: %v\n", err)
|
|
|
|
}
|
2022-05-26 12:08:25 +00:00
|
|
|
}()
|
|
|
|
|
|
|
|
callContractTx()
|
2022-03-31 12:40:09 +00:00
|
|
|
}
|