logdb

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2021 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() 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) Log added in v1.3.0

func (db *LogDB) Log(f func(*Writer) error) error

Log write logs.

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) Flush added in v1.3.0

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

Flush commits accumulated logs.

func (*Writer) Len added in v1.3.0

func (w *Writer) Len() int

Len returns count of pending 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