logdb

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2019 License: LGPL-3.0 Imports: 8 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()

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) NewTask added in v1.1.0

func (db *LogDB) NewTask() *Task

NewTask create a new task to perform transactional operations of writing 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 {
	Unit RangeType
	From uint64
	To   uint64
}

type RangeType

type RangeType string
const (
	Block RangeType = "block"
	Time  RangeType = "time"
)

type Task added in v1.1.0

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

Task to transactionally perform logs writting.

func (*Task) Commit added in v1.1.0

func (t *Task) Commit() error

Commit commit task.

func (*Task) ForBlock added in v1.1.0

func (t *Task) ForBlock(b *block.Header) *Task

ForBlock set context to given block.

func (*Task) Write added in v1.1.0

func (t *Task) Write(txID thor.Bytes32, txOrigin thor.Address, outputs []*tx.Output) *Task

Write write all outputs of a tx.

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 {
	TxID        *thor.Bytes32
	CriteriaSet []*TransferCriteria
	Range       *Range
	Options     *Options
	Order       Order //default asc
}

Jump to

Keyboard shortcuts

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