Skip to content

Commit a33a9c7

Browse files
authored
Merge pull request #711 from evoskuil/master
Add context to block.populate for bip68 check.
2 parents baa8955 + 21c03f1 commit a33a9c7

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

include/bitcoin/node/chasers/chaser_block.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ class BCN_API chaser_block
6868

6969
private:
7070
void set_prevout(const system::chain::input& input) const NOEXCEPT;
71-
void populate(const system::chain::block& block) const NOEXCEPT;
71+
bool populate(const system::chain::block& block,
72+
const system::chain::context& ctx) const NOEXCEPT;
7273
};
7374

7475
} // namespace node

src/chasers/chaser_block.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,11 @@ code chaser_block::validate(const block& block,
117117
return ec;
118118
}
119119

120-
// Populate prevouts from self/tree/store (metadata not required).
121-
populate(block);
120+
// Populate prevouts from self/tree (metadata not required).
121+
if (!populate(block, ctx))
122+
return system::error::relative_time_locked;
123+
124+
// Populate prevouts from store (metadata not required).
122125
if (!archive().populate(block))
123126
return network::error::protocol_violation;
124127

@@ -178,15 +181,20 @@ void chaser_block::set_prevout(const input& input) const NOEXCEPT
178181
}
179182

180183
// metadata is mutable so can be set on a const object.
181-
void chaser_block::populate(const block& block) const NOEXCEPT
184+
bool chaser_block::populate(const block& block,
185+
const system::chain::context& ctx) const NOEXCEPT
182186
{
183-
block.populate();
187+
if (!block.populate(ctx))
188+
return false;
189+
184190
const inputs_cptr ins{ block.inputs_ptr() };
185191
std::for_each(ins->begin(), ins->end(), [&](const auto& in) NOEXCEPT
186192
{
187193
if (!in->prevout && !in->point().is_null())
188194
set_prevout(*in);
189195
});
196+
197+
return true;
190198
}
191199

192200
} // namespace node

src/chasers/chaser_validate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ void chaser_validate::validate_block(const header_link& link) NOEXCEPT
218218
{
219219
ec = error::validate2;
220220
}
221-
else if (!block->populate())
221+
else if (!block->populate(ctx))
222222
{
223223
ec = system::error::relative_time_locked;
224224
}

0 commit comments

Comments
 (0)