From a304dd5617e82f4a176008c43eef79131a0f3736 Mon Sep 17 00:00:00 2001 From: clemahieu Date: Thu, 4 Apr 2024 10:04:05 +0200 Subject: [PATCH] Adding const to ledger::weight* functions. (#4534) --- nano/secure/ledger.cpp | 4 ++-- nano/secure/ledger.hpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/nano/secure/ledger.cpp b/nano/secure/ledger.cpp index ab13ca171..a59c46099 100644 --- a/nano/secure/ledger.cpp +++ b/nano/secure/ledger.cpp @@ -981,7 +981,7 @@ std::pair nano::ledger::hash_root_random (st } // Vote weight of an account -nano::uint128_t nano::ledger::weight (nano::account const & account_a) +nano::uint128_t nano::ledger::weight (nano::account const & account_a) const { if (check_bootstrap_weights.load ()) { @@ -1001,7 +1001,7 @@ nano::uint128_t nano::ledger::weight (nano::account const & account_a) return cache.rep_weights.representation_get (account_a); } -nano::uint128_t nano::ledger::weight_exact (store::transaction const & txn_a, nano::account const & representative_a) +nano::uint128_t nano::ledger::weight_exact (store::transaction const & txn_a, nano::account const & representative_a) const { return store.rep_weight.get (txn_a, representative_a); } diff --git a/nano/secure/ledger.hpp b/nano/secure/ledger.hpp index e754b7a91..a3e7f127a 100644 --- a/nano/secure/ledger.hpp +++ b/nano/secure/ledger.hpp @@ -50,11 +50,11 @@ public: * If the weight is below the cache limit it returns 0. * During bootstrap it returns the preconfigured bootstrap weights. */ - nano::uint128_t weight (nano::account const &); + nano::uint128_t weight (nano::account const &) const; std::optional successor (store::transaction const &, nano::qualified_root const &) const noexcept; std::optional successor (store::transaction const & transaction, nano::block_hash const & hash) const noexcept; /* Returns the exact vote weight for the given representative by doing a database lookup */ - nano::uint128_t weight_exact (store::transaction const &, nano::account const &); + nano::uint128_t weight_exact (store::transaction const &, nano::account const &) const; std::shared_ptr forked_block (store::transaction const &, nano::block const &); std::shared_ptr head_block (store::transaction const &, nano::account const &); bool block_confirmed (store::transaction const &, nano::block_hash const &) const; @@ -105,7 +105,7 @@ public: nano::stats & stats; std::unordered_map bootstrap_weights; uint64_t bootstrap_weight_max_blocks{ 1 }; - std::atomic check_bootstrap_weights; + mutable std::atomic check_bootstrap_weights; bool pruning{ false }; private: