Skip to content

Commit

Permalink
mass calc params
Browse files Browse the repository at this point in the history
  • Loading branch information
smartgoo committed Dec 8, 2024
1 parent 6444a62 commit 6511686
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions wallet/core/src/bindings/python/tx/mass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ pub fn maximum_standard_transaction_mass() -> u64 {
pub fn calculate_unsigned_transaction_mass(network_id: &str, tx: &Transaction, minimum_signatures: Option<u16>) -> PyResult<u64> {
let network_id = NetworkId::from_str(network_id)?;
let consensus_params = Params::from(network_id);
let network_params = NetworkParams::from(network_id);
let mc = mass::MassCalculator::new(&consensus_params, &network_params);
let mc = mass::MassCalculator::new(&consensus_params);
Ok(mc.calc_overall_mass_for_unsigned_client_transaction(tx, minimum_signatures.unwrap_or(1))?)
}

Expand All @@ -25,8 +24,7 @@ pub fn calculate_unsigned_transaction_mass(network_id: &str, tx: &Transaction, m
pub fn update_unsigned_transaction_mass(network_id: &str, tx: &Transaction, minimum_signatures: Option<u16>) -> PyResult<bool> {
let network_id = NetworkId::from_str(network_id)?;
let consensus_params = Params::from(network_id);
let network_params = NetworkParams::from(network_id);
let mc = mass::MassCalculator::new(&consensus_params, network_params);
let mc = mass::MassCalculator::new(&consensus_params);
let mass = mc.calc_overall_mass_for_unsigned_client_transaction(tx, minimum_signatures.unwrap_or(1))?;
if mass > MAXIMUM_STANDARD_TRANSACTION_MASS {
Ok(false)
Expand All @@ -46,8 +44,7 @@ pub fn calculate_unsigned_transaction_fee(
) -> PyResult<Option<u64>> {
let network_id = NetworkId::from_str(network_id)?;
let consensus_params = Params::from(network_id);
let network_params = NetworkParams::from(network_id);
let mc = mass::MassCalculator::new(&consensus_params, network_params);
let mc = mass::MassCalculator::new(&consensus_params);
let mass = mc.calc_overall_mass_for_unsigned_client_transaction(tx, minimum_signatures.unwrap_or(1))?;
if mass > MAXIMUM_STANDARD_TRANSACTION_MASS {
Ok(None)
Expand Down

0 comments on commit 6511686

Please sign in to comment.