Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix log level filtering rewarding lib #1094

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

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

19 changes: 9 additions & 10 deletions rs/dre-canisters/node-provider-rewards-lib/src/v1_logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ impl fmt::Display for LogEntry {
}
}

#[derive(Copy, Clone)]
pub enum LogLevel {
Info,
Debug,
Expand Down Expand Up @@ -212,15 +213,13 @@ impl RewardsLog {
result
}

pub fn get_log(&self) -> Vec<String> {
let mut log = Vec::new();

for (level, entry) in self.entries.iter() {
match level {
LogLevel::Info => log.push(format!("{}: {} ", level, entry)),
_ => continue,
}
}
log
pub fn get_log(&self, level: LogLevel) -> Vec<String> {
self.entries
.iter()
.filter_map(move |(entry_log_level, entry)| match (level, entry_log_level) {
(LogLevel::Info, LogLevel::Debug) => None,
_ => Some(format!("{}: {} ", level, entry)),
})
.collect_vec()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use ic_nns_governance_api::pb::v1::MonthlyNodeProviderRewards;
use ic_protobuf::registry::node_rewards::{v2::NodeRewardRate, v2::NodeRewardsTable};
use ic_registry_keys::NODE_REWARDS_TABLE_KEY;
use itertools::Itertools;
use node_provider_rewards_lib::v1_logs::LogLevel;
use node_provider_rewards_lib::{
v1_rewards::{assigned_nodes_multiplier, calculate_rewards},
v1_types::{AHashMap, DailyNodeMetrics as NPRDailyNodeMetrics},
Expand Down Expand Up @@ -135,7 +136,7 @@ pub fn node_provider_rewards(node_provider_id: Principal, rewarding_period: Date
node_provider_id,
rewards_xdr_permyriad: rewards_ammount.xdr_permyriad,
rewards_xdr_permyriad_no_reduction: rewards_ammount.xdr_permyriad_no_reduction,
computation_log: rewards.rewards_log_per_node_provider.get(&np_id).unwrap().get_log(),
computation_log: rewards.rewards_log_per_node_provider.get(&np_id).unwrap().get_log(LogLevel::Info),
rewards_xdr_old,
ts_distribution: latest_np_rewards.timestamp,
xdr_conversion_rate: latest_np_rewards.xdr_conversion_rate.and_then(|rate| rate.xdr_permyriad_per_icp),
Expand Down
Loading