util

package
v0.0.0-...-3979f71 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2023 License: MIT Imports: 19 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateIndexerPidFile

func CreateIndexerPidFile(logger *log.Logger, pidFilePath string) error

CreateIndexerPidFile creates the pid file at the specified location

func DecodeSignedTxn

func DecodeSignedTxn(bh sdk.BlockHeader, stb sdk.SignedTxnInBlock) (sdk.SignedTxn, sdk.ApplyData, error)

DecodeSignedTxn converts a SignedTxnInBlock from a block to SignedTxn and its associated ApplyData.

func Diff

func Diff(expected interface{}, actual interface{}) string

Diff returns a diff of both values as long as both are of the same type and are a struct, map, slice, array or string. Otherwise it returns an empty string.

func EncodeSignedTxn

func EncodeSignedTxn(bh sdk.BlockHeader, st sdk.SignedTxn, ad sdk.ApplyData) (sdk.SignedTxnInBlock, error)

EncodeSignedTxn converts a SignedTxn and ApplyData into a SignedTxnInBlock for that block.

func EnsureInitialImport

func EnsureInitialImport(db idb.IndexerDb, genesis sdk.Genesis) (bool, error)

EnsureInitialImport imports the genesis block if needed. Returns true if the initial import occurred.

func FileExists

func FileExists(filePath string) bool

FileExists checks to see if the specified file (or directory) exists

func GetConfigFromDataDir

func GetConfigFromDataDir(dataDirectory string, configFilename string, configFileTypes []string) (string, error)

GetConfigFromDataDir Given the data directory, configuration filename and a list of types, see if a configuration file that matches was located there. If no configuration file was there then an empty string is returned. If more than one filetype was matched, an error is returned.

func IsDir

func IsDir(path string) bool

IsDir returns true if the specified directory is valid

func JSONOneLine

func JSONOneLine(obj interface{}) string

JSONOneLine converts an object into JSON

func KeysStringBool

func KeysStringBool(m map[string]bool) string

KeysStringBool returns all of the keys in the map joined by a comma.

func MaybeFail

func MaybeFail(err error, errfmt string, params ...interface{})

MaybeFail exits if there was an error.

func PrintableUTF8OrEmpty

func PrintableUTF8OrEmpty(in string) string

PrintableUTF8OrEmpty checks to see if the entire string is a UTF8 printable string. If this is the case, the string is returned as is. Otherwise, the empty string is returned.

func ReadGenesis

func ReadGenesis(in io.Reader) (sdk.Genesis, error)

ReadGenesis converts a reader into a Genesis file.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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