trxdb

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolPtr

func BoolPtr(b *bool) bool

func IsRegistered

func IsRegistered(schemeName string) bool

func MustHexDecode

func MustHexDecode(input string) []byte

func Register

func Register(schemeName string, factory DriverFactory)

Register registers a storage backend DB

Types

type AccountsReader

type AccountsReader interface {
	GetAccount(ctx context.Context, accountName string) (*pbcodec.AccountCreationRef, error)
	ListAccountNames(ctx context.Context) ([]string, error)
}

type BlocksReader

type BlocksReader interface {
	GetLastWrittenIrreversibleBlockRef(ctx context.Context) (ref bstream.BlockRef, err error)
	GetLastWrittenBlockID(ctx context.Context) (blockID string, err error)
	GetBlock(ctx context.Context, id string) (*pbcodec.BlockWithRefs, error)
	GetBlockByNum(ctx context.Context, num uint32) ([]*pbcodec.BlockWithRefs, error)
	GetClosestIrreversibleIDAtBlockNum(ctx context.Context, num uint32) (ref bstream.BlockRef, err error)
	GetIrreversibleIDAtBlockID(ctx context.Context, ID string) (ref bstream.BlockRef, err error)

	// ListBlocks retrieves blocks where `highBlockNum` is the highest
	// returned, and will retrieve a maximum of `limit` rows.  For
	// example, if you pass `highBlockNum = math.MaxUint32` with
	// `limit = 1`, it will retrieve the last written block.
	//
	// FIXME: this one should be `lowBlockNum` and `highBlockNum`, the
	// thing is you might not have the expected block range if there
	// are forked blocks provided.
	ListBlocks(ctx context.Context, highBlockNum uint32, limit int) ([]*pbcodec.BlockWithRefs, error)
	ListSiblingBlocks(ctx context.Context, blockNum uint32, spread uint32) ([]*pbcodec.BlockWithRefs, error)
}

type BlocksTransactionsReader

type BlocksTransactionsReader interface {
	BlocksReader
	TransactionsReader
}

This is the main interface, needed by most subsystems.

type ChainDiscriminator

type ChainDiscriminator func(blockID string) bool

type DB

type DB interface {
	DBReader
	DBWriter

	Close() error
}

func New

func New(dsn string, opts ...Option) (DB, error)

New initializes a new DB

type DBWriter

type DBWriter interface {
	// this is used to bootstrap the trxdb-loader pipeline
	GetLastWrittenIrreversibleBlockRef(ctx context.Context) (ref bstream.BlockRef, err error)

	SetWriterChainID(chainID []byte)
	PutBlock(ctx context.Context, blk *pbcodec.Block) error
	UpdateNowIrreversibleBlock(ctx context.Context, blk *pbcodec.Block) error
	// Flush MUST be called or you WILL lose data
	Flush(context.Context) error
}

type Debugeable

type Debugeable interface {
	Dump()
}

type DriverFactory

type DriverFactory func(dsn []string) (DB, error)

type IndexableCategories

type IndexableCategories []pbtrxdb.IndexableCategory
var FullIndexing IndexableCategories
var NoIndexing IndexableCategories = nil

func NewIndexableCategories

func NewIndexableCategories(in string) (out IndexableCategories, err error)

func (IndexableCategories) AsHumanKeys

func (i IndexableCategories) AsHumanKeys() (out []string)

func (IndexableCategories) ToMap

type Option

type Option func(db DB) error

func WithLogger

func WithLogger(logger *zap.Logger) Option

func WithPurgeableStoreOption

func WithPurgeableStoreOption(ttl, purgeInterval uint64) Option

type ProtoDecoder

type ProtoDecoder struct{}

func NewProtoDecoder

func NewProtoDecoder() *ProtoDecoder

func (*ProtoDecoder) Into

func (d *ProtoDecoder) Into(cnt []byte, msg proto.Message) error

func (*ProtoDecoder) MustInto

func (d *ProtoDecoder) MustInto(cnt []byte, msg proto.Message)

type ProtoEncoder

type ProtoEncoder struct{}

func NewProtoEncoder

func NewProtoEncoder() *ProtoEncoder

func (*ProtoEncoder) MustProto

func (e *ProtoEncoder) MustProto(obj proto.Message) (out []byte)

type TestTransactionsReader

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

func NewTestTransactionsReader

func NewTestTransactionsReader(content map[string][]*pbcodec.TransactionEvent) *TestTransactionsReader

func (*TestTransactionsReader) GetLastWrittenIrreversibleBlockRef

func (r *TestTransactionsReader) GetLastWrittenIrreversibleBlockRef(ctx context.Context) (ref bstream.BlockRef, err error)

func (*TestTransactionsReader) GetTransactionEvents

func (r *TestTransactionsReader) GetTransactionEvents(ctx context.Context, idPrefix string) ([]*pbcodec.TransactionEvent, error)

func (*TestTransactionsReader) GetTransactionEventsBatch

func (r *TestTransactionsReader) GetTransactionEventsBatch(ctx context.Context, idPrefixes []string) ([][]*pbcodec.TransactionEvent, error)

func (*TestTransactionsReader) GetTransactionTraces

func (r *TestTransactionsReader) GetTransactionTraces(ctx context.Context, idPrefix string) ([]*pbcodec.TransactionEvent, error)

func (*TestTransactionsReader) GetTransactionTracesBatch

func (r *TestTransactionsReader) GetTransactionTracesBatch(ctx context.Context, idPrefixes []string) (out [][]*pbcodec.TransactionEvent, err error)

type TimelineExplorer

type TimelineExplorer interface {
	BlockIDAt(ctx context.Context, start time.Time) (id string, err error)
	BlockIDAfter(ctx context.Context, start time.Time, inclusive bool) (id string, foundtime time.Time, err error)
	BlockIDBefore(ctx context.Context, start time.Time, inclusive bool) (id string, foundtime time.Time, err error)
}

type TransactionsReader

type TransactionsReader interface {
	GetLastWrittenIrreversibleBlockRef(ctx context.Context) (ref bstream.BlockRef, err error)

	// GetTransactionTraces retrieves only the execution traces event, ignoring deferred lifecycle events.
	// It can return a nil list of TransactionEvent with no error, if nothing was found.
	// It will return an error if the idPrefix matches multiple transactions (e.g. is too short)
	GetTransactionTraces(ctx context.Context, idPrefix string) ([]*pbcodec.TransactionEvent, error)
	// GetTransactionTracesBatch returns only the execution traces, ignoring deferred lifecycle events, for each id prefix specified.
	// If some ids are not found, the corresponding index will have a nil list of TransactionEvent.
	// It will return an error if one of the the idPrefixes matches multiple transactions (e.g. is too short)
	GetTransactionTracesBatch(ctx context.Context, idPrefixes []string) ([][]*pbcodec.TransactionEvent, error)

	// GetTransactionEvents retrieves all the events related to the lifecycle of a transaction, including transaction introduction, deferred creations, cancellations, and traces of execution.
	// It can return a nil list of TransactionEvent with no error, if nothing was found.
	// It will return an error if the idPrefix matches multiple transactions (e.g. is too short)
	GetTransactionEvents(ctx context.Context, idPrefix string) ([]*pbcodec.TransactionEvent, error)

	// GetTransactionEventsBatch returns a list of all events for each transaction id prefix.
	// If some ids are not found, the corresponding index will have a nil list of TransactionEvent.
	// It will return an error if one of the the idPrefixes matches multiple transactions (e.g. is too short)
	GetTransactionEventsBatch(ctx context.Context, idPrefixes []string) ([][]*pbcodec.TransactionEvent, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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