@@ -854,12 +854,47 @@ impl<Signer: sign::ecdsa::EcdsaChannelSigner> Persist<Signer> for TestPersister
854
854
}
855
855
856
856
pub struct TestStore {
857
- persisted_bytes : Mutex < HashMap < String , HashMap < String , Vec < u8 > > > > ,
858
- read_only : bool ,
857
+ inner : Arc < TestStoreInner > ,
859
858
}
860
859
861
860
impl TestStore {
862
861
pub fn new ( read_only : bool ) -> Self {
862
+ let inner = Arc :: new ( TestStoreInner :: new ( read_only) ) ;
863
+ Self { inner }
864
+ }
865
+ }
866
+
867
+ impl KVStoreSync for TestStore {
868
+ fn read (
869
+ & self , primary_namespace : & str , secondary_namespace : & str , key : & str ,
870
+ ) -> io:: Result < Vec < u8 > > {
871
+ self . inner . read_internal ( primary_namespace, secondary_namespace, key)
872
+ }
873
+
874
+ fn write (
875
+ & self , primary_namespace : & str , secondary_namespace : & str , key : & str , buf : Vec < u8 > ,
876
+ ) -> io:: Result < ( ) > {
877
+ self . inner . write_internal ( primary_namespace, secondary_namespace, key, buf)
878
+ }
879
+
880
+ fn remove (
881
+ & self , primary_namespace : & str , secondary_namespace : & str , key : & str , lazy : bool ,
882
+ ) -> io:: Result < ( ) > {
883
+ self . inner . remove_internal ( primary_namespace, secondary_namespace, key, lazy)
884
+ }
885
+
886
+ fn list ( & self , primary_namespace : & str , secondary_namespace : & str ) -> io:: Result < Vec < String > > {
887
+ self . inner . list_internal ( primary_namespace, secondary_namespace)
888
+ }
889
+ }
890
+
891
+ struct TestStoreInner {
892
+ persisted_bytes : Mutex < HashMap < String , HashMap < String , Vec < u8 > > > > ,
893
+ read_only : bool ,
894
+ }
895
+
896
+ impl TestStoreInner {
897
+ fn new ( read_only : bool ) -> Self {
863
898
let persisted_bytes = Mutex :: new ( new_hash_map ( ) ) ;
864
899
Self { persisted_bytes, read_only }
865
900
}
@@ -950,30 +985,6 @@ impl TestStore {
950
985
}
951
986
}
952
987
953
- impl KVStoreSync for TestStore {
954
- fn read (
955
- & self , primary_namespace : & str , secondary_namespace : & str , key : & str ,
956
- ) -> io:: Result < Vec < u8 > > {
957
- self . read_internal ( primary_namespace, secondary_namespace, key)
958
- }
959
-
960
- fn write (
961
- & self , primary_namespace : & str , secondary_namespace : & str , key : & str , buf : Vec < u8 > ,
962
- ) -> io:: Result < ( ) > {
963
- self . write_internal ( primary_namespace, secondary_namespace, key, buf)
964
- }
965
-
966
- fn remove (
967
- & self , primary_namespace : & str , secondary_namespace : & str , key : & str , lazy : bool ,
968
- ) -> io:: Result < ( ) > {
969
- self . remove_internal ( primary_namespace, secondary_namespace, key, lazy)
970
- }
971
-
972
- fn list ( & self , primary_namespace : & str , secondary_namespace : & str ) -> io:: Result < Vec < String > > {
973
- self . list_internal ( primary_namespace, secondary_namespace)
974
- }
975
- }
976
-
977
988
unsafe impl Sync for TestStore { }
978
989
unsafe impl Send for TestStore { }
979
990
0 commit comments