inmemory

package
v0.9.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMarketNotExist ...
	ErrMarketNotExist = errors.New("market does not exists")
	// ErrMarketNotFound ...
	ErrMarketNotFound = errors.New("market not found")
	// ErrMarketInvalidRequest ...
	ErrMarketInvalidRequest = errors.New("requested market is null")
)

Market errors

View Source
var (
	// ErrTradeNotFound ...
	ErrTradeNotFound = errors.New("trade not found")
)

Trade errors

View Source
var (
	// ErrVaultNotFound ...
	ErrVaultNotFound = errors.New("vault not found")
)

Vault errors

Functions

func NewDepositRepositoryImpl added in v0.6.0

func NewDepositRepositoryImpl(store *depositInmemoryStore) domain.DepositRepository

NewDepositRepositoryImpl returns a new empty DepositRepositoryImpl

func NewMarketRepositoryImpl

func NewMarketRepositoryImpl(store *marketInmemoryStore) domain.MarketRepository

NewMarketRepositoryImpl returns a new empty MarketRepositoryImpl

func NewRepoManager added in v0.3.1

func NewRepoManager() ports.RepoManager

func NewTradeRepositoryImpl

func NewTradeRepositoryImpl(store *tradeInmemoryStore) domain.TradeRepository

NewTradeRepositoryImpl returns a new inmemory TradeRepository implementation.

func NewUnspentRepositoryImpl

func NewUnspentRepositoryImpl(store *unspentInmemoryStore) domain.UnspentRepository

NewUnspentRepositoryImpl returns a new empty MarketRepositoryImpl

func NewVaultRepositoryImpl

func NewVaultRepositoryImpl(store *vaultInmemoryStore) domain.VaultRepository

NewVaultRepositoryImpl returns a new empty VaultRepositoryImpl

func NewWithdrawalRepositoryImpl added in v0.6.0

func NewWithdrawalRepositoryImpl(store *withdrawalInmemoryStore) domain.WithdrawalRepository

NewWithdrawalRepositoryImpl returns a new empty DepositRepositoryImpl

Types

type DepositRepositoryImpl added in v0.6.0

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

func (DepositRepositoryImpl) AddDeposits added in v0.6.0

func (d DepositRepositoryImpl) AddDeposits(
	ctx context.Context,
	deposits []domain.Deposit,
) (int, error)

func (DepositRepositoryImpl) ListAllDeposits added in v0.6.0

func (d DepositRepositoryImpl) ListAllDeposits(
	ctx context.Context,
) ([]domain.Deposit, error)

func (DepositRepositoryImpl) ListAllDepositsForPage added in v0.6.0

func (d DepositRepositoryImpl) ListAllDepositsForPage(
	ctx context.Context, page domain.Page,
) ([]domain.Deposit, error)

func (DepositRepositoryImpl) ListDepositsForAccount added in v0.6.0

func (d DepositRepositoryImpl) ListDepositsForAccount(
	ctx context.Context,
	accountIndex int,
) ([]domain.Deposit, error)

func (DepositRepositoryImpl) ListDepositsForAccountAndPage added in v0.6.0

func (d DepositRepositoryImpl) ListDepositsForAccountAndPage(
	ctx context.Context,
	accountIndex int,
	page domain.Page,
) ([]domain.Deposit, error)

type InmemoryTx added in v0.1.0

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

func (*InmemoryTx) Commit added in v0.1.0

func (tx *InmemoryTx) Commit() error

func (*InmemoryTx) Discard added in v0.1.0

func (tx *InmemoryTx) Discard()

type MarketRepositoryImpl

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

MarketRepositoryImpl represents an in memory storage

func (MarketRepositoryImpl) CloseMarket

func (r MarketRepositoryImpl) CloseMarket(_ context.Context, accountIndex int) error

CloseMarket makes a market found with the given quote asset hash as NOT available for trading

func (*MarketRepositoryImpl) DeleteMarket added in v0.3.0

func (r *MarketRepositoryImpl) DeleteMarket(
	_ context.Context,
	accountIndex int,
) error

func (MarketRepositoryImpl) GetAllMarkets

func (r MarketRepositoryImpl) GetAllMarkets(_ context.Context) ([]domain.Market, error)

GetAllMarkets returns all the markets either tradable or not.

func (MarketRepositoryImpl) GetLatestMarket

func (r MarketRepositoryImpl) GetLatestMarket(_ context.Context) (market *domain.Market, accountIndex int, err error)

GetLatestMarket returns the latest stored market (either funded or not)

func (MarketRepositoryImpl) GetMarketByAccount added in v0.1.0

func (r MarketRepositoryImpl) GetMarketByAccount(_ context.Context, accountIndex int) (*domain.Market, error)

GetMarketByAccount return the market for the account index given as parameter

func (MarketRepositoryImpl) GetMarketByAssets added in v0.8.0

func (r MarketRepositoryImpl) GetMarketByAssets(_ context.Context, baseAsset, quoteAsset string) (market *domain.Market, accountIndex int, err error)

