Skip to content

Commit

Permalink
Batch transactions query accepts full or short hash (#1897)
Browse files Browse the repository at this point in the history
* trunc the hash and query by the short version
  • Loading branch information
badgersrus authored May 8, 2024
1 parent d93acb0 commit 73710d5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions go/host/storage/hostdb/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ func GetBatchByHeight(db HostDB, height *big.Int) (*common.PublicBatch, error) {

// GetBatchTransactions returns the TransactionListingResponse for a given batch hash
func GetBatchTransactions(db HostDB, batchHash gethcommon.Hash) (*common.TransactionListingResponse, error) {
whereQuery := " WHERE b.full_hash=" + db.GetSQLStatement().Placeholder
return fetchBatchTxs(db.GetSQLDB(), whereQuery, batchHash)
whereQuery := " WHERE b.hash=" + db.GetSQLStatement().Placeholder
return fetchBatchTxs(db.GetSQLDB(), whereQuery, truncTo16(batchHash))
}

func fetchBatchHeader(db *sql.DB, whereQuery string, args ...any) (*common.BatchHeader, error) {
Expand Down Expand Up @@ -490,7 +490,7 @@ func fetchTx(db HostDB, seqNo uint64) ([]common.TxHash, error) {
return transactions, nil
}

func fetchBatchTxs(db *sql.DB, whereQuery string, batchHash gethcommon.Hash) (*common.TransactionListingResponse, error) {
func fetchBatchTxs(db *sql.DB, whereQuery string, batchHash []byte) (*common.TransactionListingResponse, error) {
query := selectBatchTxs + whereQuery
rows, err := db.Query(query, batchHash)
if err != nil {
Expand Down

0 comments on commit 73710d5

Please sign in to comment.