Documentation ¶
Index ¶
- Constants
- func EncodeKey(key interface{}, typeName string) ([]byte, error)
- func JSONDecode(data []byte, value interface{}) error
- func JSONEncode(value interface{}) ([]byte, error)
- func NewMarketRepositoryImpl(db *DbManager) domain.MarketRepository
- func NewTradeRepositoryImpl(db *DbManager) domain.TradeRepository
- func NewUnspentRepositoryImpl(db *DbManager) domain.UnspentRepository
- func NewVaultRepositoryImpl(db *DbManager) domain.VaultRepository
- type DbManager
- func (d DbManager) NewPricesTransaction() ports.Transaction
- func (d DbManager) NewTransaction() ports.Transaction
- func (d DbManager) NewUnspentsTransaction() ports.Transaction
- func (d DbManager) RunPricesTransaction(ctx context.Context, readOnly bool, ...) (interface{}, error)
- func (d DbManager) RunTransaction(ctx context.Context, readOnly bool, ...) (interface{}, error)
- func (d DbManager) RunUnspentsTransaction(ctx context.Context, readOnly bool, ...) (interface{}, error)
- type LockedUnspent
Constants ¶
const ( UnspentBadgerholdKeyPrefix = "bh_Unspent" LockedUnspentBadgerholdKeyPrefix = "bh_LockedUnspent" )
const (
TradeBadgerholdKeyPrefix = "bh_Trade"
)
Variables ¶
This section is empty.
Functions ¶
func EncodeKey ¶
EncodeKey encodes key values with a type prefix which allows multiple different types to exist in the badger DB
func JSONDecode ¶
JSONDecode is a custom JSON based decoder for badger
func JSONEncode ¶
JSONEncode is a custom JSON based encoder for badger
func NewMarketRepositoryImpl ¶
func NewMarketRepositoryImpl(db *DbManager) domain.MarketRepository
NewMarketRepositoryImpl initialize a badger implementation of the domain.MarketRepository
func NewTradeRepositoryImpl ¶
func NewTradeRepositoryImpl(db *DbManager) domain.TradeRepository
func NewUnspentRepositoryImpl ¶
func NewUnspentRepositoryImpl(db *DbManager) domain.UnspentRepository
func NewVaultRepositoryImpl ¶
func NewVaultRepositoryImpl(db *DbManager) domain.VaultRepository
Types ¶
type DbManager ¶
type DbManager struct { Store *badgerhold.Store PriceStore *badgerhold.Store UnspentStore *badgerhold.Store }
DbManager holds all the badgerhold stores in a single data structure.
func NewDbManager ¶
NewDbManager opens (or creates if not exists) the badger store on disk. It expects a base data dir and an optional logger. It creates a dedicated directory for main, price and unspent.
func (DbManager) NewPricesTransaction ¶
func (d DbManager) NewPricesTransaction() ports.Transaction
NewPricesTransaction implements the DbManager interface
func (DbManager) NewTransaction ¶
func (d DbManager) NewTransaction() ports.Transaction
NewTransaction implements the DbManager interface
func (DbManager) NewUnspentsTransaction ¶
func (d DbManager) NewUnspentsTransaction() ports.Transaction
NewUnspentsTransaction implements the DbManager interface
func (DbManager) RunPricesTransaction ¶
func (d DbManager) RunPricesTransaction( ctx context.Context, readOnly bool, handler func(ctx context.Context) (interface{}, error), ) (interface{}, error)
RunPricesTransaction invokes the given handler and retries in case the unspents transaction returns a conflict error
func (DbManager) RunTransaction ¶
func (d DbManager) RunTransaction( ctx context.Context, readOnly bool, handler func(ctx context.Context) (interface{}, error), ) (interface{}, error)
RunTransaction invokes the given handler and retries in case the transaction returns a conflict error
func (DbManager) RunUnspentsTransaction ¶
func (d DbManager) RunUnspentsTransaction( ctx context.Context, readOnly bool, handler func(ctx context.Context) (interface{}, error), ) (interface{}, error)
RunUnspentsTransaction invokes the given handler and retries in case the unspents transaction returns a conflict error