1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use diem_global_constants::OWNER_ACCOUNT;
use diem_management::{constants, error::Error, secure_backend::SharedBackend};
use diem_types::{network_address::NetworkAddress, transaction::Transaction};
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
pub struct ValidatorConfig {
#[structopt(long)]
owner_name: String,
#[structopt(flatten)]
validator_config: diem_management::validator_config::ValidatorConfig,
#[structopt(long)]
validator_address: NetworkAddress,
#[structopt(long)]
fullnode_address: NetworkAddress,
#[structopt(flatten)]
shared_backend: SharedBackend,
#[structopt(long, help = "Disables network address validation")]
disable_address_validation: bool,
}
impl ValidatorConfig {
pub fn execute(self) -> Result<Transaction, Error> {
let config = self
.validator_config
.config()?
.override_shared_backend(&self.shared_backend.shared_backend)?;
let owner_account =
diem_config::utils::validator_owner_account_from_name(self.owner_name.as_bytes());
let mut validator_storage = config.validator_backend();
validator_storage.set(OWNER_ACCOUNT, owner_account)?;
let txn = self.validator_config.build_transaction(
0,
self.fullnode_address,
self.validator_address,
false,
self.disable_address_validation,
)?;
let mut shared_storage = config.shared_backend();
shared_storage.set(constants::VALIDATOR_CONFIG, txn.clone())?;
Ok(txn)
}
}