logdb

package
v1.7.4 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2022 License: LGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	BlockNumber uint32
	Index       uint32
	BlockID     thor.Bytes32
	BlockTime   uint64
	TxID        thor.Bytes32
	TxOrigin    thor.Address //contract caller
	ClauseIndex uint32
	Address     thor.Address // always a contract address
	Topics      [5]*thor.Bytes32
	Data        []byte
}

Event represents tx.Event that can be stored in db.

type EventCriteria added in v1.0.3

type EventCriteria struct {
	Address *thor.Address // always a contract address
	Topics  [5]*thor.Bytes32
}

type EventFilter

type EventFilter struct {
	CriteriaSet []*EventCriteria
	Range       *Range
	Options     *Options
	Order       Order //default asc
}

EventFilter filter

type LogDB

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

func New

func New(path string) (logDB *LogDB, err error)

New create or open log db at given path.

func NewMem

func NewMem() (*LogDB, error)

NewMem create a log db in ram.

func (*LogDB) Close

func (db *LogDB) Close() (err error)

Close close the log db.

func (*LogDB) FilterEvents

func (db *LogDB) FilterEvents(ctx context.Context, filter *EventFilter) ([]*Event, error)

func (*LogDB) FilterTransfers

func (db *LogDB) FilterTransfers(ctx context.Context, filter *TransferFilter) ([]*Transfer, error)

func (*LogDB) HasBlockID added in v1.1.0

func (db *LogDB) HasBlockID(id thor.Bytes32) (bool, error)

HasBlockID query whether given block id related logs were written.

func (*LogDB) NewWriter added in v1.7.0

func (db *LogDB) NewWriter() *Writer

NewWriter creates a log writer.

func (*LogDB) NewWriterSyncOff added in v1.7.0

func (db *LogDB) NewWriterSyncOff() *Writer

NewWriterSyncOff creates a log writer which applied 'pragma synchronous = off'.

func (*LogDB) NewestBlockID added in v1.1.0

func (db *LogDB) NewestBlockID() (thor.Bytes32, error)

NewestBlockID query newest written block id.

func (*LogDB) Path

func (db *LogDB) Path() string

type Options

type Options struct {
	Offset uint64
	Limit  uint64
}

type Order

type Order string
const (
	ASC  Order = "asc"
	DESC Order = "desc"
)

type Range

type Range struct {
	From uint32
	To   uint32
}

type Transfer

type Transfer struct {
	BlockNumber uint32
	Index       uint32
	BlockID     thor.Bytes32
	BlockTime   uint64
	TxID        thor.Bytes32
	TxOrigin    thor.Address
	ClauseIndex uint32
	Sender      thor.Address
	Recipient   thor.Address
	Amount      *big.Int
}

Transfer represents tx.Transfer that can be stored in db.

type TransferCriteria added in v1.0.3

type TransferCriteria struct {
	TxOrigin  *thor.Address //who send transaction
	Sender    *thor.Address //who transferred tokens
	Recipient *thor.Address //who recieved tokens
}

type TransferFilter

type TransferFilter struct {
	CriteriaSet []*TransferCriteria
	Range       *Range
	Options     *Options
	Order       Order //default asc
}

type Writer added in v1.3.0

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

Writer is the transactional log writer.

func (*Writer) Commit added in v1.7.0

func (w *Writer) Commit() (err error)

Commit commits accumulated logs.

func (*Writer) Rollback added in v1.7.0

func (w *Writer) Rollback() (err error)

Rollback rollback all uncommitted logs.

func (*Writer) Truncate added in v1.7.0

func (w *Writer) Truncate(blockNum uint32) error

Truncate truncates the database by deleting logs after blockNum (included).

func (*Writer) UncommittedCount added in v1.7.0

func (w *Writer) UncommittedCount() int

UncommittedCount returns the count of uncommitted logs.

func (*Writer) Write added in v1.3.0

func (w *Writer) Write(b *block.Block, receipts tx.Receipts) error

Write writes all logs of the given block.

Jump to

Keyboard shortcuts

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