-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dashmate): configure proposer and tx limits (#2057)
- Loading branch information
Showing
15 changed files
with
153 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
mod serialization; | ||
mod spawn; | ||
|
||
pub use serialization::from_opt_str_or_number; | ||
pub use serialization::from_str_or_number; | ||
pub use spawn::spawn_blocking_task_with_name_if_supported; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use serde::Deserialize; | ||
|
||
/// Deserialize a value from a string or a number. | ||
pub fn from_str_or_number<'de, D, T>(deserializer: D) -> Result<T, D::Error> | ||
where | ||
D: serde::Deserializer<'de>, | ||
T: serde::Deserialize<'de> + std::str::FromStr, | ||
<T as std::str::FromStr>::Err: std::fmt::Display, | ||
{ | ||
use serde::de::Error; | ||
|
||
let s = String::deserialize(deserializer)?; | ||
s.parse::<T>().map_err(Error::custom) | ||
} | ||
|
||
/// Deserialize a value from an optional string or a number | ||
pub fn from_opt_str_or_number<'de, D, T>(deserializer: D) -> Result<Option<T>, D::Error> | ||
where | ||
D: serde::Deserializer<'de>, | ||
T: serde::Deserialize<'de> + std::str::FromStr, | ||
<T as std::str::FromStr>::Err: std::fmt::Display, | ||
{ | ||
use serde::de::Error; | ||
|
||
let s = Option::<String>::deserialize(deserializer)?; | ||
match s { | ||
Some(s) => { | ||
if s.is_empty() { | ||
Ok(None) | ||
} else { | ||
s.parse::<T>().map(Some).map_err(Error::custom) | ||
} | ||
} | ||
None => Ok(None), | ||
} | ||
} |