Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the chain manager a View. #3135

Merged
merged 8 commits into from
Jan 15, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Deduplicate setting the locked block and blobs.
  • Loading branch information
afck committed Jan 15, 2025
commit aed282fb652069e756cc48d368a2026df66b04cb
26 changes: 16 additions & 10 deletions linera-chain/src/manager.rs
Original file line number Diff line number Diff line change
@@ -408,11 +408,7 @@ where
{
let value = Hashed::new(ValidatedBlock::new(executed_block.clone()));
if let Some(certificate) = lite_cert.clone().with_value(value) {
self.locked.set(Some(certificate));
self.locked_blobs.clear();
for (blob_id, blob) in blobs {
self.locked_blobs.insert(&blob_id, blob)?;
}
self.set_locked(certificate, blobs)?;
}
}
}
@@ -462,11 +458,7 @@ where
return Ok(());
}
let confirmed_block = ConfirmedBlock::new(validated.inner().executed_block().clone());
self.locked.set(Some(validated));
self.locked_blobs.clear();
for (blob_id, blob) in blobs {
self.locked_blobs.insert(&blob_id, blob)?;
}
self.set_locked(validated, blobs)?;
self.update_current_round(local_time);
if let Some(key_pair) = key_pair {
// Vote to confirm.
@@ -603,6 +595,20 @@ where
fn is_super(&self, owner: &Owner) -> bool {
self.ownership.get().super_owners.contains_key(owner)
}

/// Sets the locked block and the associated blobs.
fn set_locked(
&mut self,
certificate: ValidatedBlockCertificate,
blobs: BTreeMap<BlobId, Blob>,
) -> Result<(), ViewError> {
self.locked.set(Some(certificate));
self.locked_blobs.clear();
for (blob_id, blob) in blobs {
self.locked_blobs.insert(&blob_id, blob)?;
}
Ok(())
}
}

/// Chain manager information that is included in `ChainInfo` sent to clients.