Documentation
¶
Index ¶
- Constants
- func NewDB(dbPath string, logger dex.Logger, opts ...Opts) (dexdb.DB, error)
- type BoltDB
- func (db *BoltDB) Account(url string) (*dexdb.AccountInfo, error)
- func (db *BoltDB) AccountOrders(dex string, n int, since uint64) ([]*dexdb.MetaOrder, error)
- func (db *BoltDB) Accounts() ([]*dexdb.AccountInfo, error)
- func (db *BoltDB) AckNotification(id []byte) error
- func (db *BoltDB) ActiveDEXOrders(dex string) ([]*dexdb.MetaOrder, error)
- func (db *BoltDB) ActiveMatches() ([]*dexdb.MetaMatch, error)
- func (db *BoltDB) ActiveOrders() ([]*dexdb.MetaOrder, error)
- func (db *BoltDB) AddBond(host string, bond *db.Bond) error
- func (db *BoltDB) Backup() error
- func (db *BoltDB) BackupTo(dst string, overwrite, compact bool) error
- func (db *BoltDB) BondRefunded(host string, assetID uint32, bondCoinID []byte) error
- func (db *BoltDB) ConfirmBond(host string, assetID uint32, bondCoinID []byte) error
- func (db *BoltDB) CreateAccount(ai *dexdb.AccountInfo) error
- func (db *BoltDB) DEXOrdersWithActiveMatches(dex string) ([]order.OrderID, error)
- func (db *BoltDB) DeleteInactiveMatches(ctx context.Context, olderThan *time.Time, ...) (int, error)
- func (db *BoltDB) DeleteInactiveOrders(ctx context.Context, olderThan *time.Time, ...) (int, error)
- func (db *BoltDB) DisabledRateSources() (disabledSources []string, err error)
- func (db *BoltDB) Language() (lang string, _ error)
- func (db *BoltDB) LinkOrder(oid, linkedID order.OrderID) error
- func (db *BoltDB) ListAccounts() ([]string, error)
- func (db *BoltDB) LoadPokes() (pokes []*dexdb.Notification, _ error)
- func (db *BoltDB) MarketOrders(dex string, base, quote uint32, n int, since uint64) ([]*dexdb.MetaOrder, error)
- func (db *BoltDB) MatchesForOrder(oid order.OrderID, excludeCancels bool) ([]*dexdb.MetaMatch, error)
- func (db *BoltDB) NextBondKeyIndex(assetID uint32) (uint32, error)
- func (db *BoltDB) NotificationsN(n int) ([]*dexdb.Notification, error)
- func (db *BoltDB) Order(oid order.OrderID) (mord *dexdb.MetaOrder, err error)
- func (db *BoltDB) Orders(orderFilter *dexdb.OrderFilter) (ords []*dexdb.MetaOrder, err error)
- func (db *BoltDB) PrimaryCredentials() (creds *dexdb.PrimaryCredentials, err error)
- func (db *BoltDB) Recrypt(creds *dexdb.PrimaryCredentials, oldCrypter, newCrypter encrypt.Crypter) (walletUpdates map[uint32][]byte, acctUpdates map[string][]byte, err error)
- func (db *BoltDB) Run(ctx context.Context)
- func (db *BoltDB) SaveDisabledRateSources(disabledSources []string) error
- func (db *BoltDB) SaveNotification(note *dexdb.Notification) error
- func (db *BoltDB) SavePokes(pokes []*dexdb.Notification) error
- func (db *BoltDB) SeedGenerationTime() (uint64, error)
- func (db *BoltDB) SetLanguage(lang string) error
- func (db *BoltDB) SetPrimaryCredentials(creds *dexdb.PrimaryCredentials) error
- func (db *BoltDB) SetSeedGenerationTime(time uint64) error
- func (db *BoltDB) SetWalletPassword(wid []byte, newEncPW []byte) error
- func (db *BoltDB) ToggleAccountStatus(host string, disable bool) error
- func (db *BoltDB) UpdateAccountInfo(ai *dexdb.AccountInfo) error
- func (db *BoltDB) UpdateBalance(wid []byte, bal *dexdb.Balance) error
- func (db *BoltDB) UpdateMatch(m *dexdb.MetaMatch) error
- func (db *BoltDB) UpdateOrder(m *dexdb.MetaOrder) error
- func (db *BoltDB) UpdateOrderMetaData(oid order.OrderID, md *dexdb.OrderMetaData) error
- func (db *BoltDB) UpdateOrderStatus(oid order.OrderID, status order.OrderStatus) error
- func (db *BoltDB) UpdateWallet(wallet *dexdb.Wallet) error
- func (db *BoltDB) UpdateWalletStatus(wid []byte, disable bool) error
- func (db *BoltDB) Wallet(wid []byte) (wallet *dexdb.Wallet, err error)
- func (db *BoltDB) Wallets() ([]*dexdb.Wallet, error)
- type Opts
Constants ¶
const DBVersion = uint32(len(upgrades))
DBVersion is the latest version of the database that is understood. Databases with recorded versions higher than this will fail to open (meaning any upgrades prevent reverting to older software).
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BoltDB ¶
BoltDB is a bbolt-based database backend for Bison Wallet. BoltDB satisfies the db.DB interface defined at decred.org/dcrdex/client/db.
func (*BoltDB) Account ¶
func (db *BoltDB) Account(url string) (*dexdb.AccountInfo, error)
Account gets the AccountInfo associated with the specified DEX address.
func (*BoltDB) AccountOrders ¶
AccountOrders retrieves all orders associated with the specified DEX. n = 0 applies no limit on number of orders returned. since = 0 is equivalent to disabling the time filter, since no orders were created before 1970.
func (*BoltDB) Accounts ¶
func (db *BoltDB) Accounts() ([]*dexdb.AccountInfo, error)
Accounts returns a list of DEX Accounts. The DB is designed to have a single account per DEX, so the account itself is identified by the DEX host. TODO: allow bonds filter based on lockTime.
func (*BoltDB) AckNotification ¶
AckNotification sets the acknowledgement for a notification.
func (*BoltDB) ActiveDEXOrders ¶
ActiveDEXOrders retrieves all orders for the specified DEX.
func (*BoltDB) ActiveMatches ¶
ActiveMatches retrieves the matches that are in an active state, which is any match that is still active.
func (*BoltDB) ActiveOrders ¶
ActiveOrders retrieves all orders which appear to be in an active state, which is either in the epoch queue or in the order book.
func (*BoltDB) AddBond ¶ added in v0.6.0
AddBond saves a new Bond or updates an existing bond for an existing DEX account.
func (*BoltDB) Backup ¶
Backup makes a copy of the database in the "backup" folder, overwriting any existing backup.
func (*BoltDB) BackupTo ¶ added in v0.4.2
BackupTo makes a copy of the database to the specified file, optionally overwriting and compacting the DB.
func (*BoltDB) BondRefunded ¶ added in v0.6.0
BondRefunded marks a DEX account bond as refunded by the client wallet.
func (*BoltDB) ConfirmBond ¶ added in v0.6.0
ConfirmBond marks a DEX account bond as confirmed by the DEX.
func (*BoltDB) CreateAccount ¶
func (db *BoltDB) CreateAccount(ai *dexdb.AccountInfo) error
CreateAccount saves the AccountInfo. If an account already exists for this DEX, it will return an error.
func (*BoltDB) DEXOrdersWithActiveMatches ¶
DEXOrdersWithActiveMatches retrieves order IDs for any order that has active matches, regardless of whether the order itself is in an active state.
func (*BoltDB) DeleteInactiveMatches ¶ added in v0.5.0
func (db *BoltDB) DeleteInactiveMatches(ctx context.Context, olderThan *time.Time, perMatchFn func(mtch *dexdb.MetaMatch, isSell bool) error) (int, error)
DeleteInactiveMatches deletes matches that are no longer needed for normal operations. Optionally accepts a time to delete matches with a later time stamp. Accepts an optional function to perform on deleted matches.
func (*BoltDB) DeleteInactiveOrders ¶ added in v0.5.0
func (db *BoltDB) DeleteInactiveOrders(ctx context.Context, olderThan *time.Time, perOrderFn func(ords *dexdb.MetaOrder) error) (int, error)
DeleteInactiveOrders deletes orders that are no longer needed for normal operations. Optionally accepts a time to delete orders with a later time stamp. Accepts an optional function to perform on deleted orders.
func (*BoltDB) DisabledRateSources ¶ added in v0.5.0
DisabledRateSources retrieves a map of disabled fiat rate sources.
func (*BoltDB) Language ¶ added in v1.0.0
Language retrieves the language stored with SetLanguage. If no language has been stored, an empty string is returned without an error.
func (*BoltDB) ListAccounts ¶
ListAccounts returns a list of DEX URLs. The DB is designed to have a single account per DEX, so the account itself is identified by the DEX URL.
func (*BoltDB) LoadPokes ¶ added in v1.0.0
func (db *BoltDB) LoadPokes() (pokes []*dexdb.Notification, _ error)
LoadPokes loads the slice of notifications last saved with SavePokes. The loaded pokes are deleted from the database.
func (*BoltDB) MarketOrders ¶
func (db *BoltDB) MarketOrders(dex string, base, quote uint32, n int, since uint64) ([]*dexdb.MetaOrder, error)
MarketOrders retrieves all orders for the specified DEX and market. n = 0 applies no limit on number of orders returned. since = 0 is equivalent to disabling the time filter, since no orders were created before 1970.
func (*BoltDB) MatchesForOrder ¶
func (db *BoltDB) MatchesForOrder(oid order.OrderID, excludeCancels bool) ([]*dexdb.MetaMatch, error)
MatchesForOrder retrieves the matches for the specified order ID.
func (*BoltDB) NextBondKeyIndex ¶ added in v0.6.0
NextBondKeyIndex returns the next bond key index and increments the stored value so that subsequent calls will always return a higher index.
func (*BoltDB) NotificationsN ¶
func (db *BoltDB) NotificationsN(n int) ([]*dexdb.Notification, error)
NotificationsN reads out the N most recent notifications.
func (*BoltDB) Orders ¶
Orders fetches a slice of orders, sorted by descending time, and filtered with the provided OrderFilter. Orders does not return cancel orders.
func (*BoltDB) PrimaryCredentials ¶ added in v0.4.0
func (db *BoltDB) PrimaryCredentials() (creds *dexdb.PrimaryCredentials, err error)
PrimaryCredentials retrieves the *PrimaryCredentials, if they are stored. It is an error if none have been stored.
func (*BoltDB) Recrypt ¶ added in v0.4.0
func (db *BoltDB) Recrypt(creds *dexdb.PrimaryCredentials, oldCrypter, newCrypter encrypt.Crypter) (walletUpdates map[uint32][]byte, acctUpdates map[string][]byte, err error)
Recrypt re-encrypts the wallet passwords and account private keys. As a convenience, the provided *PrimaryCredentials are stored under the same transaction.
func (*BoltDB) SaveDisabledRateSources ¶ added in v0.5.0
SaveDisabledRateSources updates disabled fiat rate sources.
func (*BoltDB) SaveNotification ¶
func (db *BoltDB) SaveNotification(note *dexdb.Notification) error
SaveNotification saves the notification.
func (*BoltDB) SavePokes ¶ added in v1.0.0
func (db *BoltDB) SavePokes(pokes []*dexdb.Notification) error
SavePokes saves a slice of notifications, overwriting any previously saved slice.
func (*BoltDB) SeedGenerationTime ¶ added in v0.5.0
SeedGenerationTime returns the time the app seed was generated, if it was stored. It returns dexdb.ErrNoSeedGenTime if it was not stored.
func (*BoltDB) SetLanguage ¶ added in v1.0.0
SetLanguage stores the language.
func (*BoltDB) SetPrimaryCredentials ¶ added in v0.4.0
func (db *BoltDB) SetPrimaryCredentials(creds *dexdb.PrimaryCredentials) error
SetPrimaryCredentials validates and stores the PrimaryCredentials.
func (*BoltDB) SetSeedGenerationTime ¶ added in v0.5.0
SetSeedGenerationTime stores the time the app seed was generated.
func (*BoltDB) SetWalletPassword ¶
SetWalletPassword set the encrypted password field for the wallet.
func (*BoltDB) ToggleAccountStatus ¶ added in v1.0.1
ToggleAccountStatus enables or disables the account associated with the given host.
func (*BoltDB) UpdateAccountInfo ¶ added in v0.5.0
func (db *BoltDB) UpdateAccountInfo(ai *dexdb.AccountInfo) error
UpdateAccountInfo updates the account info for an existing account with the same Host as the parameter. If no account exists with this host, an error is returned.
func (*BoltDB) UpdateBalance ¶
UpdateBalance updates balance in the wallet bucket.
func (*BoltDB) UpdateMatch ¶
UpdateMatch updates the match information in the database. Any existing entry for the same match ID will be overwritten without indication.
func (*BoltDB) UpdateOrder ¶
UpdateOrder saves the order information in the database. Any existing order info for the same order ID will be overwritten without indication.
func (*BoltDB) UpdateOrderMetaData ¶
UpdateOrderMetaData updates the order metadata, not including the Host.
func (*BoltDB) UpdateOrderStatus ¶
UpdateOrderStatus sets the order status for an order.
func (*BoltDB) UpdateWallet ¶
UpdateWallet adds a wallet to the database.
func (*BoltDB) UpdateWalletStatus ¶ added in v0.6.0
UpdateWalletStatus updates a wallet's status.