mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 10:22:38 +00:00
Set Graffiti via CLI (#1320)
## Issue Addressed Closes #1319 ## Proposed Changes This issue: 1. Allows users to edit their Graffiti via the cli option `--graffiti`. If the graffiti is too long, lighthouse will not start and throw an error message. Otherwise, it will set the Graffiti to be the one provided by the user, right-padded with 0s. 2. Create a new `Graffiti` type and unify the code around it. With this type, everything is enforced at compile-time, and the code can be (I think...) panic-free! :) ## Additional info Currently, only `&str` are supported, as this is the returned type by `.arg("graffiti")`. Since this is user-input, I tried being as careful as I could. This is also why I created the `Graffiti` type, to make sure I could check as much as possible at compile time.
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
use clap::{App, Arg};
|
||||
|
||||
// Default text included in blocks.
|
||||
// Must be 32-bytes or will not build.
|
||||
//
|
||||
// |-------must be this long------|
|
||||
const DEFAULT_GRAFFITI: &str = "sigp/lighthouse-0.1.2-prerelease";
|
||||
|
||||
pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
App::new("beacon_node")
|
||||
.visible_aliases(&["b", "bn", "beacon"])
|
||||
@@ -227,4 +233,16 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
.long("purge-db")
|
||||
.help("If present, the chain database will be deleted. Use with caution.")
|
||||
)
|
||||
|
||||
/*
|
||||
* Misc.
|
||||
*/
|
||||
.arg(
|
||||
Arg::with_name("graffiti")
|
||||
.long("graffiti")
|
||||
.help("Specify your custom graffiti to be included in blocks.")
|
||||
.value_name("GRAFFITI")
|
||||
.default_value(DEFAULT_GRAFFITI)
|
||||
.takes_value(true)
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user