Skip to content

Commit 08af407

Browse files
authored
Merge pull request #38 from LATOKEN/feature-full-swap-status
Feature full swap status
2 parents b71fa66 + b4da118 commit 08af407

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

src/service/storage/swap.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,19 @@ func (d *DataBase) GetSwapBySwapID(swapID string) []*Swap {
3535
// GetSwapByStatus ...
3636
func (d *DataBase) GetSwapByStatus(swapType SwapType, sender, receipt string, amount string, txHash string) (*Swap, error) {
3737
swap := &Swap{}
38-
if err := d.db.Where("type = ? and sender_addr = ? and receiver_addr = ? and out_amount = ? and tx_hash = ? and status in (?)",
39-
swapType, sender, receipt, amount, txHash,
40-
[]SwapStatus{SwapStatusDepositConfirmed, SwapStatusClaimSent, SwapStatusClaimConfirmed, SwapStatusClaimSentFailed, SwapStatusDepositFailed, SwapStatusPassedConfirmed, SwapStatusPassedSent, SwapStatusSpendSent, SwapStatusSpendConfirmed, SwapStatusRejected}).
38+
if err := d.db.Where("type = ? and sender_addr = ? and receiver_addr = ? and out_amount = ? and tx_hash = ?",
39+
swapType, sender, receipt, amount, txHash).
40+
Find(&swap).Error; err != nil {
41+
return nil, err
42+
}
43+
44+
return swap, nil
45+
}
46+
47+
// GetSwapByTxHash ...
48+
func (d *DataBase) GetSwapByTxHash(txHash string) (*Swap, error) {
49+
swap := &Swap{}
50+
if err := d.db.Where("tx_hash = ?", txHash).
4151
Find(&swap).Error; err != nil {
4252
return nil, err
4353
}

0 commit comments

Comments
 (0)