Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Salka1988 committed Oct 10, 2023
1 parent e1e548e commit e8a28db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
6 changes: 3 additions & 3 deletions packages/fuels-test-helpers/src/fuel_bin_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use fuel_core_services::Service as ServiceTrait;
use fuel_core_client::client::FuelClient;
use std::{net::SocketAddr, path::PathBuf, pin::Pin, time::Duration};

use crate::node_types::{Config, DbType, Trigger, DEFAULT_CACHE_SIZE};
use crate::node_types::{Config, DbType, Trigger};
use portpicker::{is_free, pick_unused_port};
use tokio::{process::Command, spawn, task::JoinHandle, time::sleep};

Expand Down Expand Up @@ -51,9 +51,9 @@ impl ExtendedConfig {
}
}

if self.config.max_database_cache_size != DEFAULT_CACHE_SIZE {
if let Some(cache_size) = self.config.max_database_cache_size {
args.push("--max-database-cache-size".to_string());
args.push(self.config.max_database_cache_size.to_string());
args.push(cache_size.to_string());
}

if self.config.utxo_validation {
Expand Down
10 changes: 4 additions & 6 deletions packages/fuels-test-helpers/src/node_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ use serde::{de::Error as SerdeError, Deserializer, Serializer};

use serde_with::{DeserializeAs, SerializeAs};

pub const DEFAULT_CACHE_SIZE: usize = 10 * 1024 * 1024;

#[derive(Clone, Debug)]
pub enum Trigger {
Instant,
Expand Down Expand Up @@ -61,7 +59,7 @@ impl From<DbType> for fuel_core::service::DbType {
#[derive(Clone, Debug)]
pub struct Config {
pub addr: SocketAddr,
pub max_database_cache_size: usize,
pub max_database_cache_size: Option<usize>,
pub database_type: DbType,
pub utxo_validation: bool,
pub manual_blocks_enabled: bool,
Expand All @@ -75,7 +73,7 @@ impl Config {
pub fn local_node() -> Self {
Self {
addr: SocketAddr::new(Ipv4Addr::new(127, 0, 0, 1).into(), 0),
max_database_cache_size: DEFAULT_CACHE_SIZE,
max_database_cache_size: Some(10 * 1024 * 1024),
database_type: DbType::InMemory,
utxo_validation: false,
manual_blocks_enabled: false,
Expand All @@ -91,7 +89,7 @@ impl Default for Config {
fn default() -> Self {
Self {
addr: SocketAddr::new(Ipv4Addr::new(127, 0, 0, 1).into(), 0),
max_database_cache_size: DEFAULT_CACHE_SIZE,
max_database_cache_size: Some(10 * 1024 * 1024),
database_type: DbType::InMemory,
utxo_validation: false,
manual_blocks_enabled: false,
Expand All @@ -108,7 +106,7 @@ impl From<Config> for fuel_core::service::Config {
fn from(value: Config) -> Self {
Self {
addr: value.addr,
max_database_cache_size: value.max_database_cache_size,
max_database_cache_size: value.max_database_cache_size.unwrap_or(10 * 1024 * 1024),
database_path: match &value.database_type {
DbType::InMemory => Default::default(),
DbType::RocksDb(path) => path.clone().unwrap_or_default(),
Expand Down

0 comments on commit e8a28db

Please sign in to comment.