filewriter

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 16 Imported by: 0

README

File Export Plugin

Write block data to files. This plugin works with the file rerader plugin to create a simple file-based pipeine.

The genesis file is always exported to a plain JSON file named genesis.json regardless of the FilenamePattern.

Configuration

name: file_writer
config:
    # BlocksDir is the path to a directory where block data should be stored.
    # The directory is created if it doesn't exist. If no directory is provided
    # blocks are written to the Conduit data directory.
    #block-dir: "/path/to/block/files"

    # FilenamePattern is the format used to write block files. It uses go
    # string formatting and should accept one number for the round.
    # To specify JSON encoding, add a '.json' extension to the filename.
    # To specify MessagePack encoding, add a '.msgp' extension to the filename.
    # If the file has a '.gz' extension, blocks will be gzipped regardless of encoding.
    # Default: "%[1]d_block.msgp.gz"
    filename-pattern: "%[1]d_block.msgp.gz"

    # DropCertificate is used to remove the vote certificate from the block data before writing files.
    drop-certificate: true

Documentation

Index

Constants

View Source
const (
	// PluginName to use when configuring.
	PluginName = "file_writer"

	// FilePattern is used to name the output files.
	FilePattern = "%[1]d_block.msgp.gz"

	// GenesisFilename is the name of the genesis file.
	GenesisFilename = "genesis.json"
)

Variables

This section is empty.

Functions

func DecodeFromFile added in v1.4.0

func DecodeFromFile(filename string, v interface{}, format EncodingFormat, isGzip bool) error

DecodeFromFile decodes a file to an object using a given format and possible gzip compression.

func Encode added in v1.4.0

func Encode(format EncodingFormat, writer io.Writer, v interface{}) error

Encode an object to a writer using a given an EncodingFormat.

func EncodeToFile added in v1.4.0

func EncodeToFile(filename string, v interface{}, format EncodingFormat, isGzip bool) error

EncodeToFile encodes an object to a file using a given format and possible gzip compression.

Types

type Config

type Config struct {
	/* <code>blocks-dir</code> is an optional path to a directory where block data should be
	stored.<br/>
	The directory is created if it doesn't exist.<br/>
	If no directory is provided the default plugin data directory is used.
	*/
	BlocksDir string `yaml:"block-dir"`
	/* <code>filename-pattern</code> is the format used to write block files. It uses go
	string formatting and should accept one number for the round.<br/>
	If the file has a '.gz' extension, blocks will be gzipped.
	Default:

		"%[1]d_block.json"
	*/
	FilenamePattern string `yaml:"filename-pattern"`
	// <code>drop-certificate</code> is used to remove the vote certificate from the block data before writing files.
	DropCertificate bool `yaml:"drop-certificate"`
}

Config specific to the file exporter

type EncodingFormat added in v1.4.0

type EncodingFormat byte

EncodingFormat enumerates the acceptable encoding formats for Conduit file-based plugins.

const (
	// MessagepackFormat indicates the file is encoded using MessagePack.
	MessagepackFormat EncodingFormat = iota

	// JSONFormat indicates the file is encoded using JSON.
	JSONFormat

	// UnrecognizedFormat indicates the file's encoding is unknown to Conduit.
	UnrecognizedFormat
)

func ParseFilenamePattern added in v1.4.0

func ParseFilenamePattern(pattern string) (EncodingFormat, bool, error)

ParseFilenamePattern parses a filename pattern into an EncodingFormat and gzip flag.

Jump to

Keyboard shortcuts

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