GetMarketByAsset returns a funded market using the quote asset hash

func (MarketRepositoryImpl) GetOrCreateMarket

func (r MarketRepositoryImpl) GetOrCreateMarket(_ context.Context, market *domain.Market) (*domain.Market, error)

GetOrCreateMarket gets a market with a given account index. If not found, a new entry is inserted

func (MarketRepositoryImpl) GetTradableMarkets

func (r MarketRepositoryImpl) GetTradableMarkets(_ context.Context) (tradableMarkets []domain.Market, err error)

GetTradableMarkets returns all the markets available for trading

func (MarketRepositoryImpl) OpenMarket

func (r MarketRepositoryImpl) OpenMarket(_ context.Context, accountIndex int) error

OpenMarket makes a market found with the given quote asset hash as available for trading

func (MarketRepositoryImpl) UpdateMarket

func (r MarketRepositoryImpl) UpdateMarket(
	_ context.Context,
	accountIndex int,
	updateFn func(m *domain.Market) (*domain.Market, error),
) error

UpdateMarket updates data to a market identified by the account index passing an update function

func (*MarketRepositoryImpl) UpdatePrices added in v0.1.0

func (r *MarketRepositoryImpl) UpdatePrices(_ context.Context, accountIndex int, prices domain.Prices) error

type RepoManager added in v0.3.1

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

func (*RepoManager) Close added in v0.3.1

func (d *RepoManager) Close()

func (*RepoManager) DepositRepository added in v0.6.0

func (d *RepoManager) DepositRepository() domain.DepositRepository

func (*RepoManager) MarketRepository added in v0.3.1

func (d *RepoManager) MarketRepository() domain.MarketRepository

func (*RepoManager) NewPricesTransaction added in v0.3.1

func (db *RepoManager) NewPricesTransaction() ports.Transaction

func (*RepoManager) NewTransaction added in v0.3.1

func (db *RepoManager) NewTransaction() ports.Transaction

func (*RepoManager) NewUnspentsTransaction added in v0.3.1

func (db *RepoManager) NewUnspentsTransaction() ports.Transaction

func (*RepoManager) RunPricesTransaction added in v0.3.1

func (db *RepoManager) RunPricesTransaction(
	ctx context.Context,
	readOnly bool,
	handler func(ctx context.Context) (interface{}, error),
) (interface{}, error)

func (*RepoManager) RunTransaction added in v0.3.1

func (db *RepoManager) RunTransaction(
	ctx context.Context,
	_ bool,
	handler func(ctx context.Context) (interface{}, error),
) (interface{}, error)

func (*RepoManager) RunUnspentsTransaction added in v0.3.1

