Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
sdankel committed Jul 3, 2024
1 parent e5d5389 commit c85c247
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions forc-pkg/src/pkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use crate::{
source::{self, IPFSNode, Source},
BuildProfile,
};
use byte_unit::{Byte, UnitType};
use anyhow::{anyhow, bail, Context, Error, Result};
use byte_unit::{Byte, UnitType};
use forc_tracing::{println_action_green, println_warning};
use forc_util::{
default_output_directory, find_file_name, kebab_to_snake_case, print_compiling,
Expand Down Expand Up @@ -498,7 +498,11 @@ impl BuiltPackage {
let json_abi_path = output_dir.join(program_abi_stem).with_extension("json");
self.write_json_abi(&json_abi_path, minify)?;

debug!(" Bytecode size: {} bytes ({})", self.bytecode.bytes.len(), format_bytecode_size(self.bytecode.bytes.len()));
debug!(
" Bytecode size: {} bytes ({})",
self.bytecode.bytes.len(),
format_bytecode_size(self.bytecode.bytes.len())
);
// Additional ops required depending on the program type
match self.tree_type {
TreeType::Contract => {
Expand Down Expand Up @@ -2108,12 +2112,12 @@ fn profile_target_string(profile_name: &str, build_target: &BuildTarget) -> Stri
};
format!("{profile_name} [{}] target(s)", targets.join(" + "))
}
/// Returns the size of the bytecode in a human-readable format.
pub fn format_bytecode_size(bytes_len: usize) -> String {
let size = Byte::from_u64(bytes_len as u64);
let adjusted_byte = size.get_appropriate_unit(UnitType::Decimal);
adjusted_byte.to_string()
}
/// Returns the size of the bytecode in a human-readable format.
pub fn format_bytecode_size(bytes_len: usize) -> String {
let size = Byte::from_u64(bytes_len as u64);
let adjusted_byte = size.get_appropriate_unit(UnitType::Decimal);
adjusted_byte.to_string()
}

/// Check if the given node is a contract dependency of any node in the graph.
fn is_contract_dependency(graph: &Graph, node: NodeIx) -> bool {
Expand Down Expand Up @@ -2180,7 +2184,10 @@ pub fn build_with_options(build_options: &BuildOpts) -> Result<Built> {
},
)?;
let output_dir = pkg.output_directory.as_ref().map(PathBuf::from);
let total_size = built_packages.iter().map(|(_, pkg)| pkg.bytecode.bytes.len()).sum::<usize>();
let total_size = built_packages
.iter()
.map(|(_, pkg)| pkg.bytecode.bytes.len())
.sum::<usize>();

println_action_green(
"Finished",
Expand Down

0 comments on commit c85c247

Please sign in to comment.