Skip to content

Commit 7467237

Browse files
committed
refactor: rename function and clarify some comments after review
- Rename function 'allow_unparsable_block' to 'compute_allow_unparsable_block' and clarify its comment - Add reference to pre-production network in 'allow_unparsable_block' comments
1 parent 5d06859 commit 7467237

File tree

11 files changed

+28
-29
lines changed

11 files changed

+28
-29
lines changed

.github/workflows/actions/deploy-terraform-infrastructure/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ inputs:
101101
description: CExplorer url of the list of pools that is used by the mithril aggregator.
102102
required: false
103103
mithril_aggregator_allow_unparsable_block:
104-
description: If set no error is returned in case of unparsable block and an error log is written instead. Will be ignored on production networks.
104+
description: If set no error is returned in case of unparsable block and an error log is written instead. Will be ignored on (pre)production networks.
105105
required: false
106106
default: "false"
107107
prometheus_auth_username:

docs/website/root/manual/developer-docs/nodes/mithril-aggregator.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ Here is a list of the available parameters:
445445
| `signed_entity_types` | `--signed-entity-types` | - | `SIGNED_ENTITY_TYPES` | Signed entity types parameters (discriminants names in an ordered comma separated list) | - | `MithrilStakeDistribution,CardanoImmutableFilesFull,CardanoStakeDistribution` | - |
446446
| `snapshot_compression_algorithm` | `--snapshot-compression-algorithm` | - | `SNAPSHOT_COMPRESSION_ALGORITHM` | Compression algorithm of the snapshot archive | `zstandard` | `gzip` or `zstandard` | - |
447447
| `zstandard_parameters` | - | - | `ZSTANDARD_PARAMETERS__LEVEL` and `ZSTANDARD_PARAMETERS__NUMBER_OF_WORKERS` | Zstandard specific parameters | - | `{ level: 9, number_of_workers: 4 }` | - |
448-
| `allow_unparsable_block` | `--allow-unparsable-block` | - | `ALLOW_UNPARSABLE_BLOCK` | If set no error is returned in case of unparsable block and an error log is written instead. Will be ignored on production networks. | `false` | - | - |
448+
| `allow_unparsable_block` | `--allow-unparsable-block` | - | `ALLOW_UNPARSABLE_BLOCK` | If set no error is returned in case of unparsable block and an error log is written instead. Will be ignored on (pre)production networks. | `false` | - | - |
449449

450450
`genesis bootstrap` command:
451451

docs/website/root/manual/developer-docs/nodes/mithril-signer.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ Options:
165165
--allow-unparsable-block
166166
If set no error is returned in case of unparsable block and an error log is written instead.
167167

168-
Will be ignored on production networks.
168+
Will be ignored on (pre)production networks.
169169

170170
-h, --help
171171
Print help (see a summary with '-h')
@@ -251,4 +251,4 @@ Here is a list of the available parameters:
251251
| `enable_metrics_server` | `--enable-metrics-server` | - | `ENABLE_METRICS_SERVER` | Enable metrics HTTP server (Prometheus endpoint on /metrics) | `false` | - | - |
252252
| `metrics_server_ip` | `--metrics-server-ip` | - | `METRICS_SERVER_IP` | Metrics HTTP server IP | `0.0.0.0` | - | - |
253253
| `metrics_server_port` | `--metrics-server-port` | - | `METRICS_SERVER_PORT` | Metrics HTTP server listening port | `9090` | - | - |
254-
| `allow_unparsable_block` | `--allow-unparsable-block` | - | `ALLOW_UNPARSABLE_BLOCK` | If set no error is returned in case of unparsable block and an error log is written instead. Will be ignored on production networks. | `false` | - | - |
254+
| `allow_unparsable_block` | `--allow-unparsable-block` | - | `ALLOW_UNPARSABLE_BLOCK` | If set no error is returned in case of unparsable block and an error log is written instead. Will be ignored on (pre)production networks. | `false` | - | - |

mithril-aggregator/src/commands/serve_command.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub struct ServeCommand {
3939

4040
/// If set no error is returned in case of unparsable block and an error log is written instead.
4141
///
42-
/// Will be ignored on production networks.
42+
/// Will be ignored on (pre)production networks.
4343
#[clap(long)]
4444
allow_unparsable_block: bool,
4545
}

mithril-aggregator/src/configuration.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ pub struct Configuration {
150150

151151
/// If set no error is returned in case of unparsable block and an error log is written instead.
152152
///
153-
/// Will be ignored on production networks.
153+
/// Will be ignored on (pre)production networks.
154154
pub allow_unparsable_block: bool,
155155
}
156156

@@ -357,7 +357,7 @@ pub struct DefaultConfiguration {
357357

358358
/// If set no error is returned in case of unparsable block and an error log is written instead.
359359
///
360-
/// Will be ignored on production networks.
360+
/// Will be ignored on (pre)production networks.
361361
pub allow_unparsable_block: String,
362362
}
363363

mithril-aggregator/src/dependency_injection/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ impl DependenciesBuilder {
718718
self.get_logger().await?,
719719
self.configuration
720720
.get_network()?
721-
.allow_unparsable_block(self.configuration.allow_unparsable_block)?,
721+
.compute_allow_unparsable_block(self.configuration.allow_unparsable_block)?,
722722
);
723723

724724
Ok(Arc::new(transaction_parser))

mithril-common/src/entities/cardano_network.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,8 @@ impl CardanoNetwork {
7575
}
7676
}
7777

