Skip to content

Commit

Permalink
add ImportLockRun interface
Browse files Browse the repository at this point in the history
  • Loading branch information
timwu20 committed Jan 20, 2025
1 parent fdc527e commit 82c2680
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
14 changes: 14 additions & 0 deletions internal/client/api/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,20 @@ type BlockImportOperation[
UpdateTransactionIndex(index []statemachine.IndexOperation) error
}

// LockImportRun is the interface for performing operations on the backend.
type LockImportRun[
H runtime.Hash,
N runtime.Number,

Hasher runtime.Hasher[H],
Header runtime.Header[N, H],
E runtime.Extrinsic,
] interface {
/// LockImportRun locks the import lock, and run operations inside.
LockImportRun(
f func(*ClientImportOperation[H, Hasher, N, Header, E]) error,
) error
}
type KeyValue struct {
Key []byte
Value []byte
Expand Down
5 changes: 3 additions & 2 deletions internal/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ type TestClient struct {
}

var (
_ api.BlockchainEvents[hash.H256, uint64, *generic.Header[uint64, hash.H256, runtime.BlakeTwo256]] = &TestClient{}
_ api.PreCommitActions[hash.H256, uint64, *generic.Header[uint64, hash.H256, runtime.BlakeTwo256]] = &TestClient{}
_ api.BlockchainEvents[hash.H256, uint64, *generic.Header[uint64, hash.H256, runtime.BlakeTwo256]] = &TestClient{}
_ api.PreCommitActions[hash.H256, uint64, *generic.Header[uint64, hash.H256, runtime.BlakeTwo256]] = &TestClient{}
_ api.LockImportRun[hash.H256, uint64, runtime.BlakeTwo256, *generic.Header[uint64, hash.H256, runtime.BlakeTwo256], noopExtrinsic] = &TestClient{}
)

func NewTestBackend(t *testing.T,
Expand Down

0 comments on commit 82c2680

Please sign in to comment.