Skip to content

Commit

Permalink
feat: turn on event validation by default (#562)
Browse files Browse the repository at this point in the history
* feat: turn on event validation by default

* fix: clap is weirs with bools, we need to parse them and explicitly define an action on them to set them

* fix: use option in event_validation flag

* chore: add comment and set default_value to true, using default_value_t=Some(true) will break the code. The default_value_t cannot be used here : The default_value_t attribute in Clap requires the type to implement Display because it needs to be able to print the default value in the help text. However, Option<T> does not implement Display, even if T does. To work around this, we use default_value instead This works because Clap will parse the string true into a bool and then wrap it in Some(...). We have additionally also handled this in the code parsing using an unwrap_or(). The default_value is added more for semantic purposes to aid readability of the code

---------

Co-authored-by: Samika Kashyap <[email protected]>
  • Loading branch information
samika98 and Samika Kashyap authored Oct 24, 2024
1 parent af3c6f0 commit 0b0e5ae
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions one/src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,10 @@ pub struct DaemonOpts {
)]
authentication: bool,

/// Enable event validation; Requires using the experimental-features flag
#[arg(
long,
default_value_t = false,
env = "CERAMIC_ONE_EVENT_VALIDATION",
requires = "experimental_features"
)]
event_validation: bool,
/// Enable event validation, true by default
/// default value in args is added here for readability, removal of this param does not change the behavior
#[arg(long, default_value = "true", env = "CERAMIC_ONE_EVENT_VALIDATION")]
event_validation: Option<bool>,

/// Flight SQL bind address; Requires using the experimental-features flag
#[arg(
Expand Down Expand Up @@ -337,16 +333,10 @@ pub async fn run(opts: DaemonOpts) -> Result<()> {

// Construct services from pool
let interest_svc = Arc::new(InterestService::new(sqlite_pool.clone()));
let event_validation = opts.event_validation.unwrap_or(true);
let event_svc = Arc::new(
EventService::try_new(
sqlite_pool.clone(),
true,
opts.event_validation,
rpc_providers,
)
.await?,
EventService::try_new(sqlite_pool.clone(), true, event_validation, rpc_providers).await?,
);

let network = opts.network.to_network(&opts.local_network_id)?;

// Setup tokio-metrics
Expand Down

0 comments on commit 0b0e5ae

Please sign in to comment.