Refine from pedantic, remove erratic consts

This commit is contained in:
Luke Parker
2023-07-08 01:26:08 -04:00
parent 286e96ccd8
commit 3ca76c51e4
36 changed files with 192 additions and 335 deletions

View File

@@ -25,7 +25,7 @@ struct SignableTransactionBuilderInternal {
impl SignableTransactionBuilderInternal {
// Takes in the change address so users don't miss that they have to manually set one
// If they don't, all leftover funds will become part of the fee
const fn new(protocol: Protocol, fee: Fee, change_address: Option<Change>) -> Self {
fn new(protocol: Protocol, fee: Fee, change_address: Option<Change>) -> Self {
Self {
protocol,
fee,
@@ -91,7 +91,6 @@ impl SignableTransactionBuilder {
Self(self.0.clone())
}
#[must_use]
pub fn new(protocol: Protocol, fee: Fee, change_address: Option<Change>) -> Self {
Self(Arc::new(RwLock::new(SignableTransactionBuilderInternal::new(
protocol,

View File

@@ -211,7 +211,6 @@ pub struct Fee {
}
impl Fee {
#[must_use]
pub fn calculate(&self, weight: usize) -> u64 {
((((self.per_weight * u64::try_from(weight).unwrap()) - 1) / self.mask) + 1) * self.mask
}
@@ -262,7 +261,6 @@ impl fmt::Debug for Change {
impl Change {
/// Create a change output specification from a ViewPair, as needed to maintain privacy.
#[must_use]
pub fn new(view: &ViewPair, guaranteed: bool) -> Self {
Self {
address: view.address(
@@ -280,7 +278,6 @@ impl Change {
/// Create a fingerprintable change output specification which will harm privacy.
///
/// Only use this if you know what you're doing.
#[must_use]
pub const fn fingerprintable(address: MoneroAddress) -> Self {
Self { address, view: None }
}
@@ -394,8 +391,7 @@ impl SignableTransaction {
Ok(Self { protocol, r_seed, inputs, payments, data, fee })
}
#[must_use]
pub const fn fee(&self) -> u64 {
pub fn fee(&self) -> u64 {
self.fee
}
@@ -568,7 +564,6 @@ impl SignableTransaction {
/// The eventuality is defined as the TX extra/outputs this transaction will create, if signed
/// with the specified seed. This eventuality can be compared to on-chain transactions to see
/// if the transaction has already been signed and published.
#[must_use]
pub fn eventuality(&self) -> Option<Eventuality> {
let inputs = self.inputs.iter().map(SpendableOutput::key).collect::<Vec<_>>();
let (tx_key, additional, outputs, id) = Self::prepare_payments(
@@ -726,7 +721,6 @@ impl Eventuality {
///
/// This extra may be used with a transaction with a distinct set of inputs, yet no honest
/// transaction which doesn't satisfy this Eventuality will contain it.
#[must_use]
pub fn extra(&self) -> &[u8] {
&self.extra
}
@@ -817,7 +811,6 @@ impl Eventuality {
write_vec(write_byte, &self.extra, w)
}
#[must_use]
pub fn serialize(&self) -> Vec<u8> {
let mut buf = Vec::with_capacity(128);
self.write(&mut buf).unwrap();