db

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var KeyNotFound = errors.New("key not found")

Functions

func DeleteSwapPending added in v1.0.1

func DeleteSwapPending(db *gorm.DB, record *types.SwapPending) error

func GetQGasSwapInfoByUniqueID added in v1.0.1

func GetQGasSwapInfoByUniqueID(db *gorm.DB, hash string, action types.QGasSwapType) (*types.QGasSwapInfo, error)

func GetQGasSwapInfoByUserTxHash added in v1.0.1

func GetQGasSwapInfoByUserTxHash(db *gorm.DB, hash string) (*types.QGasSwapInfo, error)

func GetQGasSwapInfos added in v1.0.1

func GetQGasSwapInfos(db *gorm.DB, page, pageSize int) ([]*types.QGasSwapInfo, error)

func GetQGasSwapInfosByState added in v1.0.1

func GetQGasSwapInfosByState(db *gorm.DB, page, pageSize int, state types.QGasSwapState) ([]*types.QGasSwapInfo, error)

func GetQGasSwapInfosByUserAddr added in v1.0.1

func GetQGasSwapInfosByUserAddr(db *gorm.DB, page, pageSize int, addr string, action types.QGasSwapType) ([]*types.QGasSwapInfo, error)

func GetSwapInfoByTxHash added in v1.0.1

func GetSwapInfoByTxHash(db *gorm.DB, hash string, action types.ChainType) (*types.SwapInfo, error)

func GetSwapInfos added in v1.0.1

func GetSwapInfos(db *gorm.DB, page, pageSize int) ([]*types.SwapInfo, error)

func GetSwapInfosByAddr added in v1.0.1

func GetSwapInfosByAddr(db *gorm.DB, page, pageSize int, addr string, action types.ChainType) ([]*types.SwapInfo, error)

func GetSwapInfosByState added in v1.0.1

func GetSwapInfosByState(db *gorm.DB, page, pageSize int, state types.SwapState) ([]*types.SwapInfo, error)

func GetSwapPendingByTxEthHash added in v1.0.1

func GetSwapPendingByTxEthHash(db *gorm.DB, hash string) (*types.SwapPending, error)

func GetSwapPendingByTxNeoHash added in v1.0.1

func GetSwapPendingByTxNeoHash(db *gorm.DB, hash string) (*types.SwapPending, error)

func GetSwapPendings added in v1.0.1

func GetSwapPendings(db *gorm.DB, page, pageSize int) ([]*types.SwapPending, error)

func InsertQGasSwapInfo added in v1.0.1

func InsertQGasSwapInfo(db *gorm.DB, record *types.QGasSwapInfo) error

func InsertSwapInfo added in v1.0.1

func InsertSwapInfo(db *gorm.DB, record *types.SwapInfo) error

func InsertSwapPending added in v1.0.1

func InsertSwapPending(db *gorm.DB, record *types.SwapPending) error

func NewDB added in v1.0.1

func NewDB(url string) (*gorm.DB, error)

func Paginate added in v1.0.1

func Paginate(page, pageSize int) func(db *gorm.DB) *gorm.DB

func UpdateQGasSwapInfo added in v1.0.1

func UpdateQGasSwapInfo(db *gorm.DB, record *types.QGasSwapInfo) error

func UpdateSwapInfo added in v1.0.1

func UpdateSwapInfo(db *gorm.DB, record *types.SwapInfo) error

Types

type ActionType

type ActionType byte
const (
	Dump ActionType = iota
	GC
	Backup
	Restore
	Size
)

type BadgerStore

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

func (*BadgerStore) Action

func (b *BadgerStore) Action(at ActionType) (interface{}, error)

func (*BadgerStore) Batch

func (b *BadgerStore) Batch(canRead bool) Batch

func (*BadgerStore) BatchWrite

func (b *BadgerStore) BatchWrite(canRead bool, fn func(batch Batch) error) error

func (*BadgerStore) Close

func (b *BadgerStore) Close() error

func (*BadgerStore) Count

func (b *BadgerStore) Count(prefix []byte) (uint64, error)

func (*BadgerStore) Delete

func (b *BadgerStore) Delete(k []byte) error

func (*BadgerStore) Drop

func (b *BadgerStore) Drop(prefix []byte) error

func (*BadgerStore) Get

func (b *BadgerStore) Get(k []byte) ([]byte, error)

func (*BadgerStore) Has

func (b *BadgerStore) Has(k []byte) (bool, error)

func (*BadgerStore) Iterator

func (b *BadgerStore) Iterator(prefix []byte, end []byte, fn func(k, v []byte) error) error

func (*BadgerStore) Purge

func (b *BadgerStore) Purge() error

func (*BadgerStore) Put

func (b *BadgerStore) Put(k, v []byte) error

func (*BadgerStore) PutBatch

func (b *BadgerStore) PutBatch(batch Batch) error

func (*BadgerStore) Upgrade

func (b *BadgerStore) Upgrade(int) error

type BadgerTransaction

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

func (*BadgerTransaction) Delete

func (b *BadgerTransaction) Delete(k []byte) error

func (*BadgerTransaction) Discard

func (b *BadgerTransaction) Discard()

func (*BadgerTransaction) Drop

func (b *BadgerTransaction) Drop(prefix []byte) error

func (*BadgerTransaction) Get

func (b *BadgerTransaction) Get(k []byte) (interface{}, error)

func (*BadgerTransaction) Iterator

func (b *BadgerTransaction) Iterator(prefix []byte, end []byte, fn func(k, v []byte) error) error

func (*BadgerTransaction) Put

func (b *BadgerTransaction) Put(k []byte, v interface{}) error

type BadgerWriteBatch

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

func (*BadgerWriteBatch) Delete

func (b *BadgerWriteBatch) Delete(k []byte) error

func (*BadgerWriteBatch) Discard

func (b *BadgerWriteBatch) Discard()

func (*BadgerWriteBatch) Drop

func (b *BadgerWriteBatch) Drop([]byte) error

func (*BadgerWriteBatch) Get

func (b *BadgerWriteBatch) Get([]byte) (interface{}, error)

func (*BadgerWriteBatch) Iterator

func (b *BadgerWriteBatch) Iterator([]byte, []byte, func(k []byte, v []byte) error) error

func (*BadgerWriteBatch) Put

func (b *BadgerWriteBatch) Put(k []byte, v interface{}) error

type Batch

type Batch interface {
	Put(k []byte, v interface{}) error
	Delete(k []byte) error
	Get([]byte) (interface{}, error)
	Iterator(prefix []byte, end []byte, f func(k, v []byte) error) error
	Drop(prefix []byte) error
	Discard()
}

type KeyPrefix

type KeyPrefix byte

type Store

type Store interface {
	Delete(k []byte) error
	Get([]byte) ([]byte, error)
	Put(k, v []byte) error
	Has(k []byte) (bool, error)
	Batch(bool) Batch
	PutBatch(Batch) error
	BatchWrite(bool, func(batch Batch) error) error
	//BatchView(func(batch Batch) error) error
	Iterator(prefix []byte, end []byte, f func(k, v []byte) error) error
	Count(prefix []byte) (uint64, error)
	Purge() error
	Drop(prefix []byte) error
	Upgrade(version int) error
	Action(at ActionType) (interface{}, error)
	Close() error
}

func NewBadgerStore

func NewBadgerStore(dir string) (Store, error)

NewBadgerStore initializes/opens a badger database in the given directory.

Jump to

Keyboard shortcuts

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