Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
aspect committed Sep 26, 2024
1 parent 5993abb commit c8d829c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 31 deletions.
25 changes: 5 additions & 20 deletions wallet/core/src/tx/generator/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,6 @@ fn test_generator_inputs_250k_outputs_2_sweep() -> Result<()> {
Ok(())
}


#[test]
fn test_generator_fan_out_1() -> Result<()> {
use kaspa_consensus_core::mass::calc_storage_mass;
Expand All @@ -788,35 +787,21 @@ fn test_generator_fan_out_1() -> Result<()> {

let storage_mass = calc_storage_mass(
false,
[
100000000,
8723579967,
].into_iter(),
[
20000000,
25000000,
31000000,
].into_iter(),
[100000000, 8723579967].into_iter(),
[20000000, 25000000, 31000000].into_iter(),
network_params.kip9_version,
consensus_params.storage_mass_parameter,
);

println!("storage_mass: {:?}", storage_mass);

generator(test_network_id(), &[
// 10000000.0 * 1e-8,
// 10000000.0 * 1e-8,
// 100000000.0 * 1e-8,
// ---
1.00000000,
1.00000000,
87.23579967,
], &[], Fees::sender(Kaspa(1.0)), [
], &[], None, Fees::sender(Kaspa(1.0)), [
(output_address, Kaspa(0.20000000)),
(output_address, Kaspa(0.25000000)),
(output_address, Kaspa(0.21000000)),
// (output_address, Sompi(20000000)),
// (output_address, Sompi(25000000)),
// (output_address, Sompi(31000000)),
].as_slice())
.unwrap()
.harness()
Expand All @@ -832,4 +817,4 @@ fn test_generator_fan_out_1() -> Result<()> {
.finalize();

Ok(())
}
}
15 changes: 4 additions & 11 deletions wallet/core/src/wasm/tx/mass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use kaspa_consensus_client::*;
use kaspa_consensus_core::config::params::Params;
use kaspa_consensus_core::mass::calc_storage_mass;
use kaspa_consensus_core::network::{NetworkId, NetworkIdT};
use kaspa_wallet_pskt::input;
use kaspa_wasm_core::types::NumberArray;
use wasm_bindgen::prelude::*;
use workflow_wasm::convert::*;
Expand Down Expand Up @@ -101,25 +100,19 @@ pub fn calculate_unsigned_transaction_fee(
}
}


/// `calculateStorageMass()` is a helper function to compute the storage mass of inputs and outputs.
/// This function can be use to calculate the storage mass of transaction inputs and outputs.
/// Note that the storage mass is only a component of the total transaction mass. You are not
/// meant to use this function by itself and should use `calculateTransactionMass()` instead.
/// This function purely exists for diagnostic purposes and to help with complex algorithms that
/// may require a manual UTXO selection for identifying UTXOs and outputs needed for low storage mass.
///
///
/// @category Wallet SDK
/// @see {@link maximumStandardTransactionMass}
/// @see {@link calculateTransactionMass}
///
///
#[wasm_bindgen(js_name = calculateStorageMass)]
pub fn calculate_storage_mass(
network_id: NetworkIdT,
input_values : &NumberArray,
output_values : &NumberArray,
) -> Result<Option<u64>> {

pub fn calculate_storage_mass(network_id: NetworkIdT, input_values: &NumberArray, output_values: &NumberArray) -> Result<Option<u64>> {
let network_id = NetworkId::try_owned_from(network_id)?;
let consensus_params = Params::from(network_id);
let network_params = NetworkParams::from(network_id);
Expand All @@ -136,4 +129,4 @@ pub fn calculate_storage_mass(
);

Ok(storage_mass)
}
}

0 comments on commit c8d829c

Please sign in to comment.