Skip to content

Commit 5895796

Browse files
committed
Fix bp_getTransactionList bug
1 parent 556c53f commit 5895796

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

api/models/transactions.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ type Transaction struct {
1818
TxIndex int `db:"tx_index" json:"index"` // pk2
1919
Hash string `db:"hash" json:"hash"`
2020
BlockHash string `db:"block_hash" json:"block_hash"`
21-
Timestamp int64 `db:"timestamp" json:"-"`
22-
TimestampHuman time.Time `db:"-" json:"timestamp"`
21+
Timestamp int64 `db:"timestamp" json:"timestamp"`
22+
TimestampHuman time.Time `db:"-" json:"timestamp_human"`
2323
TxType int `db:"tx_type" json:"type"`
2424
Address string `db:"address" json:"address"`
2525
Raw string `db:"raw" json:"raw"`
@@ -64,10 +64,10 @@ func (m *TransactionsModel) GetTransactionList(since, direction string, limit in
6464
query := fmt.Sprintf(`SELECT block_height, tx_index, hash, block_hash,
6565
timestamp, tx_type, address, raw
6666
FROM indexed_transactions
67-
WHERE block_height %s ? and tx_index %s ?
67+
WHERE block_height %s ? or (block_height = ? and tx_index %s ?)
6868
ORDER BY block_height %s, tx_index %s
6969
LIMIT ?`, compare, compare, orderBy, orderBy)
7070

71-
_, err = chaindb.Select(&txs, query, tx.BlockHeight, tx.TxIndex, limit)
71+
_, err = chaindb.Select(&txs, query, tx.BlockHeight, tx.BlockHeight, tx.TxIndex, limit)
7272
return txs, err
7373
}

api/transactions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ type bpGetTransactionByHashParams struct {
4545
func bpGetTransactionByHash(ctx context.Context, conn *jsonrpc2.Conn, req *jsonrpc2.Request) (
4646
result interface{}, err error,
4747
) {
48-
params := ctx.Value("_params").(*bpGetBlockByHashParams)
48+
params := ctx.Value("_params").(*bpGetTransactionByHashParams)
4949
model := models.TransactionsModel{}
5050
return model.GetTransactionByHash(params.Hash)
5151
}

0 commit comments

Comments
 (0)