Skip to content

Commit

Permalink
fix results API
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangchiqing committed Jul 11, 2024
1 parent 1d45907 commit 5d1ae72
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
11 changes: 3 additions & 8 deletions storage/badger/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,9 @@ func (r *ExecutionResults) ByID(resultID flow.Identifier) (*flow.ExecutionResult
return r.byID(resultID)(tx)
}

func (r *ExecutionResults) ByIDTx(resultID flow.Identifier) func(interface{}) (*flow.ExecutionResult, error) {
return func(txinf interface{}) (*flow.ExecutionResult, error) {
tx, ok := txinf.(*transaction.Tx)
if !ok {
return nil, fmt.Errorf("could not cast to *transaction.Tx")
}
result, err := r.byID(resultID)(tx.DBTxn)
return result, err
func (r *ExecutionResults) ByIDTx(resultID flow.Identifier) func(*transaction.Tx) (*flow.ExecutionResult, error) {
return func(tx *transaction.Tx) (*flow.ExecutionResult, error) {
return r.byID(resultID)(tx.DBTxn)
}
}

Expand Down
10 changes: 6 additions & 4 deletions storage/mock/execution_results.go

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

3 changes: 2 additions & 1 deletion storage/pebble/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/onflow/flow-go/module"
"github.com/onflow/flow-go/module/metrics"
"github.com/onflow/flow-go/storage"
"github.com/onflow/flow-go/storage/badger/transaction"
"github.com/onflow/flow-go/storage/pebble/operation"
)

Expand Down Expand Up @@ -92,7 +93,7 @@ func (r *ExecutionResults) ByID(resultID flow.Identifier) (*flow.ExecutionResult
return r.byID(resultID)(r.db)
}

func (r *ExecutionResults) ByIDTx(resultID flow.Identifier) func(interface{}) (*flow.ExecutionResult, error) {
func (r *ExecutionResults) ByIDTx(resultID flow.Identifier) func(*transaction.Tx) (*flow.ExecutionResult, error) {
return nil
}

Expand Down
3 changes: 2 additions & 1 deletion storage/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package storage

import (
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/storage/badger/transaction"
)

type ExecutionResults interface {
Expand All @@ -18,7 +19,7 @@ type ExecutionResults interface {
ByID(resultID flow.Identifier) (*flow.ExecutionResult, error)

// ByIDTx retrieves an execution result by its ID in the context of the given transaction
ByIDTx(resultID flow.Identifier) func(interface{}) (*flow.ExecutionResult, error)
ByIDTx(resultID flow.Identifier) func(*transaction.Tx) (*flow.ExecutionResult, error)

// Index indexes an execution result by block ID.
Index(blockID flow.Identifier, resultID flow.Identifier) error
Expand Down

0 comments on commit 5d1ae72

Please sign in to comment.