From 8acffcc0db35dc911c6150f5180dae46014479d3 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Thu, 30 May 2019 18:38:41 +1000 Subject: [PATCH] Make some `BeaconChain` functions private --- beacon_node/beacon_chain/src/beacon_chain.rs | 8 ++++---- beacon_node/client/src/beacon_chain_types.rs | 2 +- beacon_node/client/src/lib.rs | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index d362f7fab..a04f6b1c8 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -94,7 +94,7 @@ pub struct BeaconChain { pub op_pool: OperationPool, canonical_head: RwLock>, finalized_head: RwLock>, - pub state: RwLock>, + state: RwLock>, pub spec: ChainSpec, pub fork_choice: RwLock, pub metrics: Metrics, @@ -310,7 +310,7 @@ impl BeaconChain { } /// Update the canonical head to some new values. - pub fn update_canonical_head( + fn update_canonical_head( &self, new_beacon_block: BeaconBlock, new_beacon_block_root: Hash256, @@ -354,7 +354,7 @@ impl BeaconChain { /// /// Also persists the `BeaconChain` to the store, in the case the client does not exit /// gracefully. - pub fn update_state(&self, mut state: BeaconState) -> Result<(), Error> { + fn update_state(&self, mut state: BeaconState) -> Result<(), Error> { let present_slot = match self.slot_clock.present_slot() { Ok(Some(slot)) => slot, _ => return Err(Error::UnableToReadSlot), @@ -407,7 +407,7 @@ impl BeaconChain { } /// Update the justified head to some new values. - pub fn update_finalized_head( + fn update_finalized_head( &self, new_beacon_block: BeaconBlock, new_beacon_block_root: Hash256, diff --git a/beacon_node/client/src/beacon_chain_types.rs b/beacon_node/client/src/beacon_chain_types.rs index 8990e842d..24ad93ad4 100644 --- a/beacon_node/client/src/beacon_chain_types.rs +++ b/beacon_node/client/src/beacon_chain_types.rs @@ -68,7 +68,7 @@ where info!( log, "Loaded BeaconChain from store"; - "slot" => beacon_chain.state.read().slot, + "slot" => beacon_chain.head().beacon_state.slot, "best_slot" => beacon_chain.best_slot(), ); diff --git a/beacon_node/client/src/lib.rs b/beacon_node/client/src/lib.rs index b67cc6a0d..4824d40ad 100644 --- a/beacon_node/client/src/lib.rs +++ b/beacon_node/client/src/lib.rs @@ -75,7 +75,7 @@ where // If we don't block here we create an initial scenario where we're unable to process any // blocks and we're basically useless. { - let state_slot = beacon_chain.state.read().slot; + let state_slot = beacon_chain.head().beacon_state.slot; let wall_clock_slot = beacon_chain.read_slot_clock().unwrap(); let slots_since_genesis = beacon_chain.slots_since_genesis().unwrap(); info!( @@ -91,7 +91,7 @@ where info!( log, "State initialized"; - "state_slot" => beacon_chain.state.read().slot, + "state_slot" => beacon_chain.head().beacon_state.slot, "wall_clock_slot" => beacon_chain.read_slot_clock().unwrap(), ); @@ -190,7 +190,7 @@ fn do_state_catchup(chain: &Arc>, log: &slog "best_slot" => chain.head().beacon_block.slot, "latest_block_root" => format!("{}", chain.head().beacon_block_root), "wall_clock_slot" => chain.read_slot_clock().unwrap(), - "state_slot" => chain.state.read().slot, + "state_slot" => chain.head().beacon_state.slot, "slots_since_genesis" => genesis_height, );