batch

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2020 License: Apache-2.0 Imports: 9 Imported by: 8

Documentation

Overview

Package batch batches multiple operations into batch files and stores the batch files in a distributed content-addressable storage (DCAS or CAS). A reference to the main batch file (core index) is then anchored on the blockchain as Sidetree transaction.

Batch Writer basic flow:

1) accept operations being delivered via Add method 2) 'cut' configurable number of operations into batch files 3) store batch files into CAS (content addressable storage) 4) write the anchor string referencing core index file URI to the underlying blockchain

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockchainClient

type BlockchainClient interface {
	// WriteAnchor writes the anchor string as a transaction to blockchain
	WriteAnchor(anchor string, protocolGenesisTime uint64) error
	// Read ledger transaction
	Read(sinceTransactionNumber int) (bool, *txn.SidetreeTxn)
}

BlockchainClient defines an interface to access the underlying blockchain.

type CompressionProvider added in v0.1.4

type CompressionProvider interface {

	// Compress will compress data using specified algorithm.
	Compress(alg string, data []byte) ([]byte, error)
}

CompressionProvider defines an interface for handling different types of compression.

type Context

type Context interface {
	Protocol() protocol.Client
	Blockchain() BlockchainClient
	OperationQueue() cutter.OperationQueue
}

Context contains batch writer context. 1) protocol information client 2) content addressable storage client 3) blockchain client.

type Option

type Option func(opts *Options) error

Option defines Writer options such as batch timeout.

func WithBatchTimeout

func WithBatchTimeout(batchTimeout time.Duration) Option

WithBatchTimeout allows for specifying batch timeout.

type Options

type Options struct {
	BatchTimeout time.Duration
}

Options allows the user to specify more advanced options.

type Writer

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

Writer implements batch writer.

func New

func New(namespace string, context Context, options ...Option) (*Writer, error)

New creates a new Writer with the given namespace. Writer accepts operations being delivered via Add, orders them, and then uses the batch cutter to form the operations batch files. The URI of main batch file (index core) will be written as part of anchor string to the given ledger.

func (*Writer) Add

func (r *Writer) Add(op *operation.QueuedOperation, protocolGenesisTime uint64) error

Add the given operation to a queue of operations to be batched and anchored on blockchain.

func (*Writer) Start

func (r *Writer) Start()

Start periodic anchoring of operation batches to blockchain.

func (*Writer) Stop

func (r *Writer) Stop()

Stop frees the resources which were allocated by start.

func (*Writer) Stopped added in v0.1.3

func (r *Writer) Stopped() bool

Stopped returns true if the writer has been stopped.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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