MCPcopy Create free account
hub / github.com/ChainSafe/Delorean-Protocol / add_validator

Function add_validator

fendermint/app/src/cmd/genesis.rs:163–177  ·  view source on GitHub ↗
(genesis_file: &PathBuf, args: &GenesisAddValidatorArgs)

Source from the content-addressed store, hash-verified

161}
162
163fn add_validator(genesis_file: &PathBuf, args: &GenesisAddValidatorArgs) -> anyhow::Result<()> {
164 update_genesis(genesis_file, |mut genesis| {
165 let pk = read_public_key(&args.public_key)?;
166 let vk = ValidatorKey(pk);
167 if genesis.validators.iter().any(|v| v.public_key == vk) {
168 return Err(anyhow!("account already exists in the genesis file"));
169 }
170 let validator = Validator {
171 public_key: vk,
172 power: Collateral(args.power.clone()),
173 };
174 genesis.validators.push(validator);
175 Ok(genesis)
176 })
177}
178
179fn read_genesis(genesis_file: &PathBuf) -> anyhow::Result<Genesis> {
180 let json = std::fs::read_to_string(genesis_file).context("failed to read genesis")?;

Callers

nothing calls this directly

Calls 4

update_genesisFunction · 0.85
read_public_keyFunction · 0.85
CollateralClass · 0.85
ValidatorKeyClass · 0.50

Tested by

no test coverage detected