app

package
v3.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2024 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCustomLogger added in v3.5.0

func NewCustomLogger() (*slog.Logger, slog.Level)

Types

type App

type App struct {
	Logger   *slog.Logger
	Config   config.Config
	InitMode InitMode
	Monitor  OnOff
	Api      OnOff
	Sleep    int
	BlockCnt int
	LogLevel slog.Level
}

App is the main struct for the app. It contains the logger, the configuration, and the state of the app.

func NewApp

func NewApp() *App

NewApp creates a new App instance with the default values.

func (*App) EstablishConfig

func (a *App) EstablishConfig() error

EstablishConfig either reads an existing configuration file or creates it if it doesn't exist.

func (*App) IsOn

func (a *App) IsOn(feature Feature) bool

IsOn returns true if the given feauture is enabled. It returns false otherwise.

func (*App) ParseArgs

func (a *App) ParseArgs() (bool, error)

ParseArgs parses the command line options and sets the app's configuration accordingly. See README.md or run trueblocks-node --help.

func (*App) ReportOneScrape added in v3.5.0

func (a *App) ReportOneScrape(report *scraperReport)

func (*App) RunMonitor

func (a *App) RunMonitor(wg *sync.WaitGroup)

RunMonitor is a function that runs in a goroutine to monitor addresses.

func (*App) RunScraper

func (a *App) RunScraper(wg *sync.WaitGroup)

RunScraper runs the scraper in a goroutine. It will scrape the chains in the configuration file and sleep between each run for the duration specified with --sleep.

func (*App) RunServer

func (a *App) RunServer()

RunServer runs the API server in a goroutine, waits for it to be ready and then returns. All available trueblocks-core endpoints are available.

type CustomHandler added in v3.5.0

type CustomHandler struct {
	// contains filtered or unexported fields
}

func (*CustomHandler) Enabled added in v3.5.0

func (h *CustomHandler) Enabled(_ context.Context, level slog.Level) bool

func (*CustomHandler) Handle added in v3.5.0

func (h *CustomHandler) Handle(ctx context.Context, r slog.Record) error

func (*CustomHandler) WithAttrs added in v3.5.0

func (h *CustomHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*CustomHandler) WithGroup added in v3.5.0

func (h *CustomHandler) WithGroup(name string) slog.Handler

type Feature

type Feature string

Feature is a type that represents the features of the app

const (
	// Scrape represents the scraper feature. The scraper may not be disabled.
	Scrape Feature = "scrape"
	// Monitor represents the monitor feature. The monitor is Off by default. Enable
	// it with the `--monitor on` option.
	Monitor Feature = "monitor"
	// Api represents the API feature. The api is On by default. Disable it
	// with the `--api off` option.
	Api Feature = "api"
)

type InitMode

type InitMode string

InitMode is a type that represents the initialization for the Unchained Index. It applies to the `--init` option.

const (
	// All cause the initialization to download both the bloom filters and the index
	// portions of the Unchained Index.
	All InitMode = "all"
	// Blooms cause the initialization to download only the bloom filters portion of
	// the Unchained Index.
	Blooms InitMode = "blooms"
	// None cause the app to not download any part of the Unchained Index. It will be
	// built from scratch with the scraper.
	None InitMode = "none"
)

type OnOff

type OnOff string

OnOff is a type that represents a boolean value that can be either "on" or "off".

const (
	// On is the "on" value for a feature. It applies to the `--monitor` and `--api` options.
	On OnOff = "on"
	// Off is the "off" value for a feature. It applies to the `--monitor` and `--api` options.
	Off OnOff = "off"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL