Documentation ¶
Index ¶
- Constants
- Variables
- func EncodeKey(key interface{}, typeName string) ([]byte, error)
- func JSONDecode(data []byte, value interface{}) error
- func JSONEncode(value interface{}) ([]byte, error)
- func NewMarketRepositoryImpl(store, priceStore *badgerhold.Store) domain.MarketRepository
- func NewRepoManager(baseDbDir string, logger badger.Logger) (ports.RepoManager, error)
- func NewTradeRepositoryImpl(store *badgerhold.Store) domain.TradeRepository
- func NewUnspentRepositoryImpl(store, lockStore *badgerhold.Store) domain.UnspentRepository
- func NewVaultRepositoryImpl(store *badgerhold.Store) domain.VaultRepository
- type LockedUnspent
- type RepoManager
- func (d *RepoManager) Close()
- func (d *RepoManager) MarketRepository() domain.MarketRepository
- func (d *RepoManager) NewPricesTransaction() ports.Transaction
- func (d *RepoManager) NewTransaction() ports.Transaction
- func (d *RepoManager) NewUnspentsTransaction() ports.Transaction
- func (d *RepoManager) RunPricesTransaction(ctx context.Context, readOnly bool, ...) (interface{}, error)
- func (d *RepoManager) RunTransaction(ctx context.Context, readOnly bool, ...) (interface{}, error)
- func (d *RepoManager) RunUnspentsTransaction(ctx context.Context, readOnly bool, ...) (interface{}, error)
- func (d *RepoManager) TradeRepository() domain.TradeRepository
- func (d *RepoManager) UnspentRepository() domain.UnspentRepository
- func (d *RepoManager) VaultRepository() domain.VaultRepository
Constants ¶
const ( UnspentBadgerholdKeyPrefix = "bh_Unspent" LockedUnspentBadgerholdKeyPrefix = "bh_LockedUnspent" )
const (
TradeBadgerholdKeyPrefix = "bh_Trade"
)
Variables ¶
var ( // ErrMarketInvalidRequest ... ErrMarketInvalidRequest = errors.New("requested market is null") // ErrMarketNotFound ... ErrMarketNotFound = errors.New("market not found") )
var ( // ErrTradeNotFound ... ErrTradeNotFound = errors.New("trade not found") )
var ( // ErrVaultNotFound ... ErrVaultNotFound = errors.New("vault not found") )
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(store, priceStore *badgerhold.Store) domain.MarketRepository
NewMarketRepositoryImpl initialize a badger implementation of the domain.MarketRepository
func NewRepoManager ¶ added in v0.3.1
func NewRepoManager(baseDbDir string, logger badger.Logger) (ports.RepoManager, error)
NewRepoManager 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 and prices stores, while the unspent repository lives in memory.
func NewTradeRepositoryImpl ¶
func NewTradeRepositoryImpl(store *badgerhold.Store) domain.TradeRepository
func NewUnspentRepositoryImpl ¶
func NewUnspentRepositoryImpl(store, lockStore *badgerhold.Store) domain.UnspentRepository
func NewVaultRepositoryImpl ¶
func NewVaultRepositoryImpl(store *badgerhold.Store) domain.VaultRepository
Types ¶
type LockedUnspent ¶
type RepoManager ¶ added in v0.3.1
type RepoManager struct {
// contains filtered or unexported fields
}
RepoManager holds all the badgerhold stores in a single data structure.
func (*RepoManager) Close ¶ added in v0.3.1
func (d *RepoManager) Close()
func (*RepoManager) MarketRepository ¶ added in v0.3.1
func (d *RepoManager) MarketRepository() domain.MarketRepository
func (*RepoManager) NewPricesTransaction ¶ added in v0.3.1
func (d *RepoManager) NewPricesTransaction() ports.Transaction
NewPricesTransaction implements the RepoManager interface
func (*RepoManager) NewTransaction ¶ added in v0.3.1
func (d *RepoManager) NewTransaction() ports.Transaction
NewTransaction implements the RepoManager interface
func (*RepoManager) NewUnspentsTransaction ¶ added in v0.3.1
func (d *RepoManager) NewUnspentsTransaction() ports.Transaction
NewUnspentsTransaction implements the RepoManager interface
func (*RepoManager) RunPricesTransaction ¶ added in v0.3.1
func (d *RepoManager) 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 (*RepoManager) RunTransaction ¶ added in v0.3.1
func (d *RepoManager) 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 (*RepoManager) RunUnspentsTransaction ¶ added in v0.3.1
func (d *RepoManager) 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
func (*RepoManager) TradeRepository ¶ added in v0.3.1
func (d *RepoManager) TradeRepository() domain.TradeRepository
func (*RepoManager) UnspentRepository ¶ added in v0.3.1
func (d *RepoManager) UnspentRepository() domain.UnspentRepository
func (*RepoManager) VaultRepository ¶ added in v0.3.1
func (d *RepoManager) VaultRepository() domain.VaultRepository