mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
staticaddr/sql_store: Add fetching loop in by hash
This commit is contained in:
parent
216aebbbbf
commit
409b2e9929
2 changed files with 28 additions and 0 deletions
|
|
@ -64,6 +64,10 @@ type StaticAddressLoopInStore interface {
|
|||
|
||||
// IsStored checks if the loop-in is already stored in the database.
|
||||
IsStored(ctx context.Context, swapHash lntypes.Hash) (bool, error)
|
||||
|
||||
// GetLoopInByHash returns the loop-in swap with the given hash.
|
||||
GetLoopInByHash(ctx context.Context, swapHash lntypes.Hash) (
|
||||
*StaticAddressLoopIn, error)
|
||||
}
|
||||
|
||||
type QuoteGetter interface {
|
||||
|
|
|
|||
|
|
@ -100,6 +100,30 @@ func NewSqlStore(db BaseDB, clock clock.Clock,
|
|||
}
|
||||
}
|
||||
|
||||
// GetLoopInByHash returns the loop-in swap with the given hash.
|
||||
func (s *SqlStore) GetLoopInByHash(ctx context.Context,
|
||||
swapHash lntypes.Hash) (*StaticAddressLoopIn, error) {
|
||||
|
||||
var (
|
||||
err error
|
||||
row sqlc.GetStaticAddressLoopInSwapRow
|
||||
updates []sqlc.StaticAddressSwapUpdate
|
||||
)
|
||||
row, err = s.baseDB.GetStaticAddressLoopInSwap(ctx, swapHash[:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
updates, err = s.baseDB.GetLoopInSwapUpdates(ctx, swapHash[:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return toStaticAddressLoopIn(
|
||||
ctx, s.network, row, updates,
|
||||
)
|
||||
}
|
||||
|
||||
// GetStaticAddressLoopInSwapsByStates returns all static address loop-ins from
|
||||
// the db that are in the given states.
|
||||
func (s *SqlStore) GetStaticAddressLoopInSwapsByStates(ctx context.Context,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue