Struct ckb_sdk::tx_builder::CapacityBalancer
source · pub struct CapacityBalancer {
pub fee_rate: FeeRate,
pub capacity_provider: CapacityProvider,
pub change_lock_script: Option<Script>,
pub force_small_change_as_fee: Option<u64>,
}Expand description
Transaction capacity balancer config
Fields§
§fee_rate: FeeRate§capacity_provider: CapacityProviderSearch cell by this lock script and filter out cells with data or with type script or not mature.
change_lock_script: Option<Script>Change cell’s lock script if None use capacity_provider’s first lock script
force_small_change_as_fee: Option<u64>When there is no more inputs for create a change cell to balance the transaction capacity, force the addition capacity as fee, the value is actual maximum transaction fee.
Implementations§
source§impl CapacityBalancer
impl CapacityBalancer
pub fn new_simple(
capacity_provider: Script,
placeholder_witness: WitnessArgs,
fee_rate: u64
) -> CapacityBalancer
sourcepub fn new_simple_with_since(
capacity_provider: Script,
placeholder_witness: WitnessArgs,
since_source: SinceSource,
fee_rate: u64
) -> CapacityBalancer
pub fn new_simple_with_since(
capacity_provider: Script,
placeholder_witness: WitnessArgs,
since_source: SinceSource,
fee_rate: u64
) -> CapacityBalancer
Create new simple capacity balancer with since source.
pub fn new_with_provider(
fee_rate: u64,
capacity_provider: CapacityProvider
) -> Self
sourcepub fn set_max_fee(&mut self, max_fee: Option<u64>)
pub fn set_max_fee(&mut self, max_fee: Option<u64>)
Set or clear the force_small_change_as_fee
pub fn balance_tx_capacity(
&mut self,
tx: &TransactionView,
cell_collector: &mut dyn CellCollector,
tx_dep_provider: &dyn TransactionDependencyProvider,
cell_dep_resolver: &dyn CellDepResolver,
header_dep_resolver: &dyn HeaderDepResolver
) -> Result<TransactionView, BalanceTxCapacityError>
pub fn rebalance_tx_capacity(
&self,
tx: &TransactionView,
cell_collector: &mut dyn CellCollector,
tx_dep_provider: &dyn TransactionDependencyProvider,
cell_dep_resolver: &dyn CellDepResolver,
header_dep_resolver: &dyn HeaderDepResolver,
accepted_min_fee: u64,
change_index: Option<usize>
) -> Result<(TransactionView, Option<usize>), BalanceTxCapacityError>
pub fn check_cycle_fee(
&self,
tx: TransactionView,
cell_collector: &mut dyn CellCollector,
tx_dep_provider: &dyn TransactionDependencyProvider,
cell_dep_resolver: &dyn CellDepResolver,
header_dep_resolver: &dyn HeaderDepResolver,
change_index: Option<usize>
) -> Result<(TransactionView, Option<usize>, bool), BalanceTxCapacityError>
Trait Implementations§
source§impl Clone for CapacityBalancer
impl Clone for CapacityBalancer
source§fn clone(&self) -> CapacityBalancer
fn clone(&self) -> CapacityBalancer
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more