78-
/// Evaluate the possibility of validating the request to allow unparsable block or not,
79-
/// depending on the target Cardano network
80-
pub fn allow_unparsable_block(&self, allow_unparsable_block: bool) -> StdResult<bool> {
78+
/// Determines whether unparsable blocks should be allowed based on the specific Cardano network.
79+
pub fn compute_allow_unparsable_block(&self, allow_unparsable_block: bool) -> StdResult<bool> {
8180
let allow_unparsable_block = match self {
8281
CardanoNetwork::MainNet => false,
8382
CardanoNetwork::TestNet(id) if *id == PREPROD_MAGIC_ID => false,
@@ -158,68 +157,68 @@ mod tests {
158157
}
159158

160159
#[test]
161-
fn allow_unparsable_block_should_always_return_false_on_mainnet_and_preprod() {
160+
fn compute_allow_unparsable_block_should_always_return_false_on_mainnet_and_preprod() {
162161
let allow_unparsable_block = CardanoNetwork::MainNet
163-
.allow_unparsable_block(false)
162+
.compute_allow_unparsable_block(false)
164163
.unwrap();
165164
assert!(!allow_unparsable_block);
166165

167166
let allow_unparsable_block = CardanoNetwork::MainNet
168-
.allow_unparsable_block(true)
167+
.compute_allow_unparsable_block(true)
169168
.unwrap();
170169
assert!(!allow_unparsable_block);
171170

172171
let allow_unparsable_block = CardanoNetwork::TestNet(PREPROD_MAGIC_ID)
173-
.allow_unparsable_block(false)
172+
.compute_allow_unparsable_block(false)
174173
.unwrap();
175174
assert!(!allow_unparsable_block);
176175

177176
let allow_unparsable_block = CardanoNetwork::TestNet(PREPROD_MAGIC_ID)
178-
.allow_unparsable_block(true)
177+
.compute_allow_unparsable_block(true)
179178
.unwrap();
180179
assert!(!allow_unparsable_block);
181180
}
182181

183182
#[test]
184-
fn allow_unparsable_block_should_return_value_passed_in_parameter_on_all_networks_other_than_mainnet_and_preprod(
183+
fn compute_allow_unparsable_block_should_return_value_passed_in_parameter_on_all_networks_other_than_mainnet_and_preprod(
185184
) {
186185
let allow_unparsable_block = CardanoNetwork::TestNet(PREVIEW_MAGIC_ID)
187-
.allow_unparsable_block(false)
186+
.compute_allow_unparsable_block(false)
188187
.unwrap();
189188
assert!(!allow_unparsable_block);
190189

191190
let allow_unparsable_block = CardanoNetwork::TestNet(PREVIEW_MAGIC_ID)
192-
.allow_unparsable_block(true)
191+
.compute_allow_unparsable_block(true)
193192
.unwrap();
194193
assert!(allow_unparsable_block);
195194

196195
let allow_unparsable_block = CardanoNetwork::TestNet(SANCHONET_MAGIC_ID)
197-
.allow_unparsable_block(false)
196+
.compute_allow_unparsable_block(false)
198197
.unwrap();
199198
assert!(!allow_unparsable_block);
200199

201200
let allow_unparsable_block = CardanoNetwork::TestNet(SANCHONET_MAGIC_ID)
202-
.allow_unparsable_block(true)
201+
.compute_allow_unparsable_block(true)
203202
.unwrap();
204203
assert!(allow_unparsable_block);
205204

206205
let allow_unparsable_block = CardanoNetwork::TestNet(TESTNET_MAGIC_ID)
207-
.allow_unparsable_block(false)
206+
.compute_allow_unparsable_block(false)
208207
.unwrap();
209208
assert!(!allow_unparsable_block);
210209

211210
let allow_unparsable_block = CardanoNetwork::TestNet(TESTNET_MAGIC_ID)
212-
.allow_unparsable_block(true)
211+
.compute_allow_unparsable_block(true)
213212
.unwrap();
214213
assert!(allow_unparsable_block);
215214

216215
let allow_unparsable_block = CardanoNetwork::DevNet(123)
217-
.allow_unparsable_block(false)
216+
.compute_allow_unparsable_block(false)
218217
.unwrap();
219218
assert!(!allow_unparsable_block);
220219

221220
let allow_unparsable_block = CardanoNetwork::DevNet(123)
222-
.allow_unparsable_block(true)
221+
.compute_allow_unparsable_block(true)
223222
.unwrap();
224223
assert!(allow_unparsable_block);
225224
}

mithril-infra/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ variable "mithril_aggregator_cexplorer_pools_url" {
251251

252252
variable "mithril_aggregator_allow_unparsable_block" {
253253
type = bool
254-
description = "If set no error is returned in case of unparsable block and an error log is written instead. Will be ignored on production networks."
254+
description = "If set no error is returned in case of unparsable block and an error log is written instead. Will be ignored on (pre)production networks."
255255
default = false
256256
}
257257

mithril-signer/src/configuration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ pub struct Configuration {
9393

9494
/// If set no error is returned in case of unparsable block and an error log is written instead.
9595
///
96-
/// Will be ignored on production networks.
96+
/// Will be ignored on (pre)production networks.
9797
pub allow_unparsable_block: bool,
9898
}
9999

mithril-signer/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub struct Args {
7878

7979
/// If set no error is returned in case of unparsable block and an error log is written instead.
8080
///
81-
/// Will be ignored on production networks.
81+
/// Will be ignored on (pre)production networks.
8282
#[clap(long)]
8383
allow_unparsable_block: bool,
8484
}

0 commit comments

Comments
 (0)