fn make_shard_server()

in fastpay/src/server.rs [15:66]


fn make_shard_server(
    local_ip_addr: &str,
    server_config_path: &str,
    committee_config_path: &str,
    initial_accounts_config_path: &str,
    buffer_size: usize,
    cross_shard_queue_size: usize,
    shard: u32,
) -> network::Server {
    let server_config =
        AuthorityServerConfig::read(server_config_path).expect("Fail to read server config");
    let committee_config =
        CommitteeConfig::read(committee_config_path).expect("Fail to read committee config");
    let initial_accounts_config = InitialStateConfig::read(initial_accounts_config_path)
        .expect("Fail to read initial account config");

    let committee = Committee::new(committee_config.voting_rights());
    let num_shards = server_config.authority.num_shards;

    let mut state = AuthorityState::new_shard(
        committee,
        server_config.authority.address,
        server_config.key.copy(),
        shard,
        num_shards,
    );

    // Load initial states
    for (address, balance) in &initial_accounts_config.accounts {
        if AuthorityState::get_shard(num_shards, address) != shard {
            continue;
        }
        let client = AccountOffchainState {
            balance: *balance,
            next_sequence_number: SequenceNumber::from(0),
            pending_confirmation: None,
            confirmed_log: Vec::new(),
            synchronization_log: Vec::new(),
            received_log: Vec::new(),
        };
        state.accounts.insert(*address, client);
    }

    network::Server::new(
        server_config.authority.network_protocol,
        local_ip_addr.to_string(),
        server_config.authority.base_port,
        state,
        buffer_size,
        cross_shard_queue_size,
    )
}