Documentation ¶
Index ¶
- Variables
- type MeshDB
- func (m *MeshDB) ClearAllMiniHeaders() error
- func (m *MeshDB) Close()
- func (m *MeshDB) CountPinnedOrders() (int, error)
- func (m *MeshDB) FindAllMiniHeadersSortedByNumber() ([]*miniheader.MiniHeader, error)
- func (m *MeshDB) FindLatestMiniHeader() (*miniheader.MiniHeader, error)
- func (m *MeshDB) FindOrdersByMakerAddress(makerAddress common.Address) ([]*Order, error)
- func (m *MeshDB) FindOrdersByMakerAddressAndMaxSalt(makerAddress common.Address, salt *big.Int) ([]*Order, error)
- func (m *MeshDB) FindOrdersByMakerAddressMakerFeeAssetAddressAndTokenID(makerAddress, makerFeeAssetAddress common.Address, tokenID *big.Int) ([]*Order, error)
- func (m *MeshDB) FindOrdersByMakerAddressTokenAddressAndTokenID(makerAddress, tokenAddress common.Address, tokenID *big.Int) ([]*Order, error)
- func (m *MeshDB) FindOrdersLastUpdatedBefore(lastUpdated time.Time) ([]*Order, error)
- func (m *MeshDB) FindRemovedOrders() ([]*Order, error)
- func (m *MeshDB) GetMetadata() (*Metadata, error)
- func (m *MeshDB) SaveMetadata(metadata *Metadata) error
- func (m *MeshDB) TrimOrdersByExpirationTime(targetMaxOrders int) (newMaxExpirationTime *big.Int, removedOrders []*Order, err error)
- func (m *MeshDB) UpdateMetadata(updater func(oldmetadata Metadata) (newMetadata Metadata)) error
- type Metadata
- type MetadataCollection
- type MiniHeadersCollection
- type Order
- type OrdersCollection
Constants ¶
This section is empty.
Variables ¶
var ErrDBFilledWithPinnedOrders = errors.New("the database is full of pinned orders; no orders can be removed in order to make space")
Functions ¶
This section is empty.
Types ¶
type MeshDB ¶
type MeshDB struct { MiniHeaders *MiniHeadersCollection Orders *OrdersCollection // contains filtered or unexported fields }
MeshDB instantiates the DB connection and creates all the collections used by the application
func (*MeshDB) ClearAllMiniHeaders ¶
ClearAllMiniHeaders removes all stored MiniHeaders from the database.
func (*MeshDB) CountPinnedOrders ¶
CountPinnedOrders returns the number of pinned orders.
func (*MeshDB) FindAllMiniHeadersSortedByNumber ¶
func (m *MeshDB) FindAllMiniHeadersSortedByNumber() ([]*miniheader.MiniHeader, error)
FindAllMiniHeadersSortedByNumber returns all MiniHeaders sorted by block number
func (*MeshDB) FindLatestMiniHeader ¶
func (m *MeshDB) FindLatestMiniHeader() (*miniheader.MiniHeader, error)
FindLatestMiniHeader returns the latest MiniHeader (i.e. the one with the largest block number), or nil if there are none in the database.
func (*MeshDB) FindOrdersByMakerAddress ¶
FindOrdersByMakerAddress finds all orders belonging to a particular maker address
func (*MeshDB) FindOrdersByMakerAddressAndMaxSalt ¶
func (m *MeshDB) FindOrdersByMakerAddressAndMaxSalt(makerAddress common.Address, salt *big.Int) ([]*Order, error)
FindOrdersByMakerAddressAndMaxSalt finds all orders belonging to a particular maker address that also have a salt value less then or equal to X
func (*MeshDB) FindOrdersByMakerAddressMakerFeeAssetAddressAndTokenID ¶
func (m *MeshDB) FindOrdersByMakerAddressMakerFeeAssetAddressAndTokenID(makerAddress, makerFeeAssetAddress common.Address, tokenID *big.Int) ([]*Order, error)
FindOrdersByMakerAddressMakerFeeAssetAddressTokenID finds all orders belonging to a particular maker address where makerFeeAssetData encodes for a particular token contract and optionally a token ID. To find orders without a maker fee, use constants.NullAddress for makerFeeAssetAddress.
func (*MeshDB) FindOrdersByMakerAddressTokenAddressAndTokenID ¶
func (m *MeshDB) FindOrdersByMakerAddressTokenAddressAndTokenID(makerAddress, tokenAddress common.Address, tokenID *big.Int) ([]*Order, error)
FindOrdersByMakerAddressTokenAddressAndTokenID finds all orders belonging to a particular maker address where makerAssetData encodes for a particular token contract and optionally a token ID
func (*MeshDB) FindOrdersLastUpdatedBefore ¶
FindOrdersLastUpdatedBefore finds all orders where the LastUpdated time is less than X
func (*MeshDB) FindRemovedOrders ¶
FindRemovedOrders finds all orders that have been flagged for removal
func (*MeshDB) GetMetadata ¶
GetMetadata returns the metadata (or a db.NotFoundError if no metadata has been found).
func (*MeshDB) SaveMetadata ¶
SaveMetadata inserts the metadata into the database, overwriting any existing metadata.
func (*MeshDB) TrimOrdersByExpirationTime ¶
func (m *MeshDB) TrimOrdersByExpirationTime(targetMaxOrders int) (newMaxExpirationTime *big.Int, removedOrders []*Order, err error)
TrimOrdersByExpirationTime removes existing orders with the highest expiration time until the number of remaining orders is <= targetMaxOrders. It returns any orders that were removed and the new max expiration time that can be used to eliminate incoming orders that expire too far in the future.
func (*MeshDB) UpdateMetadata ¶
UpdateMetadata updates the metadata in the database via a transaction. It accepts a callback function which will be provided with the old metadata and should return the new metadata to save.
type Metadata ¶
type Metadata struct { EthereumChainID int MaxExpirationTime *big.Int EthRPCRequestsSentInCurrentUTCDay int StartOfCurrentUTCDay time.Time }
Metadata is the database representation of MeshDB instance metadata
type MetadataCollection ¶
type MetadataCollection struct {
*db.Collection
}
MetadataCollection represents a DB collection used to store instance metadata
type MiniHeadersCollection ¶
type MiniHeadersCollection struct { *db.Collection // contains filtered or unexported fields }
MiniHeadersCollection represents a DB collection of mini Ethereum block headers
type Order ¶
type Order struct { Hash common.Hash SignedOrder *zeroex.SignedOrder // When was this order last validated LastUpdated time.Time // How much of this order can still be filled FillableTakerAssetAmount *big.Int // Was this order flagged for removal? Due to the possibility of block-reorgs, instead // of immediately removing an order when FillableTakerAssetAmount becomes 0, we instead // flag it for removal. After this order isn't updated for X time and has IsRemoved = true, // the order can be permanently deleted. IsRemoved bool // IsPinned indicates whether or not the order is pinned. Pinned orders are // not removed from the database unless they become unfillable. IsPinned bool }
Order is the database representation a 0x order along with some relevant metadata
type OrdersCollection ¶
type OrdersCollection struct { *db.Collection MakerAddressAndSaltIndex *db.Index MakerAddressTokenAddressTokenIDIndex *db.Index MakerAddressMakerFeeAssetAddressTokenIDIndex *db.Index MakerAssetDataIndex *db.Index LastUpdatedIndex *db.Index IsRemovedIndex *db.Index ExpirationTimeIndex *db.Index }
OrdersCollection represents a DB collection of 0x orders