func (db *RepoManager) RunUnspentsTransaction(
	ctx context.Context,
	readOnly bool,
	handler func(ctx context.Context) (interface{}, error),
) (interface{}, 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

func (*RepoManager) WithdrawalRepository added in v0.6.0

func (d *RepoManager) WithdrawalRepository() domain.WithdrawalRepository

type UnspentRepositoryImpl

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

UnspentRepositoryImpl represents an in memory storage

func (UnspentRepositoryImpl) AddUnspents

func (r UnspentRepositoryImpl) AddUnspents(
	_ context.Context, unspents []domain.Unspent,
) (int, error)

AddUnspents method is used by crawler to add unspent's to the memory, it assumes that all unspent's belongs to the same address, it assumes that each time it is invoked by crawler, it assumes that it will receive all unspent's for specific address it adds non exiting unspent's to the memory in case that unspent's, passed to the function, are not already in memory it will mark unspent in memory, as spent

func (UnspentRepositoryImpl) ConfirmUnspents added in v0.1.0

func (r UnspentRepositoryImpl) ConfirmUnspents(
	ctx context.Context,
	unspentKeys []domain.UnspentKey,
) (int, error)

ConfirmUnspents ...

func (UnspentRepositoryImpl) GetAllUnspents

func (r UnspentRepositoryImpl) GetAllUnspents(_ context.Context) []domain.Unspent

GetAllUnspents returns all the unspents stored

func (UnspentRepositoryImpl) GetAllUnspentsForAddresses added in v0.1.0

func (r UnspentRepositoryImpl) GetAllUnspentsForAddresses(
	ctx context.Context, addresses []string,
) ([]domain.Unspent, error)

GetAllUnspentsForAddresses ...

func (UnspentRepositoryImpl) GetAllUnspentsForAddressesAndPage added in v0.6.0

func (r UnspentRepositoryImpl) GetAllUnspentsForAddressesAndPage(
	ctx context.Context, addresses []string, page domain.Page,
) ([]domain.Unspent, error)

GetAllUnspentsForAddressesAndPage ...

func (UnspentRepositoryImpl) GetAvailableUnspents

func (r UnspentRepositoryImpl) GetAvailableUnspents(_ context.Context) ([]domain.Unspent, error)

GetAvailableUnspents ...

func (UnspentRepositoryImpl) GetAvailableUnspentsForAddresses

func (r UnspentRepositoryImpl) GetAvailableUnspentsForAddresses(
	_ context.Context,
	addresses []string,
) ([]domain.Unspent, error)

GetAvailableUnspentsForAddresses ...

func (UnspentRepositoryImpl) GetBalance

func (r UnspentRepositoryImpl) GetBalance(
	_ context.Context,
	addresses []string,
	assetHash string,
) (uint64, error)

GetBalance ...

func (UnspentRepositoryImpl) GetUnlockedBalance

func (r UnspentRepositoryImpl) GetUnlockedBalance(
	_ context.Context,
	addresses []string,
	assetHash string,
) (uint64, error)

GetUnlockedBalance ...

func (UnspentRepositoryImpl) GetUnspentsForAddresses added in v0.1.0

func (r UnspentRepositoryImpl) GetUnspentsForAddresses(
	_ context.Context,
	addresses []string,
) ([]domain.Unspent, error)

GetUnspentsForAddresses ...

func (UnspentRepositoryImpl) LockUnspents

func (r UnspentRepositoryImpl) LockUnspents(
	_ context.Context,
	unspentKeys []domain.UnspentKey,
	tradeID uuid.UUID,
) (int, error)

LockUnspents ...

func (UnspentRepositoryImpl) SpendUnspents added in v0.1.0

func (r UnspentRepositoryImpl) SpendUnspents(
	ctx context.Context,
	unspentKeys []domain.UnspentKey,
) (int, error)

SpendUnspents ...

func (UnspentRepositoryImpl) UnlockUnspents

func (r UnspentRepositoryImpl) UnlockUnspents(
	_ context.Context,
	unspentKeys []domain.UnspentKey,
) (int, error)

UnlockUnspents ...

type VaultRepositoryImpl

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

VaultRepositoryImpl represents an in memory storage

func (VaultRepositoryImpl) GetAccountByAddress

func (r VaultRepositoryImpl) GetAccountByAddress(
	ctx context.Context,
	addr string,
) (*domain.Account, int, error)

func (VaultRepositoryImpl) GetAccountByIndex

func (r VaultRepositoryImpl) GetAccountByIndex(ctx context.Context,
	accountIndex int) (*domain.Account, error)

func (VaultRepositoryImpl) GetAllDerivedAddressesInfoForAccount added in v0.3.0

func (r VaultRepositoryImpl) GetAllDerivedAddressesInfoForAccount(
	ctx context.Context,
	accountIndex int,
) (domain.AddressesInfo, error)

func (VaultRepositoryImpl) GetAllDerivedExternalAddressesInfoForAccount added in v0.3.0

func (r VaultRepositoryImpl) GetAllDerivedExternalAddressesInfoForAccount(
	ctx context.Context,
	accountIndex int,
) (domain.AddressesInfo, error)

func (VaultRepositoryImpl) GetDerivationPathByScript

func (r VaultRepositoryImpl) GetDerivationPathByScript(
	ctx context.Context,
	accountIndex int,
	scripts []string,
) (map[string]string, error)

func (VaultRepositoryImpl) GetOrCreateVault

func (r VaultRepositoryImpl) GetOrCreateVault(
	ctx context.Context,
	mnemonic []string,
	passphrase string,
	net *network.Network,
) (*domain.Vault, error)

func (VaultRepositoryImpl) UpdateVault

func (r VaultRepositoryImpl) UpdateVault(
	ctx context.Context,
	updateFn func(*domain.Vault) (*domain.Vault, error),
) error

UpdateVault updates data to the Vault passing an update function

type WithdrawalRepositoryImpl added in v0.6.0

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

func (WithdrawalRepositoryImpl) AddWithdrawals added in v0.6.0

func (w WithdrawalRepositoryImpl) AddWithdrawals(
	_ context.Context,
	withdrawals []domain.Withdrawal,
) (int, error)

func (WithdrawalRepositoryImpl) ListAllWithdrawals added in v0.6.0

func (w WithdrawalRepositoryImpl) ListAllWithdrawals(
	_ context.Context,
) ([]domain.Withdrawal, error)

func (WithdrawalRepositoryImpl) ListAllWithdrawalsForPage added in v0.6.0

func (w WithdrawalRepositoryImpl) ListAllWithdrawalsForPage(
	_ context.Context, page domain.Page,
) ([]domain.Withdrawal, error)

func (WithdrawalRepositoryImpl) ListWithdrawalsForAccount added in v0.6.0

func (w WithdrawalRepositoryImpl) ListWithdrawalsForAccount(
	_ context.Context, accountIndex int,
) ([]domain.Withdrawal, error)

func (WithdrawalRepositoryImpl) ListWithdrawalsForAccountAndPage added in v0.6.0

func (w WithdrawalRepositoryImpl) ListWithdrawalsForAccountAndPage(
	_ context.Context, accountIndex int, page domain.Page,
) ([]domain.Withdrawal, error)

Jump to

Keyboard shortcuts

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