mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-07-21 15:19:29 +00:00
fix(wallet): suggestions 3
This commit is contained in:
parent
a0971018ea
commit
eaa76f5e7e
@ -154,8 +154,8 @@ pub unsafe extern "C" fn wallet_ffi_create_new(
|
||||
/// This loads a wallet that was previously created with `wallet_ffi_create_new()`.
|
||||
///
|
||||
/// # Parameters
|
||||
/// - `handle` - Valid wallet handle
|
||||
/// - `config_path`: Path to the wallet configuration file (JSON)
|
||||
/// - `storage_path`: Path to the wallet storage (JSON)
|
||||
/// - `statistics_path`: Path to the wallet statistics file (JSON)
|
||||
///
|
||||
/// # Returns
|
||||
@ -164,7 +164,6 @@ pub unsafe extern "C" fn wallet_ffi_create_new(
|
||||
///
|
||||
/// # Safety
|
||||
/// All string parameters must be valid null-terminated UTF-8 strings.
|
||||
/// `handle` must be a valid wallet handle from `wallet_ffi_create_new` or `wallet_ffi_open`.
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn wallet_ffi_open(
|
||||
config_path: *const c_char,
|
||||
|
||||
@ -1633,8 +1633,8 @@ struct FfiCreateWalletOutput wallet_ffi_create_new(const char *config_path,
|
||||
* This loads a wallet that was previously created with `wallet_ffi_create_new()`.
|
||||
*
|
||||
* # Parameters
|
||||
* - `handle` - Valid wallet handle
|
||||
* - `config_path`: Path to the wallet configuration file (JSON)
|
||||
* - `storage_path`: Path to the wallet storage (JSON)
|
||||
* - `statistics_path`: Path to the wallet statistics file (JSON)
|
||||
*
|
||||
* # Returns
|
||||
@ -1643,7 +1643,6 @@ struct FfiCreateWalletOutput wallet_ffi_create_new(const char *config_path,
|
||||
*
|
||||
* # Safety
|
||||
* All string parameters must be valid null-terminated UTF-8 strings.
|
||||
* `handle` must be a valid wallet handle from `wallet_ffi_create_new` or `wallet_ffi_open`.
|
||||
*/
|
||||
struct WalletHandle *wallet_ffi_open(const char *config_path,
|
||||
const char *storage_path,
|
||||
|
||||
@ -7,6 +7,8 @@ use log::warn;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
const DEFAULT_CALLIBRATION_LIMIT: usize = 100;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct SequencerConnectionData {
|
||||
/// Connection data of all known sequencers.
|
||||
@ -49,6 +51,7 @@ pub struct WalletConfig {
|
||||
/// Max amount of blocks to poll in one request.
|
||||
pub seq_block_poll_max_amount: u64,
|
||||
/// Limit number of sequencer polls during calibration, should not be zero
|
||||
#[serde(default = "default_calibration_limit")]
|
||||
pub calibration_limit: usize,
|
||||
}
|
||||
|
||||
@ -63,7 +66,7 @@ impl Default for WalletConfig {
|
||||
seq_tx_poll_max_blocks: 5,
|
||||
seq_poll_max_retries: 5,
|
||||
seq_block_poll_max_amount: 100,
|
||||
calibration_limit: 100,
|
||||
calibration_limit: DEFAULT_CALLIBRATION_LIMIT,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -151,3 +154,7 @@ impl WalletConfig {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const fn default_calibration_limit() -> usize {
|
||||
DEFAULT_CALLIBRATION_LIMIT
|
||||
}
|
||||
|
||||
@ -213,17 +213,11 @@ impl MultiSequencerClient {
|
||||
resp
|
||||
}
|
||||
|
||||
/// Update statistics of a leader, clear statist updates log.
|
||||
pub async fn update_statistics(&self, leader_statistic: &mut Statistics) {
|
||||
{
|
||||
let statistic_updates = self.statistic_updates.read().await;
|
||||
leader_statistic.apply_updates(statistic_updates.as_ref());
|
||||
}
|
||||
|
||||
// Clear updates
|
||||
{
|
||||
let mut statistic_updates = self.statistic_updates.write().await;
|
||||
statistic_updates.clear();
|
||||
}
|
||||
let mut statistic_updates = self.statistic_updates.write().await;
|
||||
leader_statistic.apply_updates(statistic_updates.as_ref());
|
||||
statistic_updates.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@ -368,10 +362,8 @@ pub fn choose_leader(
|
||||
client_list: &HashMap<Url, SequencerClient>,
|
||||
statistics: &HashMap<Url, Statistics>,
|
||||
) -> Option<(Url, SequencerClient)> {
|
||||
let mut client_vec = vec![];
|
||||
|
||||
// Sort out all unmetered clients
|
||||
client_vec = client_list
|
||||
let mut client_vec: Vec<_> = client_list
|
||||
.keys()
|
||||
.filter(|item| statistics.contains_key(*item))
|
||||
.collect();
|
||||
|
||||
@ -203,7 +203,7 @@ pub fn wallet_config(sequencer_addr: SocketAddr) -> Result<WalletConfig> {
|
||||
seq_tx_poll_max_blocks: 15,
|
||||
seq_poll_max_retries: 10,
|
||||
seq_block_poll_max_amount: 100,
|
||||
calibration_limit: 1,
|
||||
calibration_limit: 5,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user