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) AccountProof(url string) (*dexdb.AccountProof, error)
- func (db *BoltDB) Accounts() ([]*dexdb.AccountInfo, error)
- func (db *BoltDB) AckNotification(id []byte) error
- func (db *BoltDB) ActiveBotPrograms() (pgms map[uint64]*dexdb.BotProgram, err 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) DisableAccount(url string) error
- func (db *BoltDB) DisabledRateSources() (disabledSources []string, err error)
- func (db *BoltDB) LinkOrder(oid, linkedID order.OrderID) error
- func (db *BoltDB) ListAccounts() ([]string, 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) RetireBotProgram(pgmID uint64) error
- func (db *BoltDB) Run(ctx context.Context)
- func (db *BoltDB) SaveBotProgram(pgm *dexdb.BotProgram) (pgmID uint64, err error)
- func (db *BoltDB) SaveDisabledRateSources(disabledSources []string) error
- func (db *BoltDB) SaveNotification(note *dexdb.Notification) error
- func (db *BoltDB) SeedGenerationTime() (uint64, 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) StoreAccountProof(proof *dexdb.AccountProof) error
- func (db *BoltDB) UpdateAccountInfo(ai *dexdb.AccountInfo) error
- func (db *BoltDB) UpdateBalance(wid []byte, bal *dexdb.Balance) error
- func (db *BoltDB) UpdateBotProgram(pgmID uint64, pgm *dexdb.BotProgram) 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 a DEX client. 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) AccountProof ¶ added in v0.2.0
func (db *BoltDB) AccountProof(url string) (*dexdb.AccountProof, error)
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) ActiveBotPrograms ¶ added in v0.6.0
func (db *BoltDB) ActiveBotPrograms() (pgms map[uint64]*dexdb.BotProgram, err error)
ActiveBotPrograms loads a list of active bot program IDs.
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) DisableAccount ¶
DisableAccount disables the account associated with the given host and archives it. The Accounts and Account methods will no longer find the disabled account.
TODO: Add disabledAccounts method for retrieval of a disabled account and possible recovery of the account data.
func (*BoltDB) DisabledRateSources ¶ added in v0.5.0
DisabledRateSources retrieves a map of disabled fiat rate sources.
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) 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) RetireBotProgram ¶ added in v0.6.0
RetireBotProgram deletes the bot program from the database.
func (*BoltDB) SaveBotProgram ¶ added in v0.6.0
func (db *BoltDB) SaveBotProgram(pgm *dexdb.BotProgram) (pgmID uint64, err error)
SaveBotProgram saves data associated with a bot program. A unique ID is returned that can be used to address this program in future queries.
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) 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) 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) StoreAccountProof ¶ added in v0.6.0
func (db *BoltDB) StoreAccountProof(proof *dexdb.AccountProof) error
StoreAccountProof marks the account as paid with the legacy registration fee by setting the "fee proof".
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) UpdateBotProgram ¶ added in v0.6.0
func (db *BoltDB) UpdateBotProgram(pgmID uint64, pgm *dexdb.BotProgram) error
UpdateBotProgram updates the data associated with a running bot program.
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.