Documentation ¶
Overview ¶
Package db implements the APIs for interacting with our disk persisted key-value store.
Index ¶
- type Database
- func (db *Database) ClearAllOffers() error
- func (db *Database) Close() error
- func (db *Database) DeleteOffer(id types.Hash) error
- func (db *Database) GetAllOffers() ([]*types.Offer, error)
- func (db *Database) GetAllSwaps() ([]*swap.Info, error)
- func (db *Database) GetOffer(id types.Hash) (*types.Offer, error)
- func (db *Database) GetSwap(id types.Hash) (*swap.Info, error)
- func (db *Database) HasSwap(id types.Hash) (bool, error)
- func (db *Database) PutOffer(offer *types.Offer) error
- func (db *Database) PutSwap(s *swap.Info) error
- func (db *Database) RecoveryDB() *RecoveryDB
- type EthereumSwapInfo
- type RecoveryDB
- func (db *RecoveryDB) DeleteSwap(_ types.Hash) error
- func (db *RecoveryDB) GetContractSwapInfo(id types.Hash) (*EthereumSwapInfo, error)
- func (db *RecoveryDB) GetCounterpartySwapKeys(id types.Hash) (*mcrypto.PublicKey, *mcrypto.PrivateViewKey, error)
- func (db *RecoveryDB) GetCounterpartySwapPrivateKey(id types.Hash) (*mcrypto.PrivateSpendKey, error)
- func (db *RecoveryDB) GetNewSwapTxHash(id types.Hash) (types.Hash, error)
- func (db *RecoveryDB) GetSwapPrivateKey(id types.Hash) (*mcrypto.PrivateSpendKey, error)
- func (db *RecoveryDB) GetSwapRelayerInfo(id types.Hash) (*types.OfferExtra, error)
- func (db *RecoveryDB) PutContractSwapInfo(id types.Hash, info *EthereumSwapInfo) error
- func (db *RecoveryDB) PutCounterpartySwapKeys(id types.Hash, sk *mcrypto.PublicKey, vk *mcrypto.PrivateViewKey) error
- func (db *RecoveryDB) PutCounterpartySwapPrivateKey(id types.Hash, kp *mcrypto.PrivateSpendKey) error
- func (db *RecoveryDB) PutNewSwapTxHash(id types.Hash, txHash types.Hash) error
- func (db *RecoveryDB) PutSwapPrivateKey(id types.Hash, sk *mcrypto.PrivateSpendKey) error
- func (db *RecoveryDB) PutSwapRelayerInfo(id types.Hash, info *types.OfferExtra) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database is the persistent datastore used by swapd.
func NewDatabase ¶
NewDatabase returns a new *Database.
func (*Database) ClearAllOffers ¶
ClearAllOffers clears all offers from the database.
func (*Database) DeleteOffer ¶
DeleteOffer deletes an offer from the database.
func (*Database) GetAllOffers ¶
GetAllOffers returns all offers in the database.
func (*Database) GetAllSwaps ¶
GetAllSwaps returns all swaps in the database.
func (*Database) GetOffer ¶
GetOffer returns the given offer from the db, if it exists. Returns the error chaindb.ErrKeyNotFound if the entry does not exist.
func (*Database) GetSwap ¶
GetSwap returns a swap with the given ID, if it exists. Returns the error chaindb.ErrKeyNotFound if the entry does not exist.
type EthereumSwapInfo ¶
type EthereumSwapInfo struct { // StartNumber the block number of the `newSwap` transaction. The same for // both maker/taker. StartNumber *big.Int `json:"startNumber" validate:"required"` // SwapID is the swap ID used by the swap contract; not the same as the // swap/offer ID used by swapd. It's the hash of the ABI encoded // `contracts.SwapCreatorSwap` struct. SwapID types.Hash `json:"swapID" validate:"required"` // Swap is the `Swap` structure inside SwapCreator.sol. Swap *contracts.SwapCreatorSwap `json:"swap" validate:"required"` // SwapCreatorAddr is the address of the contract on which the swap was created. SwapCreatorAddr ethcommon.Address `json:"swapCreatorAddr" validate:"required"` }
EthereumSwapInfo represents information required on the Ethereum side in case of recovery
type RecoveryDB ¶
type RecoveryDB struct {
// contains filtered or unexported fields
}
RecoveryDB contains information about ongoing swaps required for recovery in case of shutdown.
func (*RecoveryDB) DeleteSwap ¶
func (db *RecoveryDB) DeleteSwap(_ types.Hash) error
DeleteSwap deletes all recovery info from the db for the given swap. TODO: this is currently unimplemented
func (*RecoveryDB) GetContractSwapInfo ¶
func (db *RecoveryDB) GetContractSwapInfo(id types.Hash) (*EthereumSwapInfo, error)
GetContractSwapInfo returns the contract swap ID (a hash of the `SwapCreatorSwap` structure) and and contract swap structure for the given swap ID.
func (*RecoveryDB) GetCounterpartySwapKeys ¶
func (db *RecoveryDB) GetCounterpartySwapKeys(id types.Hash) (*mcrypto.PublicKey, *mcrypto.PrivateViewKey, error)
GetCounterpartySwapKeys is called during recovery to retrieve the counterparty's swap keys.
func (*RecoveryDB) GetCounterpartySwapPrivateKey ¶
func (db *RecoveryDB) GetCounterpartySwapPrivateKey(id types.Hash) (*mcrypto.PrivateSpendKey, error)
GetCounterpartySwapPrivateKey returns the counterparty's swap private key, if it exists.
func (*RecoveryDB) GetNewSwapTxHash ¶ added in v0.3.0
GetNewSwapTxHash returns the newSwap transaction hash for the given swap ID.
func (*RecoveryDB) GetSwapPrivateKey ¶
func (db *RecoveryDB) GetSwapPrivateKey(id types.Hash) (*mcrypto.PrivateSpendKey, error)
GetSwapPrivateKey returns the swap private key share, if it exists.
func (*RecoveryDB) GetSwapRelayerInfo ¶
func (db *RecoveryDB) GetSwapRelayerInfo(id types.Hash) (*types.OfferExtra, error)
GetSwapRelayerInfo ...
func (*RecoveryDB) PutContractSwapInfo ¶
func (db *RecoveryDB) PutContractSwapInfo(id types.Hash, info *EthereumSwapInfo) error
PutContractSwapInfo stores the given contract swap ID (which is not the same as the daemon swap ID, but is instead a hash of the `SwapCreatorSwap` structure) and contract swap structure for the given swap ID.
func (*RecoveryDB) PutCounterpartySwapKeys ¶
func (db *RecoveryDB) PutCounterpartySwapKeys(id types.Hash, sk *mcrypto.PublicKey, vk *mcrypto.PrivateViewKey) error
PutCounterpartySwapKeys is used to store the counterparty's swap keys.
func (*RecoveryDB) PutCounterpartySwapPrivateKey ¶
func (db *RecoveryDB) PutCounterpartySwapPrivateKey(id types.Hash, kp *mcrypto.PrivateSpendKey) error
PutCounterpartySwapPrivateKey stores the counterparty's swap private key for the given swap ID.
func (*RecoveryDB) PutNewSwapTxHash ¶ added in v0.3.0
PutNewSwapTxHash stores the newSwap transaction hash for the given swap ID.
func (*RecoveryDB) PutSwapPrivateKey ¶
func (db *RecoveryDB) PutSwapPrivateKey(id types.Hash, sk *mcrypto.PrivateSpendKey) error
PutSwapPrivateKey stores the given ephemeral swap private key share for the given swap ID.
func (*RecoveryDB) PutSwapRelayerInfo ¶
func (db *RecoveryDB) PutSwapRelayerInfo(id types.Hash, info *types.OfferExtra) error
PutSwapRelayerInfo ...