@@ -37,12 +37,7 @@ use commonware_storage::{
3737 translator:: Translator ,
3838 Persistable ,
3939} ;
40- use commonware_utils:: {
41- channel:: mpsc,
42- non_empty_range,
43- sync:: { AsyncRwLock , AsyncRwLockReadGuard } ,
44- Array ,
45- } ;
40+ use commonware_utils:: { channel:: mpsc, non_empty_range, sync:: AsyncRwLock , Array } ;
4641use std:: { ops:: Deref , sync:: Arc } ;
4742
4843type AnyDbHandle < F , E , C , I , H , U > = Arc < AsyncRwLock < Db < F , E , C , I , H , U > > > ;
@@ -84,25 +79,13 @@ where
8479 self
8580 }
8681
87- /// Acquire a read lock on the DB.
88- pub async fn lock (
89- & self ,
90- ) -> AsyncRwLockReadGuard < ' _ , Db < F , E , C , I , H , unordered:: Update < K , V > > > {
91- self . db . read ( ) . await
92- }
93-
94- /// Get a reference to the inner batch.
95- pub const fn batch ( & self ) -> & UnmerkleizedBatch < F , H , unordered:: Update < K , V > > {
96- & self . batch
97- }
98-
9982 /// Read a value by key, falling back to committed state.
10083 pub async fn get ( & self , key : & K ) -> Result < Option < V :: Value > , Error < F > > {
10184 let db = self . db . read ( ) . await ;
10285 self . batch . get ( key, & * db) . await
10386 }
10487
105- /// Read multiple values by key, amortizing lock acquisition and journal I/O .
88+ /// Read multiple values by key, falling back to committed state .
10689 ///
10790 /// Returns results in the same order as the input keys.
10891 pub async fn get_many ( & self , keys : & [ & K ] ) -> Result < Vec < Option < V :: Value > > , Error < F > > {
@@ -186,7 +169,7 @@ where
186169 self . batch . get ( key, & * db) . await
187170 }
188171
189- /// Read multiple values by key, amortizing lock acquisition and journal I/O .
172+ /// Read multiple values by key, falling back to committed state .
190173 ///
191174 /// Returns results in the same order as the input keys.
192175 pub async fn get_many ( & self , keys : & [ & K ] ) -> Result < Vec < Option < V :: Value > > , Error < F > > {
@@ -201,6 +184,32 @@ where
201184 }
202185}
203186
187+ /// Read-through operations for the `any` merkleized batch.
188+ impl < F , E , C , I , H , U > AnyMerkleized < F , E , C , I , H , U >
189+ where
190+ F : Family ,
191+ E : Storage + Clock + Metrics ,
192+ U : Update ,
193+ C : Contiguous < Item = Operation < F , U > > ,
194+ I : UnorderedIndex < Value = Location < F > > + ' static ,
195+ H : Hasher ,
196+ Operation < F , U > : Codec ,
197+ {
198+ /// Read a value by key, falling back to committed state.
199+ pub async fn get ( & self , key : & U :: Key ) -> Result < Option < U :: Value > , Error < F > > {
200+ let db = self . db . read ( ) . await ;
201+ self . inner . get ( key, & * db) . await
202+ }
203+
204+ /// Read multiple values by key, falling back to committed state.
205+ ///
206+ /// Returns results in the same order as the input keys.
207+ pub async fn get_many ( & self , keys : & [ & U :: Key ] ) -> Result < Vec < Option < U :: Value > > , Error < F > > {
208+ let db = self . db . read ( ) . await ;
209+ self . inner . get_many ( keys, & * db) . await
210+ }
211+ }
212+
204213/// Implement [`Unmerkleized`](UnmerkleizedTrait) for the `any` unordered update kind.
205214impl < F , E , C , I , H , K , V > UnmerkleizedTrait
206215 for AnyUnmerkleized < F , E , C , I , H , unordered:: Update < K , V > >
0 commit comments