Skip to content

Commit

Permalink
api,explorer,sqlite: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Sep 6, 2024
1 parent 175f84a commit 2a57c5c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
4 changes: 3 additions & 1 deletion api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ func (c *Client) Transactions(ids []types.TransactionID) (resp []explorer.Transa
return
}

func (c *Client) TransactionIndices(id types.TransactionID, offset, limit uint64) (resp []types.ChainIndex, err error) {
// TransactionChainIndices returns chain indices a transaction was
// included in.
func (c *Client) TransactionChainIndices(id types.TransactionID, offset, limit uint64) (resp []types.ChainIndex, err error) {
err = c.c.GET(fmt.Sprintf("/transactions/%s/indices?offset=%d&limit=%d", id, offset, limit), &resp)
return
}
Expand Down
4 changes: 2 additions & 2 deletions api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type (
BestTip(height uint64) (types.ChainIndex, error)
Metrics(id types.BlockID) (explorer.Metrics, error)
Transactions(ids []types.TransactionID) ([]explorer.Transaction, error)
TransactionIndices(id types.TransactionID, offset, limit uint64) ([]types.ChainIndex, error)
TransactionChainIndices(id types.TransactionID, offset, limit uint64) ([]types.ChainIndex, error)
Balance(address types.Address) (sc types.Currency, immatureSC types.Currency, sf uint64, err error)
SiacoinElements(ids []types.SiacoinOutputID) (result []explorer.SiacoinOutput, err error)
SiafundElements(ids []types.SiafundOutputID) (result []explorer.SiafundOutput, err error)
Expand Down Expand Up @@ -268,7 +268,7 @@ func (s *server) transactionsIDIndicesHandler(jc jape.Context) {
limit = 500
}

indices, err := s.e.TransactionIndices(id, offset, limit)
indices, err := s.e.TransactionChainIndices(id, offset, limit)
if jc.Check("failed to get transaction indices", err) != nil {
return
}
Expand Down
9 changes: 6 additions & 3 deletions explorer/explorer.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type Store interface {
MerkleProof(leafIndex uint64) ([]types.Hash256, error)
Metrics(id types.BlockID) (Metrics, error)
Transactions(ids []types.TransactionID) ([]Transaction, error)
TransactionIndices(txid types.TransactionID, offset, limit uint64) ([]types.ChainIndex, error)
TransactionChainIndices(txid types.TransactionID, offset, limit uint64) ([]types.ChainIndex, error)
UnspentSiacoinOutputs(address types.Address, offset, limit uint64) ([]SiacoinOutput, error)
UnspentSiafundOutputs(address types.Address, offset, limit uint64) ([]SiafundOutput, error)
AddressEvents(address types.Address, offset, limit uint64) (events []Event, err error)
Expand Down Expand Up @@ -147,8 +147,11 @@ func (e *Explorer) Transactions(ids []types.TransactionID) ([]Transaction, error
return e.s.Transactions(ids)
}

func (e *Explorer) TransactionIndices(id types.TransactionID, offset, limit uint64) ([]types.ChainIndex, error) {
return e.s.TransactionIndices(id, offset, limit)
// TransactionChainIndices returns the chain indices of the blocks the transaction
// was included in. If the transaction has not been included in any blocks, the
// result will be nil,nil.
func (e *Explorer) TransactionChainIndices(id types.TransactionID, offset, limit uint64) ([]types.ChainIndex, error) {
return e.s.TransactionChainIndices(id, offset, limit)
}

// UnspentSiacoinOutputs returns the unspent siacoin outputs owned by the
Expand Down
4 changes: 2 additions & 2 deletions persist/sqlite/consensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ func TestSendTransactions(t *testing.T) {
}

checkChainIndices := func(t *testing.T, txnID types.TransactionID, expected []types.ChainIndex) {
indices, err := db.TransactionIndices(txnID, 0, 100)
indices, err := db.TransactionChainIndices(txnID, 0, 100)
switch {
case err != nil:
t.Fatal(err)
Expand Down Expand Up @@ -1638,7 +1638,7 @@ func TestRevertSendTransactions(t *testing.T) {
}

checkChainIndices := func(t *testing.T, txnID types.TransactionID, expected []types.ChainIndex) {
indices, err := db.TransactionIndices(txnID, 0, 100)
indices, err := db.TransactionChainIndices(txnID, 0, 100)
switch {
case err != nil:
t.Fatal(err)
Expand Down
4 changes: 2 additions & 2 deletions persist/sqlite/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"go.sia.tech/explored/explorer"
)

// transactionChainIndices returns the chain indices of the blocks the transaction
// TransactionChainIndices returns the chain indices of the blocks the transaction
// was included in. If the transaction has not been included in any blocks, the
// result will be nil,nil.
func (s *Store) TransactionIndices(txnID types.TransactionID, offset, limit uint64) (indices []types.ChainIndex, err error) {
func (s *Store) TransactionChainIndices(txnID types.TransactionID, offset, limit uint64) (indices []types.ChainIndex, err error) {
err = s.transaction(func(tx *txn) error {
rows, err := tx.Query(`SELECT DISTINCT b.id, b.height FROM blocks b
INNER JOIN block_transactions bt ON (bt.block_id = b.id)
Expand Down

0 comments on commit 2a57c5c

Please sign in to comment.