File tree Expand file tree Collapse file tree 14 files changed +44
-79
lines changed
linera-storage-service/src Expand file tree Collapse file tree 14 files changed +44
-79
lines changed Original file line number Diff line number Diff line change @@ -518,16 +518,12 @@ impl KeyValueDatabase for StorageServiceDatabaseInternal {
518518 Ok ( namespaces)
519519 }
520520
521- async fn list_root_keys (
522- config : & Self :: Config ,
523- namespace : & str ,
524- ) -> Result < Vec < Vec < u8 > > , StorageServiceStoreError > {
525- let namespace = bcs:: to_bytes ( namespace) ?;
526- let query = RequestListRootKeys { namespace } ;
521+ async fn list_root_keys ( & self ) -> Result < Vec < Vec < u8 > > , StorageServiceStoreError > {
522+ let query = RequestListRootKeys {
523+ namespace : self . namespace . clone ( ) ,
524+ } ;
527525 let request = tonic:: Request :: new ( query) ;
528- let endpoint = config. http_address ( ) ;
529- let endpoint = Endpoint :: from_shared ( endpoint) ?;
530- let mut client = StorageServiceClient :: connect ( endpoint) . make_sync ( ) . await ?;
526+ let mut client = StorageServiceClient :: new ( self . channel . clone ( ) ) ;
531527 let response = client. process_list_root_keys ( request) . make_sync ( ) . await ?;
532528 let response = response. into_inner ( ) ;
533529 let ReplyListRootKeys { root_keys } = response;
Original file line number Diff line number Diff line change @@ -1091,7 +1091,8 @@ where
10911091 config : & Database :: Config ,
10921092 namespace : & str ,
10931093 ) -> Result < Vec < BlobId > , ViewError > {
1094- let root_keys = Database :: list_root_keys ( config, namespace) . await ?;
1094+ let database = Database :: connect ( config, namespace) . await ?;
1095+ let root_keys = database. list_root_keys ( ) . await ?;
10951096 let mut blob_ids = Vec :: new ( ) ;
10961097 for root_key in root_keys {
10971098 if root_key. len ( ) == 1 + BLOB_ID_LENGTH && root_key[ 0 ] == BLOB_ID_TAG {
@@ -1114,7 +1115,8 @@ where
11141115 config : & Database :: Config ,
11151116 namespace : & str ,
11161117 ) -> Result < Vec < ChainId > , ViewError > {
1117- let root_keys = Database :: list_root_keys ( config, namespace) . await ?;
1118+ let database = Database :: connect ( config, namespace) . await ?;
1119+ let root_keys = database. list_root_keys ( ) . await ?;
11181120 let mut chain_ids = Vec :: new ( ) ;
11191121 for root_key in root_keys {
11201122 if root_key. len ( ) == 1 + CHAIN_ID_LENGTH && root_key[ 0 ] == CHAIN_ID_TAG {
Original file line number Diff line number Diff line change @@ -304,15 +304,15 @@ where
304304 Ok ( namespaces)
305305 }
306306
307- async fn list_root_keys (
308- config : & Self :: Config ,
309- namespace : & str ,
310- ) -> Result < Vec < Vec < u8 > > , Self :: Error > {
311- let mut root_keys = D1 :: list_root_keys ( & config. first_config , namespace)
307+ async fn list_root_keys ( & self ) -> Result < Vec < Vec < u8 > > , Self :: Error > {
308+ let mut root_keys = self
309+ . first_database
310+ . list_root_keys ( )
312311 . await
313312 . map_err ( DualStoreError :: First ) ?;
314313 root_keys. extend (
315- D2 :: list_root_keys ( & config. second_config , namespace)
314+ self . second_database
315+ . list_root_keys ( )
316316 . await
317317 . map_err ( DualStoreError :: Second ) ?,
318318 ) ;
Original file line number Diff line number Diff line change @@ -401,12 +401,8 @@ impl KeyValueDatabase for DynamoDbDatabaseInternal {
401401 Ok ( namespaces)
402402 }
403403
404- async fn list_root_keys (
405- config : & Self :: Config ,
406- namespace : & str ,
407- ) -> Result < Vec < Vec < u8 > > , DynamoDbStoreInternalError > {
408- let database = Self :: connect ( config, namespace) . await ?;
409- let store = database. open_internal ( PARTITION_KEY_ROOT_KEY . to_vec ( ) ) ;
404+ async fn list_root_keys ( & self ) -> Result < Vec < Vec < u8 > > , DynamoDbStoreInternalError > {
405+ let store = self . open_internal ( PARTITION_KEY_ROOT_KEY . to_vec ( ) ) ;
410406 store. find_keys_by_prefix ( EMPTY_ROOT_KEY ) . await
411407 }
412408
Original file line number Diff line number Diff line change @@ -301,13 +301,9 @@ impl KeyValueDatabase for IndexedDbDatabase {
301301 . collect ( ) )
302302 }
303303
304- async fn list_root_keys (
305- config : & Self :: Config ,
306- namespace : & str ,
307- ) -> Result < Vec < Vec < u8 > > , IndexedDbStoreError > {
308- let database = Self :: connect ( config, namespace) . await ?;
304+ async fn list_root_keys ( & self ) -> Result < Vec < Vec < u8 > > , IndexedDbStoreError > {
309305 let start_key = STORED_ROOT_KEYS_PREFIX . to_vec ( ) ;
310- let store = database . open_internal ( start_key) ;
306+ let store = self . open_internal ( start_key) ;
311307 store. find_keys_by_prefix ( & [ ] ) . await
312308 }
313309
Original file line number Diff line number Diff line change @@ -190,11 +190,8 @@ where
190190 D :: list_all ( config) . await
191191 }
192192
193- async fn list_root_keys (
194- config : & Self :: Config ,
195- namespace : & str ,
196- ) -> Result < Vec < Vec < u8 > > , Self :: Error > {
197- D :: list_root_keys ( config, namespace) . await
193+ async fn list_root_keys ( & self ) -> Result < Vec < Vec < u8 > > , Self :: Error > {
194+ self . database . list_root_keys ( ) . await
198195 }
199196
200197 async fn delete_all ( config : & Self :: Config ) -> Result < ( ) , Self :: Error > {
Original file line number Diff line number Diff line change @@ -433,11 +433,8 @@ where
433433 D :: list_all ( & config. inner_config ) . await
434434 }
435435
436- async fn list_root_keys (
437- config : & Self :: Config ,
438- namespace : & str ,
439- ) -> Result < Vec < Vec < u8 > > , Self :: Error > {
440- D :: list_root_keys ( & config. inner_config , namespace) . await
436+ async fn list_root_keys ( & self ) -> Result < Vec < Vec < u8 > > , Self :: Error > {
437+ self . database . list_root_keys ( ) . await
441438 }
442439
443440 async fn delete_all ( config : & Self :: Config ) -> Result < ( ) , Self :: Error > {
Original file line number Diff line number Diff line change @@ -304,14 +304,11 @@ impl KeyValueDatabase for MemoryDatabase {
304304 Ok ( databases. sync_list_all ( ) )
305305 }
306306
307- async fn list_root_keys (
308- _config : & Self :: Config ,
309- namespace : & str ,
310- ) -> Result < Vec < Vec < u8 > > , MemoryStoreError > {
307+ async fn list_root_keys ( & self ) -> Result < Vec < Vec < u8 > > , MemoryStoreError > {
311308 let databases = MEMORY_DATABASES
312309 . lock ( )
313310 . expect ( "MEMORY_DATABASES lock should not be poisoned" ) ;
314- Ok ( databases. sync_list_root_keys ( namespace) )
311+ Ok ( databases. sync_list_root_keys ( & self . namespace ) )
315312 }
316313
317314 async fn exists ( _config : & Self :: Config , namespace : & str ) -> Result < bool , MemoryStoreError > {
Original file line number Diff line number Diff line change @@ -496,14 +496,9 @@ where
496496 Ok ( namespaces)
497497 }
498498
499- async fn list_root_keys (
500- config : & Self :: Config ,
501- namespace : & str ,
502- ) -> Result < Vec < Vec < u8 > > , Self :: Error > {
503- let name = D :: get_name ( ) ;
504- let counter = get_counter ( & name) ;
505- let _latency = counter. list_root_keys_latency . measure_latency ( ) ;
506- D :: list_root_keys ( config, namespace) . await
499+ async fn list_root_keys ( & self ) -> Result < Vec < Vec < u8 > > , Self :: Error > {
500+ let _latency = self . counter . list_root_keys_latency . measure_latency ( ) ;
501+ self . database . list_root_keys ( ) . await
507502 }
508503
509504 async fn delete_all ( config : & Self :: Config ) -> Result < ( ) , Self :: Error > {
Original file line number Diff line number Diff line change @@ -582,12 +582,9 @@ impl KeyValueDatabase for RocksDbDatabaseInternal {
582582 Ok ( namespaces)
583583 }
584584
585- async fn list_root_keys (
586- config : & Self :: Config ,
587- namespace : & str ,
588- ) -> Result < Vec < Vec < u8 > > , RocksDbStoreInternalError > {
589- let start_key = vec ! [ STORED_ROOT_KEYS_PREFIX ] ;
590- let store = RocksDbStoreInternal :: build ( config, namespace, start_key) ?;
585+ async fn list_root_keys ( & self ) -> Result < Vec < Vec < u8 > > , RocksDbStoreInternalError > {
586+ let mut store = self . open_shared ( & [ ] ) ?;
587+ store. executor . start_key = vec ! [ STORED_ROOT_KEYS_PREFIX ] ;
591588 store. find_keys_by_prefix ( & [ ] ) . await
592589 }
593590
You can’t perform that action at this time.
0 commit comments