Skip to content

Commit

Permalink
Fix Option<Duration> deserialization when None. (#10808)
Browse files Browse the repository at this point in the history
Apparently by default Option is deserialized to None when the field is
missing, but if you use `serde(with = ...)`, that behavior is gone. So
add `serde(default)` to bring that behavior back.
  • Loading branch information
robin-near authored Mar 25, 2024
1 parent 060016e commit 92e5938
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/chain-configs/src/client_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ pub struct DumpConfig {
/// How often to check if a new epoch has started.
/// Feel free to set to `None`, defaults are sensible.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default)]
#[serde(with = "near_async::time::serde_opt_duration_as_std")]
pub iteration_delay: Option<Duration>,
/// Location of a json file with credentials allowing write access to the bucket.
Expand Down
1 change: 1 addition & 0 deletions core/chain-configs/src/updateable_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ pub struct UpdateableClientConfig {
pub resharding_config: ReshardingConfig,

/// Time limit for adding transactions in produce_chunk()
#[serde(default)]
#[serde(with = "near_async::time::serde_opt_duration_as_std")]
pub produce_chunk_add_transactions_time_limit: Option<Duration>,
}
1 change: 1 addition & 0 deletions nearcore/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ pub struct Config {
/// A node produces a chunk by adding transactions from the transaction pool until
/// some limit is reached. This time limit ensures that adding transactions won't take
/// longer than the specified duration, which helps to produce the chunk quickly.
#[serde(default)]
#[serde(with = "near_async::time::serde_opt_duration_as_std")]
pub produce_chunk_add_transactions_time_limit: Option<Duration>,
/// Optional config for the Chunk Distribution Network feature.
Expand Down

0 comments on commit 92e5938

Please sign in to comment.