Documentation

Index

Constants

View Source
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

    func NewDB

    func NewDB(dbPath string, logger dex.Logger) (dexdb.DB, error)

      NewDB is a constructor for a *BoltDB.

      Types

      type BoltDB

      type BoltDB struct {
      	*bbolt.DB
      	// contains filtered or unexported fields
      }

        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

          func (db *BoltDB) AccountOrders(dex string, n int, since uint64) ([]*dexdb.MetaOrder, error)

            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 before 1970.

            func (*BoltDB) AccountPaid

            func (db *BoltDB) AccountPaid(proof *dexdb.AccountProof) error

              AccountPaid marks the account as paid by setting the "fee proof".

              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 URL.

                func (*BoltDB) AckNotification

                func (db *BoltDB) AckNotification(id []byte) error

                  AckNotification sets the acknowledgement for a notification.

                  func (*BoltDB) ActiveDEXOrders

                  func (db *BoltDB) ActiveDEXOrders(dex string) ([]*dexdb.MetaOrder, error)

                    ActiveDEXOrders retrieves all orders for the specified DEX.

                    func (*BoltDB) ActiveMatches

                    func (db *BoltDB) ActiveMatches() ([]*dexdb.MetaMatch, error)

                      ActiveMatches retrieves the matches that are in an active state, which is any state except order.MatchComplete.

                      func (*BoltDB) ActiveOrders

                      func (db *BoltDB) ActiveOrders() ([]*dexdb.MetaOrder, error)

                        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) Backup

                        func (db *BoltDB) Backup() error

                          Backup makes a copy of the database.

                          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

                            func (db *BoltDB) DEXOrdersWithActiveMatches(dex string) ([]order.OrderID, error)

                              DEXOrdersWithActiveMatches retrieves order IDs for any order that has active matches, regardless of whether the order itself is in an active state.

                              func (*BoltDB) DisableAccount

                              func (db *BoltDB) DisableAccount(ai *dexdb.AccountInfo) error

                                DisableAccount account disables the given account 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) Get

                                func (db *BoltDB) Get(k string) ([]byte, error)

                                  Get retrieves value previously stored with Store.

                                  func (*BoltDB) LinkOrder

                                  func (db *BoltDB) LinkOrder(oid, linkedID order.OrderID) error

                                    LinkOrder sets the linked order.

                                    func (*BoltDB) ListAccounts

                                    func (db *BoltDB) ListAccounts() ([]string, error)

                                      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 before 1970.

                                        func (*BoltDB) MatchesForOrder

                                        func (db *BoltDB) MatchesForOrder(oid order.OrderID) ([]*dexdb.MetaMatch, error)

                                          MatchesForOrder retrieves the matches for the specified order ID.

                                          func (*BoltDB) NotificationsN

                                          func (db *BoltDB) NotificationsN(n int) ([]*dexdb.Notification, error)

                                            NotificationsN reads out the N most recent notifications.

                                            func (*BoltDB) Order

                                            func (db *BoltDB) Order(oid order.OrderID) (mord *dexdb.MetaOrder, err error)

                                              Order fetches a MetaOrder by order ID.

                                              func (*BoltDB) Orders

                                              func (db *BoltDB) Orders(orderFilter *db.OrderFilter) (ords []*dexdb.MetaOrder, err error)

                                                Orders fetches a slice of orders, sorted by descending time, and filtered with the provided OrderFilter. Orders does not return cancel orders.

                                                func (*BoltDB) Run

                                                func (db *BoltDB) Run(ctx context.Context)

                                                  Run waits for context cancellation and closes the database.

                                                  func (*BoltDB) SaveNotification

                                                  func (db *BoltDB) SaveNotification(note *dexdb.Notification) error

                                                    SaveNotification saves the notification.

                                                    func (*BoltDB) SetWalletPassword

                                                    func (db *BoltDB) SetWalletPassword(wid []byte, newPW []byte) error

                                                      SetWalletPassword set the encrypted password field for the wallet.

                                                      func (*BoltDB) Store

                                                      func (db *BoltDB) Store(k string, v []byte) error

                                                        Store stores a value at the specified key in the general-use bucket.

                                                        func (*BoltDB) UpdateBalance

                                                        func (db *BoltDB) UpdateBalance(wid []byte, bal *db.Balance) error

                                                          UpdateBalance updates balance in the wallet bucket.

                                                          func (*BoltDB) UpdateMatch

                                                          func (db *BoltDB) UpdateMatch(m *dexdb.MetaMatch) error

                                                            UpdateMatch updates the match information in the database. Any existing entry for the same match ID will be overwritten without indication.

                                                            func (*BoltDB) UpdateOrder

                                                            func (db *BoltDB) UpdateOrder(m *dexdb.MetaOrder) error

                                                              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

                                                              func (db *BoltDB) UpdateOrderMetaData(oid order.OrderID, md *db.OrderMetaData) error

                                                                UpdateOrderMetaData updates the order metadata, not including the Host.

                                                                func (*BoltDB) UpdateOrderStatus

                                                                func (db *BoltDB) UpdateOrderStatus(oid order.OrderID, status order.OrderStatus) error

                                                                  UpdateOrderStatus sets the order status for an order.

                                                                  func (*BoltDB) UpdateWallet

                                                                  func (db *BoltDB) UpdateWallet(wallet *dexdb.Wallet) error

                                                                    UpdateWallet adds a wallet to the database.

                                                                    func (*BoltDB) ValueExists

                                                                    func (db *BoltDB) ValueExists(k string) (bool, error)

                                                                      ValueExists checks if a value was previously stored in the general-use bucket at the specified key.

                                                                      func (*BoltDB) Wallet

                                                                      func (db *BoltDB) Wallet(wid []byte) (wallet *dexdb.Wallet, err error)

                                                                        Wallet loads all wallet from the database.

                                                                        func (*BoltDB) Wallets

                                                                        func (db *BoltDB) Wallets() ([]*dexdb.Wallet, error)

                                                                          Wallets loads all wallets from the database.

                                                                          Source Files