mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
This commit adds a new bucket to save liquidity parameters. We've skipped the serialization and deserialization implementations here and leave them to be handled by the liquidity package.
54 lines
1.8 KiB
Go
54 lines
1.8 KiB
Go
package loopdb
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/lightningnetwork/lnd/lntypes"
|
|
)
|
|
|
|
// SwapStore is the primary database interface used by the loopd system. It
|
|
// houses information for all pending completed/failed swaps.
|
|
type SwapStore interface {
|
|
// FetchLoopOutSwaps returns all swaps currently in the store.
|
|
FetchLoopOutSwaps() ([]*LoopOut, error)
|
|
|
|
// CreateLoopOut adds an initiated swap to the store.
|
|
CreateLoopOut(hash lntypes.Hash, swap *LoopOutContract) error
|
|
|
|
// UpdateLoopOut stores a new event for a target loop out swap. This
|
|
// appends to the event log for a particular swap as it goes through
|
|
// the various stages in its lifetime.
|
|
UpdateLoopOut(hash lntypes.Hash, time time.Time,
|
|
state SwapStateData) error
|
|
|
|
// FetchLoopInSwaps returns all swaps currently in the store.
|
|
FetchLoopInSwaps() ([]*LoopIn, error)
|
|
|
|
// CreateLoopIn adds an initiated swap to the store.
|
|
CreateLoopIn(hash lntypes.Hash, swap *LoopInContract) error
|
|
|
|
// UpdateLoopIn stores a new event for a target loop in swap. This
|
|
// appends to the event log for a particular swap as it goes through
|
|
// the various stages in its lifetime.
|
|
UpdateLoopIn(hash lntypes.Hash, time time.Time,
|
|
state SwapStateData) error
|
|
|
|
// PutLiquidityParams writes the serialized `manager.Parameters` bytes
|
|
// into the bucket.
|
|
//
|
|
// NOTE: it's the caller's responsibility to encode the param. Atm,
|
|
// it's encoding using the proto package's `Marshal` method.
|
|
PutLiquidityParams(params []byte) error
|
|
|
|
// FetchLiquidityParams reads the serialized `manager.Parameters` bytes
|
|
// from the bucket.
|
|
//
|
|
// NOTE: it's the caller's responsibility to decode the param. Atm,
|
|
// it's decoding using the proto package's `Unmarshal` method.
|
|
FetchLiquidityParams() ([]byte, error)
|
|
|
|
// Close closes the underlying database.
|
|
Close() error
|
|
}
|
|
|
|
// TODO(roasbeef): back up method in interface?
|