db

package
v1.0.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

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"`
	TxHash   common.Hash    `storm:"index"`
	Price    *big.Float     `storm:"index"`
	BlockNum uint64         `storm:"index"`

	// normal field
	Status cc.CtxStatus

	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
	//Size() int
	Count(filter ...q.Matcher) int
	Height() uint64
	Load() error
	Repair() error
	Write(ctx *cc.CrossTransactionWithSignatures) error
	Read(ctxId common.Hash) (*cc.CrossTransactionWithSignatures, error)
	One(field FieldName, key interface{}) *cc.CrossTransactionWithSignatures
	//ReadAll(ctxId common.Hash) (common.Hash, error)
	//Delete(ctxId common.Hash, atNumber uint64) error
	Update(id common.Hash, updater func(ctx *CrossTransactionIndexed)) error
	Has(id common.Hash) bool
	Query(pageSize int, startPage int, orderBy FieldName, filter ...q.Matcher) []*cc.CrossTransactionWithSignatures
	RangeByNumber(begin, end uint64, pageSize int) []*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) Map added in v1.0.4

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 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"
	DestinationValue FieldName = "DestinationValue"
	BlockNumField    FieldName = "BlockNum"
)

type Filter

type Filter func(ctx *cc.CrossTransactionWithSignatures) bool

type IndexDbCache

type IndexDbCache lru.ARCCache

func (*IndexDbCache) Get

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

func (*IndexDbCache) Has

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

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 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