Skip to content

Commit afc10a2

Browse files
Restrict the scope of some variables and functions. (#4337)
## Motivation An examination of the code indicates that some variables and functions should have a restricted scope. ## Proposal The changed files are self-explanatory. ## Test Plan CI. ## Release Plan - Nothing to do / These changes follow the usual release cycle. ## Links None
1 parent f204d4a commit afc10a2

File tree

9 files changed

+20
-21
lines changed

9 files changed

+20
-21
lines changed

linera-client/src/client_options.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ pub struct ClientContextOptions {
134134

135135
impl ClientContextOptions {
136136
/// Creates [`ChainClientOptions`] with the corresponding values.
137-
pub fn to_chain_client_options(&self) -> ChainClientOptions {
137+
pub(crate) fn to_chain_client_options(&self) -> ChainClientOptions {
138138
let message_policy = MessagePolicy::new(
139139
self.blanket_message_policy,
140140
self.restrict_chain_ids_to.clone(),
@@ -152,7 +152,7 @@ impl ClientContextOptions {
152152

153153
/// Creates [`TimingConfig`] with the corresponding values.
154154
#[cfg(not(web))]
155-
pub fn to_timing_config(&self) -> TimingConfig {
155+
pub(crate) fn to_timing_config(&self) -> TimingConfig {
156156
TimingConfig {
157157
enabled: self.timings,
158158
report_interval_secs: self.timing_interval,

linera-client/src/wallet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::{config::GenesisConfig, error, Error};
1818
pub struct Wallet {
1919
pub chains: BTreeMap<ChainId, UserChain>,
2020
pub default: Option<ChainId>,
21-
pub genesis_config: GenesisConfig,
21+
genesis_config: GenesisConfig,
2222
}
2323

2424
impl Extend<UserChain> for Wallet {

linera-explorer/src/js_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use serde_wasm_bindgen::Serializer;
66
use wasm_bindgen::prelude::*;
77

88
/// JS special serializer
9-
pub const SER: Serializer =
9+
pub(crate) const SER: Serializer =
1010
serde_wasm_bindgen::Serializer::new().serialize_large_number_types_as_bigints(true);
1111

1212
pub fn setf(target: &JsValue, field: &str, value: &JsValue) {

linera-faucet/server/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ where
361361
})
362362
}
363363

364-
pub fn schema(&self) -> Schema<QueryRoot<C>, MutationRoot<C>, EmptySubscription> {
364+
fn schema(&self) -> Schema<QueryRoot<C>, MutationRoot<C>, EmptySubscription> {
365365
let mutation_root = MutationRoot {
366366
chain_id: self.chain_id,
367367
context: Arc::clone(&self.context),

linera-service/src/cli_wrappers/local_net.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ impl LocalNet {
435435
13000 + validator * 100 + proxy_id + 1
436436
}
437437

438-
pub fn proxy_internal_port(validator: usize, proxy_id: usize) -> usize {
438+
fn proxy_internal_port(validator: usize, proxy_id: usize) -> usize {
439439
10000 + validator * 100 + proxy_id + 1
440440
}
441441

@@ -788,7 +788,7 @@ impl LocalNet {
788788
bail!("Failed to start {nickname}");
789789
}
790790

791-
pub async fn ensure_simple_server_has_started(
791+
async fn ensure_simple_server_has_started(
792792
nickname: &str,
793793
port: usize,
794794
protocol: &str,

linera-service/src/exporter/runloops/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ mod test {
624624
let destination = DummyValidator::default();
625625
destination.set_faulty();
626626
tokio::spawn(destination.clone().start(port, token.clone()));
627-
LocalNet::ensure_grpc_server_has_started("falty validator", port as usize, "http").await?;
627+
LocalNet::ensure_grpc_server_has_started("faulty validator", port as usize, "http").await?;
628628
let destination_address = Destination::Validator {
629629
port,
630630
endpoint: "127.0.0.1".to_owned(),

linera-storage-service/src/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use linera_views::{
2020
batch::{Batch, WriteOperation},
2121
lru_caching::LruCachingDatabase,
2222
store::{KeyValueDatabase, ReadableKeyValueStore, WithError, WritableKeyValueStore},
23-
FutureSyncExt,
23+
FutureSyncExt as _,
2424
};
2525
use serde::de::DeserializeOwned;
2626
use tonic::transport::{Channel, Endpoint};

linera-storage/src/db_storage.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ pub mod metrics {
9595

9696
/// The metric counting how often a blob is read from storage.
9797
#[doc(hidden)]
98-
pub static READ_BLOB_COUNTER: LazyLock<IntCounterVec> = LazyLock::new(|| {
98+
pub(super) static READ_BLOB_COUNTER: LazyLock<IntCounterVec> = LazyLock::new(|| {
9999
register_int_counter_vec(
100100
"read_blob",
101101
"The metric counting how often a blob is read from storage",
@@ -105,7 +105,7 @@ pub mod metrics {
105105

106106
/// The metric counting how often a blob state is read from storage.
107107
#[doc(hidden)]
108-
pub static READ_BLOB_STATE_COUNTER: LazyLock<IntCounterVec> = LazyLock::new(|| {
108+
pub(super) static READ_BLOB_STATE_COUNTER: LazyLock<IntCounterVec> = LazyLock::new(|| {
109109
register_int_counter_vec(
110110
"read_blob_state",
111111
"The metric counting how often a blob state is read from storage",
@@ -115,7 +115,7 @@ pub mod metrics {
115115

116116
/// The metric counting how often blob states are read from storage.
117117
#[doc(hidden)]
118-
pub static READ_BLOB_STATES_COUNTER: LazyLock<IntCounterVec> = LazyLock::new(|| {
118+
pub(super) static READ_BLOB_STATES_COUNTER: LazyLock<IntCounterVec> = LazyLock::new(|| {
119119
register_int_counter_vec(
120120
"read_blob_states",
121121
"The metric counting how often blob states are read from storage",
@@ -125,7 +125,7 @@ pub mod metrics {
125125

126126
/// The metric counting how often a blob is written to storage.
127127
#[doc(hidden)]
128-
pub static WRITE_BLOB_COUNTER: LazyLock<IntCounterVec> = LazyLock::new(|| {
128+
pub(super) static WRITE_BLOB_COUNTER: LazyLock<IntCounterVec> = LazyLock::new(|| {
129129
register_int_counter_vec(
130130
"write_blob",
131131
"The metric counting how often a blob is written to storage",
@@ -145,7 +145,7 @@ pub mod metrics {
145145

146146
/// The metric counting how often certificates are read from storage.
147147
#[doc(hidden)]
148-
pub static READ_CERTIFICATES_COUNTER: LazyLock<IntCounterVec> = LazyLock::new(|| {
148+
pub(super) static READ_CERTIFICATES_COUNTER: LazyLock<IntCounterVec> = LazyLock::new(|| {
149149
register_int_counter_vec(
150150
"read_certificates",
151151
"The metric counting how often certificate are read from storage",
@@ -165,7 +165,7 @@ pub mod metrics {
165165

166166
/// The latency to load a chain state.
167167
#[doc(hidden)]
168-
pub static LOAD_CHAIN_LATENCY: LazyLock<HistogramVec> = LazyLock::new(|| {
168+
pub(crate) static LOAD_CHAIN_LATENCY: LazyLock<HistogramVec> = LazyLock::new(|| {
169169
register_histogram_vec(
170170
"load_chain_latency",
171171
"The latency to load a chain state",
@@ -176,7 +176,7 @@ pub mod metrics {
176176

177177
/// The metric counting how often an event is read from storage.
178178
#[doc(hidden)]
179-
pub static READ_EVENT_COUNTER: LazyLock<IntCounterVec> = LazyLock::new(|| {
179+
pub(super) static READ_EVENT_COUNTER: LazyLock<IntCounterVec> = LazyLock::new(|| {
180180
register_int_counter_vec(
181181
"read_event",
182182
"The metric counting how often an event is read from storage",
@@ -195,7 +195,7 @@ pub mod metrics {
195195

196196
/// The metric counting how often an event is written to storage.
197197
#[doc(hidden)]
198-
pub static WRITE_EVENT_COUNTER: LazyLock<IntCounterVec> = LazyLock::new(|| {
198+
pub(super) static WRITE_EVENT_COUNTER: LazyLock<IntCounterVec> = LazyLock::new(|| {
199199
register_int_counter_vec(
200200
"write_event",
201201
"The metric counting how often an event is written to storage",
@@ -205,7 +205,7 @@ pub mod metrics {
205205

206206
/// The metric counting how often the network description is read from storage.
207207
#[doc(hidden)]
208-
pub static READ_NETWORK_DESCRIPTION: LazyLock<IntCounterVec> = LazyLock::new(|| {
208+
pub(super) static READ_NETWORK_DESCRIPTION: LazyLock<IntCounterVec> = LazyLock::new(|| {
209209
register_int_counter_vec(
210210
"network_description",
211211
"The metric counting how often the network description is read from storage",
@@ -215,7 +215,7 @@ pub mod metrics {
215215

216216
/// The metric counting how often the network description is written to storage.
217217
#[doc(hidden)]
218-
pub static WRITE_NETWORK_DESCRIPTION: LazyLock<IntCounterVec> = LazyLock::new(|| {
218+
pub(super) static WRITE_NETWORK_DESCRIPTION: LazyLock<IntCounterVec> = LazyLock::new(|| {
219219
register_int_counter_vec(
220220
"write_network_description",
221221
"The metric counting how often the network description is written to storage",

linera-views/src/common.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ use serde::de::DeserializeOwned;
1515

1616
use crate::ViewError;
1717

18-
#[doc(hidden)]
19-
pub type HasherOutputSize = <sha3::Sha3_256 as sha3::digest::OutputSizeUser>::OutputSize;
18+
type HasherOutputSize = <sha3::Sha3_256 as sha3::digest::OutputSizeUser>::OutputSize;
2019
#[doc(hidden)]
2120
pub type HasherOutput = generic_array::GenericArray<u8, HasherOutputSize>;
2221

0 commit comments

Comments
 (0)