Helper to initialize the cache for a given epoch.
(&mut self, epoch: Epoch)
| 181 | |
| 182 | /// Helper to initialize the cache for a given epoch. |
| 183 | async fn init_epoch(&mut self, epoch: Epoch) { |
| 184 | let verified_blocks = self |
| 185 | .init_archive(epoch, "verified", self.block_codec_config.clone()) |
| 186 | .await; |
| 187 | let notarized_blocks = self |
| 188 | .init_archive(epoch, "notarized", self.block_codec_config.clone()) |
| 189 | .await; |
| 190 | let notarizations = self |
| 191 | .init_archive( |
| 192 | epoch, |
| 193 | "notarizations", |
| 194 | S::certificate_codec_config_unbounded(), |
| 195 | ) |
| 196 | .await; |
| 197 | let finalizations = self |
| 198 | .init_archive( |
| 199 | epoch, |
| 200 | "finalizations", |
| 201 | S::certificate_codec_config_unbounded(), |
| 202 | ) |
| 203 | .await; |
| 204 | let existing = self.caches.insert( |
| 205 | epoch, |
| 206 | Cache { |
| 207 | verified_blocks, |
| 208 | notarized_blocks, |
| 209 | notarizations, |
| 210 | finalizations, |
| 211 | }, |
| 212 | ); |
| 213 | assert!(existing.is_none(), "cache already exists for epoch {epoch}"); |
| 214 | } |
| 215 | |
| 216 | /// Helper to initialize an archive. |
| 217 | async fn init_archive<T: CodecShared>( |
no test coverage detected