Skip to content

Commit 8c1f980

Browse files
committed
rename sync comittte variable and fix persist condition
1 parent 807ec80 commit 8c1f980

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

beacon_node/beacon_chain/src/light_client_server_cache.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub struct LightClientServerCache<T: BeaconChainTypes> {
4444
/// Caches the most recent light client update
4545
latest_light_client_update: RwLock<Option<LightClientUpdate<T::EthSpec>>>,
4646
/// Caches the current sync committee,
47-
latest_current_sync_committee: RwLock<Option<Arc<SyncCommittee<T::EthSpec>>>>,
47+
latest_written_current_sync_committee: RwLock<Option<Arc<SyncCommittee<T::EthSpec>>>>,
4848
/// Caches state proofs by block root
4949
prev_block_cache: Mutex<lru::LruCache<Hash256, LightClientCachedData<T::EthSpec>>>,
5050
}
@@ -55,7 +55,7 @@ impl<T: BeaconChainTypes> LightClientServerCache<T> {
5555
latest_finality_update: None.into(),
5656
latest_optimistic_update: None.into(),
5757
latest_light_client_update: None.into(),
58-
latest_current_sync_committee: None.into(),
58+
latest_written_current_sync_committee: None.into(),
5959
prev_block_cache: lru::LruCache::new(PREV_BLOCK_CACHE_SIZE).into(),
6060
}
6161
}
@@ -251,7 +251,9 @@ impl<T: BeaconChainTypes> LightClientServerCache<T> {
251251
sync_committee_period: u64,
252252
finalized_period: u64,
253253
) -> Result<(), BeaconChainError> {
254-
if let Some(latest_sync_committee) = self.latest_current_sync_committee.read().clone() {
254+
if let Some(latest_sync_committee) =
255+
self.latest_written_current_sync_committee.read().clone()
256+
{
255257
if latest_sync_committee == cached_parts.current_sync_committee {
256258
return Ok(());
257259
}
@@ -265,11 +267,10 @@ impl<T: BeaconChainTypes> LightClientServerCache<T> {
265267
&sync_committee_period.to_le_bytes(),
266268
&cached_parts.current_sync_committee.as_ssz_bytes(),
267269
)?;
270+
*self.latest_written_current_sync_committee.write() =
271+
Some(cached_parts.current_sync_committee.clone());
268272
}
269273

270-
*self.latest_current_sync_committee.write() =
271-
Some(cached_parts.current_sync_committee.clone());
272-
273274
Ok(())
274275
}
275276

0 commit comments

Comments
 (0)