db

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FinishedRoot = []byte("_FINISHED_ROOT_")
)

Functions

func NewIndexDB

func NewIndexDB(chainID *big.Int, rootDB *storm.DB, cacheSize uint64) *indexDB

func OpenEtherDB

func OpenEtherDB(ctx ServiceContext, name string) (ethdb.Database, error)

func OpenStormDB

func OpenStormDB(ctx ServiceContext, name string) (*storm.DB, error)

Types

type CrossTransactionIndexed

type CrossTransactionIndexed struct {
	PK       uint64         `storm:"id,increment"`
	CtxId    common.Hash    `storm:"unique"`
	From     common.Address `storm:"index"`
	To       common.Address `storm:"index"`
	TxHash   common.Hash    `storm:"index"`
	Price    *big.Float     `storm:"index"`
	BlockNum uint64         `storm:"index"`
	// normal field
	Status uint8 `storm:"index"`

	Value            *big.Int
	BlockHash        common.Hash
	DestinationId    *big.Int
	DestinationValue *big.Int `storm:"index"`
	Input            []byte

	V []*big.Int
	R []*big.Int
	S []*big.Int
}

func (CrossTransactionIndexed) ToCrossTransaction

type CtxDB

type CtxDB interface {
	io.Closer
	ChainID() *big.Int
	Count(filter ...q.Matcher) int
	Height() uint64
	Write(ctx *cc.CrossTransactionWithSignatures) error
	Writes([]*cc.CrossTransactionWithSignatures, bool) error
	Read(ctxId common.Hash) (*cc.CrossTransactionWithSignatures, error)
	Update(id common.Hash, updater func(ctx *CrossTransactionIndexed)) error
	Updates(idList []common.Hash, updaters []func(ctx *CrossTransactionIndexed)) error
	Deletes(idList []common.Hash) error
	Has(id common.Hash) bool

	One(field FieldName, key interface{}) *cc.CrossTransactionWithSignatures
	//Find(field FieldName, key interface{}) []*cc.CrossTransactionWithSignatures
	Query(pageSize int, startPage int, orderBy []FieldName, reverse bool, filter ...q.Matcher) []*cc.CrossTransactionWithSignatures
	RangeByNumber(begin, end uint64, limit int) []*cc.CrossTransactionWithSignatures

	Load() error
	Repair() error
	Clean() error
}

type CtxSortedByBlockNum

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

func NewCtxSortedMap

func NewCtxSortedMap() *CtxSortedByBlockNum

func (*CtxSortedByBlockNum) Do added in v1.0.6

Do calls function f on each element of the map, in forward order.

func (*CtxSortedByBlockNum) Get

func (*CtxSortedByBlockNum) Len

func (m *CtxSortedByBlockNum) Len() int

func (*CtxSortedByBlockNum) Put

func (*CtxSortedByBlockNum) RemoveByID added in v1.0.6

func (m *CtxSortedByBlockNum) RemoveByID(id common.Hash)

func (*CtxSortedByBlockNum) RemoveUnderNum

func (m *CtxSortedByBlockNum) RemoveUnderNum(num uint64) (removed cc.CtxIDs)

type ErrCtxDbFailure

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

func (ErrCtxDbFailure) Error

func (e ErrCtxDbFailure) Error() string

type FieldName added in v1.0.4

type FieldName = string
const (
	PK               FieldName = "PK"
	CtxIdIndex       FieldName = "CtxId"
	TxHashIndex      FieldName = "TxHash"
	PriceIndex       FieldName = "Price"
	StatusField      FieldName = "Status"
	FromField        FieldName = "From"
	ToField          FieldName = "To"
	DestinationValue FieldName = "DestinationValue"
	BlockNumField    FieldName = "BlockNum"
)

type IndexDbCache

type IndexDbCache lru.ARCCache

func (*IndexDbCache) Get

func (m *IndexDbCache) Get(index FieldName, key interface{}) *CrossTransactionIndexed

func (*IndexDbCache) Put

func (m *IndexDbCache) Put(index FieldName, key interface{}, ctx *CrossTransactionIndexed)

func (*IndexDbCache) Remove

func (m *IndexDbCache) Remove(index FieldName, key interface{})

type QueueDB added in v1.0.6

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

func NewQueueDB added in v1.0.6

func NewQueueDB(db ethdb.KeyValueStore) (*QueueDB, error)

func (*QueueDB) Close added in v1.0.6

func (q *QueueDB) Close()

func (*QueueDB) Pop added in v1.0.6

func (q *QueueDB) Pop() ([]byte, error)

func (*QueueDB) Push added in v1.0.6

func (q *QueueDB) Push(data []byte) error

func (*QueueDB) Size added in v1.0.6

func (q *QueueDB) Size() uint64

func (*QueueDB) Stats added in v1.0.6

func (q *QueueDB) Stats() (string, error)

type ServiceContext

type ServiceContext interface {
	ResolvePath(string) string
	OpenDatabase(string, int, int, string) (ethdb.Database, error)
}

type TransactionLog added in v1.0.6

type TransactionLog struct {
	*TransactionLogs
	// contains filtered or unexported fields
}

func (*TransactionLog) AddFinish added in v1.0.6

func (*TransactionLog) Commit added in v1.0.6

func (l *TransactionLog) Commit() (common.Hash, error)

func (*TransactionLog) GetFinish added in v1.0.6

func (*TransactionLog) IsFinish added in v1.0.6

func (l *TransactionLog) IsFinish(hash common.Hash) bool

type TransactionLogs added in v1.0.6

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

func NewTransactionLogs added in v1.0.6

func NewTransactionLogs(db ethdb.KeyValueStore) (*TransactionLogs, error)

func (*TransactionLogs) Close added in v1.0.6

func (l *TransactionLogs) Close()

func (*TransactionLogs) Get added in v1.0.6

func (l *TransactionLogs) Get(chainID *big.Int) *TransactionLog

Jump to

Keyboard shortcuts

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