diff --git a/storage/badger/results.go b/storage/badger/results.go index 95ac06ac5c2..ad66841ca76 100644 --- a/storage/badger/results.go +++ b/storage/badger/results.go @@ -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) } } diff --git a/storage/mock/execution_results.go b/storage/mock/execution_results.go index 8a64f060232..c9ad6b09035 100644 --- a/storage/mock/execution_results.go +++ b/storage/mock/execution_results.go @@ -7,6 +7,8 @@ import ( mock "github.com/stretchr/testify/mock" storage "github.com/onflow/flow-go/storage" + + transaction "github.com/onflow/flow-go/storage/badger/transaction" ) // ExecutionResults is an autogenerated mock type for the ExecutionResults type @@ -109,15 +111,15 @@ func (_m *ExecutionResults) ByID(resultID flow.Identifier) (*flow.ExecutionResul } // ByIDTx provides a mock function with given fields: resultID -func (_m *ExecutionResults) ByIDTx(resultID flow.Identifier) func(interface{}) (*flow.ExecutionResult, error) { +func (_m *ExecutionResults) ByIDTx(resultID flow.Identifier) func(*transaction.Tx) (*flow.ExecutionResult, error) { ret := _m.Called(resultID) - var r0 func(interface{}) (*flow.ExecutionResult, error) - if rf, ok := ret.Get(0).(func(flow.Identifier) func(interface{}) (*flow.ExecutionResult, error)); ok { + var r0 func(*transaction.Tx) (*flow.ExecutionResult, error) + if rf, ok := ret.Get(0).(func(flow.Identifier) func(*transaction.Tx) (*flow.ExecutionResult, error)); ok { r0 = rf(resultID) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(func(interface{}) (*flow.ExecutionResult, error)) + r0 = ret.Get(0).(func(*transaction.Tx) (*flow.ExecutionResult, error)) } } diff --git a/storage/pebble/results.go b/storage/pebble/results.go index 4283b7905d6..8b1272f6a44 100644 --- a/storage/pebble/results.go +++ b/storage/pebble/results.go @@ -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" ) @@ -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 } diff --git a/storage/results.go b/storage/results.go index 8ad89525e40..39fd4d810e1 100644 --- a/storage/results.go +++ b/storage/results.go @@ -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 { @@ -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