Expand description
High-level storage helpers built on top of Client.
Wraps the postage-batch lifecycle so callers can think in terms of
(size, duration) instead of (amount, depth). The math comes
from crate::postage (depth/cost formulas) and crate::swarm
(Network for block time, Size for byte-count parsing).
Mirrors bee-js’s client.buy_storage / client.get_storage_cost.
Structs§
- Storage
Cost - Storage-cost preview returned by
get_storage_cost. - Storage
Options - Options for
buy_storage.networkshapes the per-block amount math;labelis the optional batch label;immutableselects an immutable batch.
Functions§
- buy_
storage - Preview + buy in one call: compute the cost via
get_storage_costand forward tocrate::postage::PostageApi::create_postage_batch. Returns the freshly-mintedBatchId. - calculate_
top_ up_ for_ bzz - Top-up amount (PLUR) needed for the batch to reach
target_bzztotal spend, using the chain’s current per-chunk price as the floor. Mirrors bee-jscalculateTopUpForBzz. - extend_
storage_ duration - Top up an existing batch by the per-chunk amount needed to extend
it for the given wall-clock
durationon the chosennetwork. The on-chain top-up amount iscurrent_price * blocks(duration). - extend_
storage_ size - Dilute (deepen) an existing batch so its effective capacity covers
new_size. No-op (returnsOk(())) if the batch is already deep enough. - get_
duration_ extension_ cost - Total cost (PLUR) of extending a batch by
durationonnetwork, given the current per-chunk price from/chainstate.current_price * blocks(duration) * 2^current_depth. - get_
size_ extension_ cost - Cost (PLUR) of growing a batch’s effective capacity to cover
new_size. The dilution cost equals(2^new_depth - 2^old_depth) * batch.amount. Returns0if the batch is already deep enough. - get_
storage_ cost - Compute the depth + amount for a
(size, duration)tuple, using the chain’s current price (PLUR/chunk/block) as the per-block price floor. Does not perform the purchase; pure preview.