/// Creates and initializes each validator owner and validator operator. This method creates all
/// the required accounts, sets the validator operators for each validator owner, and sets the
/// validator config on-chain.
Creates and initializes each validator owner and validator operator. This method creates all
the required accounts, sets the validator operators for each validator owner, and sets the
validator config on-chain.
Creates and initializes each validator owner and validator operator . This method creates all the required accounts sets the validator operators for each validator owner and sets the validator config on - chain .
fn create_and_initialize_owners_operators(
    session: &mut Session<StateViewCache>,
    operator_assignments: &[OperatorAssignment],
    operator_registrations: &[OperatorRegistration],
) {
    let libra_root_address = account_config::libra_root_address();
    // Create accounts for each validator owner
    for (owner_key, _) in operator_assignments {
        let owner_auth_key = AuthenticationKey::ed25519(&owner_key);
        let owner_account = account_address::from_public_key(owner_key);
        let create_owner_script = transaction_builder::encode_create_validator_account_script(
            owner_account,
            owner_auth_key.prefix().to_vec(),
        );
        exec_script(session, libra_root_address, &create_owner_script);
    }
    // Create accounts for each validator operator
    for (operator_key, _) in operator_registrations {
        let operator_auth_key = AuthenticationKey::ed25519(&operator_key);
        let operator_account = account_address::from_public_key(operator_key);
        let create_operator_script =
            transaction_builder::encode_create_validator_operator_account_script(
                operator_account,
                operator_auth_key.prefix().to_vec(),
            );
        exec_script(session, libra_root_address, &create_operator_script);
    }
    // Set the validator operator for each validator owner
    for (owner_key, assignment) in operator_assignments {
        let owner_account = account_address::from_public_key(owner_key);
        exec_script(session, owner_account, assignment);
    }
    // Set the validator config for each validator
    for (operator_key, registration) in operator_registrations {
        let operator_account = account_address::from_public_key(operator_key);
        exec_script(session, operator_account, registration);
    }
    // Add each validator to the validator set
    for (owner_key, _) in operator_assignments {
        let owner_account = account_address::from_public_key(owner_key);
        exec_function(
            session,
            libra_root_address,
            "LibraSystem",
            "add_validator",
            vec![],
            vec![
                Value::transaction_argument_signer_reference(libra_root_address),
                Value::address(owner_account),
            ],
        );
    }
}
fn create_and_initialize_owners_operators ( session : & mut Session < StateViewCache > , operator_assignments : & [ OperatorAssignment ] , operator_registrations : & [ OperatorRegistration ] , ) { let libra_root_address = account_config :: libra_root_address ( ) ; // Create accounts for each validator owner for ( owner_key , _ ) in operator_assignments { let owner_auth_key = AuthenticationKey :: ed25519 ( & owner_key ) ; let owner_account = account_address :: from_public_key ( owner_key ) ; let create_owner_script = transaction_builder :: encode_create_validator_account_script ( owner_account , owner_auth_key . prefix ( ) . to_vec ( ) , ) ; exec_script ( session , libra_root_address , & create_owner_script ) ; } // Create accounts for each validator operator for ( operator_key , _ ) in operator_registrations { let operator_auth_key = AuthenticationKey :: ed25519 ( & operator_key ) ; let operator_account = account_address :: from_public_key ( operator_key ) ; let create_operator_script = transaction_builder :: encode_create_validator_operator_account_script ( operator_account , operator_auth_key . prefix ( ) . to_vec ( ) , ) ; exec_script ( session , libra_root_address , & create_operator_script ) ; } // Set the validator operator for each validator owner for ( owner_key , assignment ) in operator_assignments { let owner_account = account_address :: from_public_key ( owner_key ) ; exec_script ( session , owner_account , assignment ) ; } // Set the validator config for each validator for ( operator_key , registration ) in operator_registrations { let operator_account = account_address :: from_public_key ( operator_key ) ; exec_script ( session , operator_account , registration ) ; } // Add each validator to the validator set for ( owner_key , _ ) in operator_assignments { let owner_account = account_address :: from_public_key ( owner_key ) ; exec_function ( session , libra_root_address , " " , " " , vec ! [ ] , vec ! [ Value transaction_argument_signer_reference ( libra_root_address ) Value address ( owner_account ) ] , ) ; } }
Creates and initializes each validator owner and validator operator.
Creates and initializes each validator owner and validator operator .
session
&mut Session<StateViewCache>
operator_assignments
&[OperatorAssignment]
operator_registrations
&[OperatorRegistration]