Documentation
¶
Index ¶
- Variables
- func GetCommonStoresURLs(dataDir string) (mergedBlocksStoreURL, oneBlocksStoreURL, forkedBlocksStoreURL string, ...)
- func GetIndexStore(dataDir string) (indexStore dstore.Store, possibleIndexSizes []uint64, err error)
- func Main(chain *Chain)
- func MustReplaceDataDir(dataDir, in string) string
- func PrintOutputModeNames() []string
- type BlockPrinterFunc
- type Chain
- type CommandExecutor
- type PrintOutputMode
- type ToolsConfig
Constants ¶
This section is empty.
Variables ¶
var ( // Common ports MetricsListenAddr string = ":9102" // Firehose chain specific port ReaderNodeGRPCAddr string = ":10010" ReaderNodeManagerAPIAddr string = ":10011" MergerServingAddr string = ":10012" RelayerServingAddr string = ":10014" FirehoseGRPCServingAddr string = ":10015" // Data storage default locations BlocksCacheDirectory string = "file://{data-dir}/storage/blocks-cache" MergedBlocksStoreURL string = "file://{data-dir}/storage/merged-blocks" OneBlockStoreURL string = "file://{data-dir}/storage/one-blocks" ForkedBlocksStoreURL string = "file://{data-dir}/storage/forked-blocks" IndexStoreURL string = "file://{data-dir}/storage/index" )
Those are `var` and globally available so that some chains to keep backward-compatibility can change them. This is not advertised and should **not** be used by new chain.
var ExamplePrefixed = func(chain *Chain, prefix, in string) string { return string(cli.ExamplePrefixed(chain.BinaryName()+" "+prefix, in)) }
Functions ¶
func GetCommonStoresURLs ¶
func GetIndexStore ¶
func Main ¶
func Main(chain *Chain)
Main is the main entry point that configures everything and should be called from your Go 'main' entrypoint directly.
func MustReplaceDataDir ¶
MustReplaceDataDir replaces `{data-dir}` from within the `in` received argument by the `dataDir` argument
func PrintOutputModeNames ¶
func PrintOutputModeNames() []string
PrintOutputModeNames returns a list of possible string values of PrintOutputMode.
Types ¶
type BlockPrinterFunc ¶
BlockPrinterFunc takes a chain agnostic [block] and prints it to a human readable form.
See [ToolsConfig#BlockPrinter] for extra details about expected printing.
type Chain ¶
type Chain struct {
// ShortName is the short name for your Firehose on <Chain> and is usually how
// your chain's name is represented as a diminitutive. If your chain's name is already
// short, we suggest to keep [ShortName] and [LongName] the same.
//
// As an example, Firehose on Ethereum [ShortName] is `eth` while Firehose on NEAR
// short name is `near`.
//
// The [ShortName] **must** be non-empty, lower cased and must **not** contain any spaces.
ShortName string
// LongName is the full name of your chain and the case sensitivy of this value is respected.
// It is used in description of command and some logging output.
//
// The [LongName] **must** be non-empty.
LongName string
// ExecutableName is the name of the binary that is used to launch a syncing node for this chain. For example,
// on Ethereum, the binary by default is `geth`. This is used by the `reader-node` app to specify the
// `reader-node-binary-name` flag.
//
// The [ExecutableName] **must** be non-empty.
ExecutableName string
// FullyQualifiedModule is the Go module of your actual `firehose-<chain>` repository and should
// correspond to the `module` line of the `go.mod` file found at the root of your **own** `firehose-<chain>`
// repository.
//
// The [FullyQualifiedModule] **must** be non-empty.
FullyQualifiedModule string
// Version represents the actual version for your Firehose on <Chain>. It should be injected
// via and `ldflags` through your `main` package.
//
// The [Version] **must** be non-empty.
Version string
// FirstStreamableBlock represents the block number of the first block that is streamable using Firehose,
// for example on Ethereum it's set to `0`, the genesis block's number while on Antelope it's
// set to 2 (genesis block is 1 there but our instrumentation on this chain instruments
// only from block #2).
//
// This is used in multiple places to determine if we reached the oldest block of the chain.
FirstStreamableBlock uint64
// Should be the number of blocks between two targets before we consider the
// first as "near" the second. For example if a chain is at block #215 and another
// source is at block #225, then there is a difference of 10 blocks which is <=
// than `BlockDifferenceThresholdConsideredNear` which would mean it's "near".
//
// Must be greater than 0 and lower than 1024
BlockDifferenceThresholdConsideredNear uint64
// ConsoleReaderFactory is the function that should return the `ConsoleReader` that knowns
// how to transform your your chain specific Firehose instrumentation logs into the proper
// Block model of your chain.
//
// The [ConsoleReaderFactory] **must** be non-nil and must return a non-nil [mindreader.ConsolerReader] or an error.
ConsoleReaderFactory func(lines chan string, logger *zap.Logger, tracer logging.Tracer) (mindreader.ConsolerReader, error)
ChainSuperviserFactory func(
chainShortName string,
binary string,
arguments []string,
dataDir string,
headBlockUpdateFunc nodeManager.HeadBlockUpdater,
debugFirehose bool,
logToZap bool,
appLogger *zap.Logger,
nodelogger *zap.Logger,
) (nodeManager.ChainSuperviser, error)
// Tools aggregate together all configuration options required for the various `fire<chain> tools`
// to work properly for example to print block using chain specific information.
//
// The [Tools] element is optional and if not provided, sane defaults will be used.
Tools *ToolsConfig
}
Chain is the omni config object for configuring your chain specific information. It contains various fields that are used everywhere to properly configure the `firehose-<chain>` binary.
Each field is documented about where it's used. Throughtout the different Chain option, we will use `Acme` as the chain's name placeholder, replace it with your chain name.
func (*Chain) BinaryName ¶
BinaryName represents the binary name for your Firehose on <Chain> is the [ShortName] lowered appended to 'fire' prefix to before for example `fireacme`.
func (*Chain) BlockPrinter ¶
func (c *Chain) BlockPrinter() BlockPrinterFunc
func (*Chain) LoggerPackageID ¶
LoggerPackageID computes a logger `packageID` value for a specific sub-package.
func (*Chain) RootLoggerPackageID ¶
RootLoggerPackageID is the `packageID` value when instantiating the root logger on the chain that is used by CLI command and other
func (*Chain) Validate ¶
func (c *Chain) Validate()
Validate normalizes some aspect of the Chain values (spaces trimming essentially) and validates the chain by accumulating error an panic if all the error found along the way.
func (*Chain) VersionString ¶
VersionString computes the version string that will be display when calling `firexxx --version` and extract build information from Git via Golang `debug.ReadBuildInfo`.
type PrintOutputMode ¶
type PrintOutputMode uint
ENUM(
Text JSON
)
const ( // PrintOutputModeText is a PrintOutputMode of type Text. PrintOutputModeText PrintOutputMode = iota // PrintOutputModeJSON is a PrintOutputMode of type JSON. PrintOutputModeJSON )
func ParsePrintOutputMode ¶
func ParsePrintOutputMode(name string) (PrintOutputMode, error)
ParsePrintOutputMode attempts to convert a string to a PrintOutputMode
func (PrintOutputMode) MarshalText ¶
func (x PrintOutputMode) MarshalText() ([]byte, error)
MarshalText implements the text marshaller method
func (PrintOutputMode) String ¶
func (x PrintOutputMode) String() string
String implements the Stringer interface.
func (*PrintOutputMode) UnmarshalText ¶
func (x *PrintOutputMode) UnmarshalText(text []byte) error
UnmarshalText implements the text unmarshaller method
type ToolsConfig ¶
type ToolsConfig struct {
// BlockPrinter represents a printing function that render a chain specific human readable
// form of the receive chain agnostic [bstream.Block]. This block is expected to be rendered as
// a single line for example on Ethereum rendering of a single block looks like:
//
// “`
// Block #24924194 (01d6d349fbd3fa419182a2f0cf0b00714e101286650c239de8923caef6134b6c) 62 transactions, 607 calls
// “`
//
// If the [alsoPrintTransactions] argument is true, each transaction of the block should also be printed, following
// directly the block line. Each transaction should also be on a single line, usually prefixed with a `- ` to make
// the rendering more appealing.
//
// For example on Ethereum rendering with [alsoPrintTransactions] being `true` looks like:
//
// “`
// Block #24924194 (01d6d349fbd3fa419182a2f0cf0b00714e101286650c239de8923caef6134b6c) 62 transactions, 607 calls
// - Transaction 0xc7e04240d6f2cc5f382c478fd0a0b5c493463498c64b31477b95bded8cd12ab4 (10 calls)
// - Transaction 0xc7d8a698351eb1ac64acb76c8bf898365bb639865271add95d2c81650b2bd98c (4 calls)
// “`
//
// The `out` parameter is used to write to the correct location. You can use [fmt.Fprintf] and [fmt.Fprintln]
// and use `out` as the output writer in your implementation.
//
// The [BlockPrinter] is optional, if nil, a default block printer will be used. It's important to note
// that the default block printer error out if `alsoPrintTransactions` is true.
BlockPrinter BlockPrinterFunc
}