Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var MonitorCmd = &cobra.Command{ Use: "monitor url", Short: "Monitor blocks using a JSON-RPC endpoint.", Long: usage, Args: cobra.MinimumNArgs(1), PreRunE: func(cmd *cobra.Command, args []string) error { _, err := url.Parse(args[0]) if err != nil { return err } if interval, err = time.ParseDuration(intervalStr); err != nil { return err } if batchSizeValue == "auto" { batchSize = -1 } else { batchSize, err = strconv.Atoi(batchSizeValue) if batchSize == 0 { return fmt.Errorf("batch-size can't be equal to zero") } if err != nil { return fmt.Errorf("batch-size needs to be an integer") } } return nil }, RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() rpc, err := ethrpc.DialContext(ctx, args[0]) if err != nil { log.Error().Err(err).Msg("Unable to dial rpc") return err } ec := ethclient.NewClient(rpc) ms := new(monitorStatus) ms.MaxBlockRetrieved = big.NewInt(0) ms.BlocksLock.Lock() ms.Blocks = make(map[string]rpctypes.PolyBlock, 0) ms.BlocksLock.Unlock() ms.ChainID = big.NewInt(0) ms.PendingCount = 0 observedPendingTxs = make(historicalRange, 0) isUiRendered := false errChan := make(chan error) go func() { for { err = fetchBlocks(ctx, ec, ms, rpc, isUiRendered) if err != nil { continue } if !isUiRendered { go func() { errChan <- renderMonitorUI(ctx, ec, ms, rpc) }() isUiRendered = true } time.Sleep(interval) } }() err = <-errChan return err }, }
monitorCmd represents the monitor command
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.