From 82c26807f973d2755051d0df5b992ca2e5001dde Mon Sep 17 00:00:00 2001 From: Timothy Wu Date: Mon, 20 Jan 2025 10:00:02 -0500 Subject: [PATCH] add ImportLockRun interface --- internal/client/api/backend.go | 14 ++++++++++++++ internal/client/client_test.go | 5 +++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/internal/client/api/backend.go b/internal/client/api/backend.go index 9c8e4c7da7..beada27356 100644 --- a/internal/client/api/backend.go +++ b/internal/client/api/backend.go @@ -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 diff --git a/internal/client/client_test.go b/internal/client/client_test.go index a1ca98867e..47910b4c20 100644 --- a/internal/client/client_test.go +++ b/internal/client/client_test.go @@ -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,