Skip to content

Commit

Permalink
Merge pull request #180 from shutter-network/feat/prioritize-inclusion
Browse files Browse the repository at this point in the history
fix erpc query
  • Loading branch information
faheelsattar authored Oct 22, 2024
2 parents d5a22ab + fb34c08 commit 630545d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
26 changes: 19 additions & 7 deletions backend/internal/data/shutter_explorer.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions backend/internal/data/sql/queries/shutter_explorer.sql
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,11 @@ SELECT tx_hash, EXTRACT(EPOCH FROM created_at)::BIGINT AS included_timestamp
FROM decrypted_tx
WHERE slot = $1 AND tx_status = 'shielded inclusion';

-- name: QueryFromTransactionDetails :one
-- name: QueryFromTransactionDetails :many
SELECT tx_hash as user_tx_hash, encrypted_tx_hash
FROM transaction_details
WHERE tx_hash = $1 OR encrypted_tx_hash = $1
ORDER BY submission_time DESC
LIMIT 1;
ORDER BY submission_time DESC;

-- name: QueryTransactionDetailsByTxHash :one
WITH prioritized_tx AS (
Expand Down
12 changes: 9 additions & 3 deletions backend/internal/usecase/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,13 @@ func (uc *TransactionUsecase) QueryTransactionDetailsByTxHash(ctx context.Contex
return nil, &err
}
} else {
txHashBytes = common.HexToHash(erpcTX.EncryptedTxHash).Bytes()
if len(erpcTX) > 0 {
if txHash == erpcTX[0].EncryptedTxHash {
txHashBytes = common.HexToHash(erpcTX[0].EncryptedTxHash).Bytes()
} else {
txHashBytes = common.HexToHash(erpcTX[0].UserTxHash).Bytes()
}
}
}

tse, err := uc.observerDBQuery.QueryTransactionDetailsByTxHash(ctx, txHashBytes)
Expand Down Expand Up @@ -291,8 +297,8 @@ func (uc *TransactionUsecase) QueryTransactionDetailsByTxHash(ctx context.Contex
if len(tse.UserTxHash) > 0 {
userTxHash = "0x" + hex.EncodeToString(tse.UserTxHash)
} else {
if erpcTxErr == nil {
userTxHash = erpcTX.UserTxHash
if len(erpcTX) > 0 {
userTxHash = erpcTX[0].UserTxHash
}
}

Expand Down

0 comments on commit 630545d

Please sign in to comment.