Skip to content

Commit 591a415

Browse files
authored
Merge pull request #771 from evoskuil/master
Make chain_state pointers const.
2 parents 6b496d5 + 42fc533 commit 591a415

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

include/bitcoin/node/chasers/chaser_organize.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class chaser_organize
5151
struct block_state
5252
{
5353
typename Block::cptr block;
54-
chain_state::ptr state;
54+
chain_state::cptr state;
5555
};
5656
using block_tree = std::unordered_map<system::hash_cref, block_state>;
5757
using header_links = std_vector<database::header_link>;
@@ -152,13 +152,13 @@ class chaser_organize
152152

153153
// Store Block into logical tree cache.
154154
void cache(const typename Block::cptr& block,
155-
const chain_state::ptr& state) NOEXCEPT;
155+
const chain_state::cptr& state) NOEXCEPT;
156156

157157
// Getters.
158158
// ------------------------------------------------------------------------
159159

160160
// Obtain chain state for given previous hash, nullptr if not found.
161-
chain_state::ptr get_chain_state(
161+
chain_state::cptr get_chain_state(
162162
const system::hash_digest& previous_hash) const NOEXCEPT;
163163

164164
// Sum of work from header to branch point (excluded).
@@ -183,7 +183,7 @@ class chaser_organize
183183

184184
// These are protected by strand.
185185
bool bumped_{};
186-
chain_state::ptr state_{};
186+
chain_state::cptr state_{};
187187

188188
// TODO: optimize, default bucket count is around 8.
189189
block_tree tree_{};

include/bitcoin/node/impl/chasers/chaser_organize.ipp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
namespace libbitcoin {
3030
namespace node {
3131

32-
BC_PUSH_WARNING(NO_NEW_OR_DELETE)
33-
3432
// Public
3533
// ----------------------------------------------------------------------------
3634

@@ -372,7 +370,7 @@ void CLASS::do_disorganize(header_t link) NOEXCEPT
372370

373371
using namespace system;
374372
const auto& header = get_header(*block);
375-
state.reset(new chain::chain_state{ *state, header, settings_ });
373+
state = to_shared<chain::chain_state>(*state, header, settings_);
376374
cache(block, state);
377375
}
378376

@@ -495,7 +493,7 @@ code CLASS::push_block(const system::hash_digest& key) NOEXCEPT
495493

496494
TEMPLATE
497495
void CLASS::cache(const typename Block::cptr& block,
498-
const chain_state::ptr& state) NOEXCEPT
496+
const chain_state::cptr& state) NOEXCEPT
499497
{
500498
tree_.emplace(system::hash_cref(block->get_hash()),
501499
block_state{ block, state });
@@ -505,7 +503,7 @@ void CLASS::cache(const typename Block::cptr& block,
505503
// ----------------------------------------------------------------------------
506504

507505
TEMPLATE
508-
CLASS::chain_state::ptr CLASS::get_chain_state(
506+
CLASS::chain_state::cptr CLASS::get_chain_state(
509507
const system::hash_digest& previous_hash) const NOEXCEPT
510508
{
511509
if (!state_)
@@ -638,8 +636,6 @@ void CLASS::log_state_change(const chain_state& from,
638636
}
639637
}
640638

641-
BC_POP_WARNING()
642-
643639
} // namespace node
644640
} // namespace libbitcoin
645641

0 commit comments

Comments
 (0)