db

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 9, 2020 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//index
	PK         = "PK"
	CtxIdIndex = "CtxId"
	PriceIndex = "Price"
	//field
	StatusField = "Status"
	FromField   = "From"
)

Variables

This section is empty.

Functions

func ComparePrice

func ComparePrice(hi, hj *cc.CrossTransactionWithSignatures) bool

func NewCacheDb

func NewCacheDb(chainID *big.Int, db ethdb.KeyValueStore, cacheSize uint64) *cacheDB

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"`
	Price *big.Float     `storm:"index"`

	// normal field
	Status cc.CtxStatus

	Value            *big.Int
	TxHash           common.Hash
	BlockHash        common.Hash
	DestinationId    *big.Int
	DestinationValue *big.Int
	Input            []byte

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

func (CrossTransactionIndexed) ToCrossTransaction

type CtxDB

type CtxDB interface {
	io.Closer
	Size() int
	Height() int
	Load() error
	Write(ctx *cc.CrossTransactionWithSignatures) error
	Read(ctxId common.Hash) (*cc.CrossTransactionWithSignatures, error)
	ReadAll(ctxId common.Hash) (common.Hash, error)
	Delete(ctxId common.Hash) error
	Update(id common.Hash, updater func(ctx *CrossTransactionIndexed)) error
	Has(id common.Hash) bool
	QueryByPK(pageSize int, startPage int, filter ...interface{}) []*cc.CrossTransactionWithSignatures
	QueryByPrice(pageSize int, startPage int, filter ...interface{}) []*cc.CrossTransactionWithSignatures
	Range(pageSize int, startCtxID *common.Hash, endCtxID *common.Hash) []*cc.CrossTransactionWithSignatures
}

type CtxSortedByBlockNum

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

func NewCtxSortedMap

func NewCtxSortedMap() *CtxSortedByBlockNum

func (*CtxSortedByBlockNum) Get

func (*CtxSortedByBlockNum) Len

func (m *CtxSortedByBlockNum) Len() int

func (*CtxSortedByBlockNum) Put

func (*CtxSortedByBlockNum) RemoveByHash

func (m *CtxSortedByBlockNum) RemoveByHash(hash common.Hash)

func (*CtxSortedByBlockNum) RemoveUnderNum

func (m *CtxSortedByBlockNum) RemoveUnderNum(num uint64)

type CtxSortedByPrice

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

func NewCtxSortedByPrice

func NewCtxSortedByPrice(cap uint64) *CtxSortedByPrice

func (*CtxSortedByPrice) Add

func (*CtxSortedByPrice) Cap

func (t *CtxSortedByPrice) Cap() uint64

func (*CtxSortedByPrice) Count

func (t *CtxSortedByPrice) Count() int

Count returns the current number of items in the all.

func (*CtxSortedByPrice) Get

func (*CtxSortedByPrice) GetAll

func (*CtxSortedByPrice) GetList

func (*CtxSortedByPrice) Remove

func (t *CtxSortedByPrice) Remove(id common.Hash) bool

Remove removes a transaction from the all.

func (*CtxSortedByPrice) Update

func (t *CtxSortedByPrice) Update(id common.Hash, updater func(*cc.CrossTransactionWithSignatures))

Update

type CtxToBlockHash

type CtxToBlockHash lru.ARCCache

func NewCtxToBlockHash

func NewCtxToBlockHash(cap int) *CtxToBlockHash

func (*CtxToBlockHash) Get

func (m *CtxToBlockHash) Get(txID common.Hash) (common.Hash, bool)

func (*CtxToBlockHash) Has

func (m *CtxToBlockHash) Has(txID common.Hash) bool

func (*CtxToBlockHash) Put

func (m *CtxToBlockHash) Put(txID common.Hash, blockHash common.Hash) bool

type ErrCtxDbFailure

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

func (ErrCtxDbFailure) Error

func (e ErrCtxDbFailure) Error() string

type Filter

type Filter func(ctx *cc.CrossTransactionWithSignatures) bool

type IndexDbCache

type IndexDbCache lru.ARCCache

func (*IndexDbCache) Get

func (*IndexDbCache) Has

func (m *IndexDbCache) Has(ctxID common.Hash) bool

func (*IndexDbCache) Put

func (m *IndexDbCache) Put(ctxID common.Hash, ctx *CrossTransactionIndexed)

func (*IndexDbCache) Remove

func (m *IndexDbCache) Remove(ctxID common.Hash)

type ServiceContext

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

Jump to

Keyboard shortcuts

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