Skip to content

Commit

Permalink
update sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Coats committed Nov 15, 2023
1 parent bf84f47 commit 5a8262a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
30 changes: 15 additions & 15 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion src/analytics/influx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl Measurement for LedgerSizeMeasurement {
const NAME: &'static str = "iota_ledger_size";

fn add_fields(&self, query: WriteQuery) -> WriteQuery {
query.add_field("total_storage_cost", self.total_storage_cost)
query.add_field("total_storage_score", self.total_storage_score)
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/analytics/ledger/ledger_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use iota_sdk::types::block::{
output::{Output, Rent},
output::{Output, StorageScore},
protocol::ProtocolParameters,
};
use serde::{Deserialize, Serialize};
Expand All @@ -19,27 +19,27 @@ trait LedgerSize {
impl LedgerSize for Output {
fn ledger_size(&self, protocol_params: &ProtocolParameters) -> LedgerSizeMeasurement {
LedgerSizeMeasurement {
total_storage_cost: self.rent_cost(protocol_params.rent_structure()),
total_storage_score: self.storage_score(protocol_params.storage_score_parameters()),
}
}
}

/// Ledger size statistics.
#[derive(Copy, Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub(crate) struct LedgerSizeMeasurement {
pub(crate) total_storage_cost: u64,
pub(crate) total_storage_score: u64,
}

impl LedgerSizeMeasurement {
fn wrapping_add(&mut self, rhs: Self) {
*self = Self {
total_storage_cost: self.total_storage_cost.wrapping_add(rhs.total_storage_cost),
total_storage_score: self.total_storage_score.wrapping_add(rhs.total_storage_score),
}
}

fn wrapping_sub(&mut self, rhs: Self) {
*self = Self {
total_storage_cost: self.total_storage_cost.wrapping_sub(rhs.total_storage_cost),
total_storage_score: self.total_storage_score.wrapping_sub(rhs.total_storage_score),
}
}
}
Expand Down

0 comments on commit 5a8262a

Please sign in to comment.