Преглед изворни кода

Reduce allocation and lifetimes complexity in call to get_confirmed_blocks_with_data (#9008)

Kamil Skalski пре 1 недеља
родитељ
комит
550789aef0
1 измењених фајлова са 6 додато и 5 уклоњено
  1. 6 5
      storage-bigtable/src/lib.rs

+ 6 - 5
storage-bigtable/src/lib.rs

@@ -34,6 +34,7 @@ use {
     std::{
     std::{
         collections::{HashMap, HashSet},
         collections::{HashMap, HashSet},
         convert::TryInto,
         convert::TryInto,
+        fmt::Debug,
         sync::{
         sync::{
             atomic::{AtomicUsize, Ordering},
             atomic::{AtomicUsize, Ordering},
             Arc,
             Arc,
@@ -550,14 +551,14 @@ impl LedgerStorage {
     }
     }
 
 
     // Fetches and gets a vector of confirmed blocks via a multirow fetch
     // Fetches and gets a vector of confirmed blocks via a multirow fetch
-    pub async fn get_confirmed_blocks_with_data<'a>(
+    pub async fn get_confirmed_blocks_with_data(
         &self,
         &self,
-        slots: &'a [Slot],
-    ) -> Result<impl Iterator<Item = (Slot, ConfirmedBlock)> + 'a + use<'a>> {
+        slots: impl IntoIterator<Item = Slot> + Debug,
+    ) -> Result<impl Iterator<Item = (Slot, ConfirmedBlock)>> {
         trace!("LedgerStorage::get_confirmed_blocks_with_data request received: {slots:?}");
         trace!("LedgerStorage::get_confirmed_blocks_with_data request received: {slots:?}");
         self.stats.increment_num_queries();
         self.stats.increment_num_queries();
         let mut bigtable = self.connection.client();
         let mut bigtable = self.connection.client();
-        let row_keys = slots.iter().copied().map(slot_to_blocks_key);
+        let row_keys = slots.into_iter().map(slot_to_blocks_key);
         let data = bigtable
         let data = bigtable
             .get_protobuf_or_bincode_cells("blocks", row_keys)
             .get_protobuf_or_bincode_cells("blocks", row_keys)
             .await?
             .await?
@@ -672,7 +673,7 @@ impl LedgerStorage {
 
 
         // Fetch blocks
         // Fetch blocks
         let blocks = self
         let blocks = self
-            .get_confirmed_blocks_with_data(&slots.into_iter().collect::<Vec<_>>())
+            .get_confirmed_blocks_with_data(slots)
             .await?
             .await?
             .collect::<HashMap<_, _>>();
             .collect::<HashMap<_, _>>();