batchfossilizer

package
v0.3.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2018 License: Apache-2.0 Imports: 20 Imported by: 4

Documentation

Overview

Package batchfossilizer implements a fossilizer that fossilize batches of data using a Merkle tree. The evidence will contain the Merkle root, the Merkle path, and a timestamp.

Index

Constants

View Source
const (
	// Name is the name set in the fossilizer's information.
	Name = "batch"

	// Description is the description set in the fossilizer's information.
	Description = "Stratumn Batch Fossilizer"

	// DefaultInterval is the default interval between batches.
	DefaultInterval = 10 * time.Minute

	// DefaultMaxLeaves if the default maximum number of leaves of a Merkle
	// tree.
	DefaultMaxLeaves = 32 * 1024

	// DefaultMaxSimBatches is the default maximum number of simultaneous
	// batches.
	DefaultMaxSimBatches = 1

	// DefaultArchive is whether to archive completed batches by default.
	DefaultArchive = true

	// DefaultStopBatch is whether to do a batch on stop by default.
	DefaultStopBatch = true

	// DefaultFSync is whether to fsync after saving a hash to disk by
	// default.
	DefaultFSync = false

	// PendingExt is the pending hashes filename extension.
	PendingExt = "pending"

	// DirPerm is the directory's permissions.
	DirPerm = 0600

	// FilePerm is the files's permissions.
	FilePerm = 0600
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// A version string that will be set in the store's information.
	Version string

	// A git commit sha that will be set in the store's information.
	Commit string

	// Interval between batches.
	Interval time.Duration

	// Maximum number of leaves of a Merkle tree.
	MaxLeaves int

	// Maximum number of simultaneous batches.
	MaxSimBatches int

	// Where to store pending hashes.
	// If empty, pending hashes are not saved and will be lost if stopped
	// abruptly.
	Path string

	// Whether to archive completed batches.
	Archive bool

	// Whether to do a batch on stop.
	StopBatch bool

	// Whether to fsync after saving a hash to disk.
	FSync bool
}

Config contains configuration options for the fossilizer.

func (*Config) GetInterval

func (c *Config) GetInterval() time.Duration

GetInterval returns the configuration's interval or the default value.

func (*Config) GetMaxLeaves

func (c *Config) GetMaxLeaves() int

GetMaxLeaves returns the configuration's maximum number of leaves of a Merkle tree or the default value.

func (*Config) GetMaxSimBatches

func (c *Config) GetMaxSimBatches() int

GetMaxSimBatches returns the configuration's maximum number of simultaneous batches or the default value.

type Fossilizer

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

Fossilizer is the type that implements github.com/stratumn/go-indigocore/fossilizer.Adapter.

func New

func New(config *Config) (*Fossilizer, error)

New creates an instance of a Fossilizer.

func (*Fossilizer) AddFossilizerEventChan

func (a *Fossilizer) AddFossilizerEventChan(fossilizerEventChan chan *fossilizer.Event)

AddFossilizerEventChan implements github.com/stratumn/go-indigocore/fossilizer.Adapter.AddFossilizerEventChan.

func (*Fossilizer) Fossilize

func (a *Fossilizer) Fossilize(ctx context.Context, data []byte, meta []byte) error

Fossilize implements github.com/stratumn/go-indigocore/fossilizer.Adapter.Fossilize.

func (*Fossilizer) GetInfo

func (a *Fossilizer) GetInfo(ctx context.Context) (interface{}, error)

GetInfo implements github.com/stratumn/go-indigocore/fossilizer.Adapter.GetInfo.

func (*Fossilizer) SetTransformer

func (a *Fossilizer) SetTransformer(t Transformer)

SetTransformer sets a transformer.

func (*Fossilizer) Start

func (a *Fossilizer) Start(ctx context.Context) error

Start starts the fossilizer.

func (*Fossilizer) Started

func (a *Fossilizer) Started() <-chan struct{}

Started return a channel that will receive once the fossilizer has started.

type Info

type Info struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Version     string `json:"version"`
	Commit      string `json:"commit"`
}

Info is the info returned by GetInfo.

type Transformer

type Transformer func(evidence *cs.Evidence, data, meta []byte) (*fossilizer.Result, error)

Transformer is the type of a function to transform results.

Jump to

Keyboard shortcuts

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