Documentation ¶
Overview ¶
Package monitorsPkg handles the chifra monitors command. It has two purposes: (1) to display information about the current set of monitors, and (2) to --watch a set of addresses. The --watch function allows one to "follow" an address (or set of addresses) and keep an off-chain database fresh. ### Crud commands chifra list creates a new monitor. See that tool's help file for more information. The chifra monitors --delete command deletes (or --undelete if already deleted) an address but does not remove it from your hard drive. The monitor is marked as being deleted, making it invisible to other tools. Use the --remove command to permanently remove a monitor from your computer. This is an irreversible operation and requires the monitor to have been previously deleted. The --decache option will remove not only the monitor but all of the cached data associated with the monitor (for example, transactions or traces). This is an irreversible operation (except for the fact that the cache can be easily re-created with chifra list <address>). The monitor need not have been previously deleted. ### Watching addresses The --watch command is special. It starts a long-running process that continually reads the blockchain looking for appearances of the addresses it is instructed to watch. It command requires two additional parameters: --watchlist <filename> and --commands <filename>. The --watchlist file is simply a list of addresses or ENS names, one per line: chifra export --logs etc. The token is a stand-in for all addresses in the --watchlist. Addresses are processed in groups of batch_size (default 8). Invalid commands or invalid addresses are ignored. If a command fails, the process continues with the next command. If a command fails for a particular address, the process continues with the next address. A warning is generated.
Index ¶
- func GetExportFormat(cmd, def string) string
- func ResetOptions(testMode bool)
- func RunMonitors(cmd *cobra.Command, args []string) error
- func ServeMonitors(w http.ResponseWriter, r *http.Request) error
- type Command
- type MonitorsOptions
- func (opts *MonitorsOptions) FreshenMonitorsForWatch(addrs []base.Address) (bool, error)
- func (opts *MonitorsOptions) HandleClean() error
- func (opts *MonitorsOptions) HandleCrudCommands() error
- func (opts *MonitorsOptions) HandleDecache() error
- func (opts *MonitorsOptions) HandleList() error
- func (opts *MonitorsOptions) HandleWatch() error
- func (opts *MonitorsOptions) MonitorsInternal() error
- func (opts *MonitorsOptions) Refresh(monitors []monitor.Monitor) (bool, error)
- func (opts *MonitorsOptions) RunMonitorScraper(wg *sync.WaitGroup, s *Scraper)
- func (opts *MonitorsOptions) String() string
- type Scraper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetExportFormat ¶
func ResetOptions ¶
func ResetOptions(testMode bool)
func RunMonitors ¶
RunMonitors handles the monitors command for the command line. Returns error only as per cobra.
func ServeMonitors ¶
func ServeMonitors(w http.ResponseWriter, r *http.Request) error
ServeMonitors handles the monitors command for the API. Returns an error.
Types ¶
type Command ¶
type MonitorsOptions ¶
type MonitorsOptions struct { Addrs []string `json:"addrs,omitempty"` // One or more addresses (0x...) to process Delete bool `json:"delete,omitempty"` // Delete a monitor, but do not remove it Undelete bool `json:"undelete,omitempty"` // Undelete a previously deleted monitor Remove bool `json:"remove,omitempty"` // Remove a previously deleted monitor Clean bool `json:"clean,omitempty"` // Clean (i.e. remove duplicate appearances) from monitors List bool `json:"list,omitempty"` // List monitors in the cache (--verbose for more detail) Watch bool `json:"watch,omitempty"` // Continually scan for new blocks and extract data as per the command file Watchlist string `json:"watchlist,omitempty"` // Available with --watch option only, a file containing the addresses to watch Commands string `json:"commands,omitempty"` // Available with --watch option only, the file containing the list of commands to apply to each watched address BatchSize uint64 `json:"batchSize,omitempty"` // Available with --watch option only, the number of monitors to process in each batch RunCount uint64 `json:"runCount,omitempty"` // Available with --watch option only, run the monitor this many times, then quit Sleep float64 `json:"sleep,omitempty"` // Available with --watch option only, the number of seconds to sleep between runs Globals globals.GlobalOptions `json:"globals,omitempty"` // The global options Conn *rpc.Connection `json:"conn,omitempty"` // The connection to the RPC server BadFlag error `json:"badFlag,omitempty"` // An error flag if needed }
MonitorsOptions provides all command options for the chifra monitors command.
func GetMonitorsOptions ¶
func GetMonitorsOptions(args []string, g *globals.GlobalOptions) *MonitorsOptions
GetMonitorsOptions returns the options for this tool so other tools may use it.
func GetOptions ¶
func GetOptions() *MonitorsOptions
func (*MonitorsOptions) FreshenMonitorsForWatch ¶
func (opts *MonitorsOptions) FreshenMonitorsForWatch(addrs []base.Address) (bool, error)
func (*MonitorsOptions) HandleClean ¶
func (opts *MonitorsOptions) HandleClean() error
HandleClean handles the chifra monitors --clean command.
func (*MonitorsOptions) HandleCrudCommands ¶
func (opts *MonitorsOptions) HandleCrudCommands() error
HandleCrudCommands handles the chifra monitors delete, undelete, remove and decache commands.
[State] | Delete | Undelete | Remove | ------------|--------|-------------------| Not Deleted | Delete | Error | Error | Deleted | Error | Undelete | Remove | ------------|--------|-------------------|
func (*MonitorsOptions) HandleDecache ¶
func (opts *MonitorsOptions) HandleDecache() error
func (*MonitorsOptions) HandleList ¶
func (opts *MonitorsOptions) HandleList() error
HandleList handles the chifra monitors --list command.
func (*MonitorsOptions) HandleWatch ¶
func (opts *MonitorsOptions) HandleWatch() error
HandleWatch starts the monitor watcher
func (*MonitorsOptions) MonitorsInternal ¶
func (opts *MonitorsOptions) MonitorsInternal() error
MonitorsInternal handles the internal workings of the monitors command. Returns an error.
func (*MonitorsOptions) Refresh ¶
func (opts *MonitorsOptions) Refresh(monitors []monitor.Monitor) (bool, error)
func (*MonitorsOptions) RunMonitorScraper ¶
func (opts *MonitorsOptions) RunMonitorScraper(wg *sync.WaitGroup, s *Scraper)
RunMonitorScraper runs continually, never stopping and freshens any existing monitors
func (*MonitorsOptions) String ¶
func (opts *MonitorsOptions) String() string
String implements the Stringer interface