Skip to content

Commit

Permalink
Make mutating ChainState methods pub(super).
Browse files Browse the repository at this point in the history
  • Loading branch information
afck committed Oct 4, 2024
1 parent 69d787d commit 5ffc29d
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions linera-core/src/client/chain_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl ChainState {
&self.pending_block
}

pub fn set_pending_block(&mut self, block: Block) {
pub(super) fn set_pending_block(&mut self, block: Block) {
if block.height == self.next_block_height {
self.pending_block = Some(block);
} else {
Expand All @@ -116,15 +116,15 @@ impl ChainState {
&self.pending_blobs
}

pub fn insert_pending_blob(&mut self, blob: Blob) {
pub(super) fn insert_pending_blob(&mut self, blob: Blob) {
self.pending_blobs.insert(blob.id(), blob);
}

pub fn known_key_pairs(&self) -> &BTreeMap<Owner, KeyPair> {
&self.known_key_pairs
}

pub fn insert_known_key_pair(&mut self, key_pair: KeyPair) -> PublicKey {
pub(super) fn insert_known_key_pair(&mut self, key_pair: KeyPair) -> PublicKey {
let new_public_key = key_pair.public();
self.known_key_pairs.insert(new_public_key.into(), key_pair);
new_public_key
Expand All @@ -134,7 +134,11 @@ impl ChainState {
&self.received_certificate_trackers
}

pub fn update_received_certificate_tracker(&mut self, name: ValidatorName, tracker: u64) {
pub(super) fn update_received_certificate_tracker(
&mut self,
name: ValidatorName,
tracker: u64,
) {
self.received_certificate_trackers
.entry(name)
.and_modify(|t| {
Expand All @@ -147,7 +151,7 @@ impl ChainState {
.or_insert(tracker);
}

pub fn update_from_info(&mut self, info: &ChainInfo) {
pub(super) fn update_from_info(&mut self, info: &ChainInfo) {
if info.next_block_height > self.next_block_height {
self.next_block_height = info.next_block_height;
self.clear_pending_block();
Expand All @@ -156,12 +160,12 @@ impl ChainState {
}
}

pub fn clear_pending_block(&mut self) {
pub(super) fn clear_pending_block(&mut self) {
self.pending_block = None;
self.pending_blobs.clear();
}

pub fn client_mutex(&self) -> Arc<Mutex<()>> {
pub(super) fn client_mutex(&self) -> Arc<Mutex<()>> {
self.client_mutex.clone()
}
}

0 comments on commit 5ffc29d

Please sign in to comment.