@@ -199,7 +199,7 @@ code CLASS::unspent_duplicates(const header_link& link,
199199
200200// protected
201201TEMPLATE
202- bool CLASS::get_conflicts (point_links& points, const point& point,
202+ code CLASS::get_conflicts (point_links& points, const point& point,
203203 const point_link& self) const NOEXCEPT
204204{
205205 // Iterate to all matching spend table keys. Since these are stubs of the
@@ -213,28 +213,28 @@ bool CLASS::get_conflicts(point_links& points, const point& point,
213213 // the existence of multiple spends of outputs in the same transaction.
214214 auto it = store_.spend .it (table::spend::compose (point));
215215 if (!it)
216- return false ;
216+ return error::integrity4 ;
217217
218218 do
219219 {
220220 table::spend::record get{};
221221 if (!store_.spend .get (it, get))
222- return false ;
222+ return error::integrity5 ;
223223
224224 if (get.point_fk != self)
225225 points.push_back (get.point_fk );
226226 }
227227 while (it.advance ());
228- return true ;
228+ return error::success ;
229229}
230230
231231// protected
232232TEMPLATE
233- bool CLASS::push_doubles (tx_links& out, const point& point,
233+ code CLASS::push_doubles (tx_links& out, const point& point,
234234 const point_links& points) const NOEXCEPT
235235{
236236 if (points.empty ())
237- return true ;
237+ return error::success ;
238238
239239 // The expected self spend and primary conflicts are removed. This serves
240240 // to remove secondary conflicts, leaving only actual additional spends.
@@ -243,39 +243,44 @@ bool CLASS::push_doubles(tx_links& out, const point& point,
243243 {
244244 table::point::get_parent_key parent_tx{};
245245 if (!store_.point .get (ptr, link, parent_tx))
246- return false ;
246+ return error::integrity6 ;
247247
248248 if (parent_tx.hash == point.hash ())
249249 out.push_back (parent_tx.fk );
250250 }
251251
252- return true ;
252+ return error::success ;
253253}
254254
255255// protected
256256TEMPLATE
257- bool CLASS::push_spenders (tx_links& out, const point& point,
257+ code CLASS::push_spenders (tx_links& out, const point& point,
258258 const point_link& self) const NOEXCEPT
259259{
260+ code ec{};
260261 point_links points{};
261- return get_conflicts (points, point, self) &&
262- push_doubles (out, point, points);
262+ if ((ec = get_conflicts (points, point, self)))
263+ return ec;
264+
265+ return push_doubles (out, point, points);
263266}
264267
265268TEMPLATE
266- bool CLASS::get_double_spenders (tx_links& out, const block& block) const NOEXCEPT
269+ code CLASS::get_double_spenders (tx_links& out,
270+ const block& block) const NOEXCEPT
267271{
268272 // Empty or coinbase only implies no spends.
269273 const auto & txs = *block.transactions_ptr ();
270274 if (txs.size () <= one)
271- return true ;
275+ return error::success ;
272276
277+ code ec{};
273278 for (auto tx = std::next (txs.begin ()); tx != txs.end (); ++tx)
274279 for (const auto & in: *(*tx)->inputs_ptr ())
275- if (! push_spenders (out, in->point (), in->metadata .link ))
276- return false ;
280+ if ((ec = push_spenders (out, in->point (), in->metadata .link ) ))
281+ return ec ;
277282
278- return true ;
283+ return error::success ;
279284}
280285
281286// unspendable
@@ -296,16 +301,16 @@ error::error_t CLASS::unspendable(uint32_t sequence, bool coinbase,
296301 return error::unconfirmed_spend;
297302 }
298303
299- const auto bip68 = ctx.is_enabled (system::chain::flags::bip68_rule) &&
300- ( version >= system::chain::relative_locktime_min_version );
304+ const auto relative = ctx.is_enabled (system::chain::flags::bip68_rule) &&
305+ transaction::is_relative_locktime_applied (coinbase, version, sequence );
301306
302- if (bip68 || coinbase)
307+ if (relative || coinbase)
303308 {
304309 context out{};
305310 if (!get_context (out, strong))
306- return error::integrity4 ;
311+ return error::integrity7 ;
307312
308- if (bip68 &&
313+ if (relative &&
309314 input::is_locked (sequence, ctx.height , ctx.mtp , out.height , out.mtp ))
310315 return error::relative_time_locked;
311316
@@ -328,10 +333,10 @@ code CLASS::populate_prevouts(point_sets& sets, size_t points,
328333 if (sets.empty ())
329334 return error::success;
330335
331- table::prevout::record_get cache{};
336+ table::prevout::slab_get cache{};
332337 cache.spends .resize (points);
333338 if (!store_.prevout .at (link, cache))
334- return error::integrity5 ;
339+ return error::integrity8 ;
335340
336341 for (const auto & spender: cache.conflicts )
337342 if (is_strong_tx (spender))
@@ -342,8 +347,8 @@ code CLASS::populate_prevouts(point_sets& sets, size_t points,
342347 for (auto & point: set.points )
343348 {
344349 const auto & pair = *it++;
345- point.tx = table::prevout::record_get ::output_tx_fk (pair.first );
346- point.coinbase = table::prevout::record_get ::coinbase (pair.first );
350+ point.tx = table::prevout::slab_get ::output_tx_fk (pair.first );
351+ point.coinbase = table::prevout::slab_get ::coinbase (pair.first );
347352 point.sequence = pair.second ;
348353 }
349354
@@ -360,7 +365,7 @@ code CLASS::block_confirmable(const header_link& link) const NOEXCEPT
360365
361366 context ctx{};
362367 if (!get_context (ctx, link))
363- return error::integrity6 ;
368+ return error::integrity9 ;
364369
365370 // bip30 coinbase check.
366371 code ec{};
@@ -382,7 +387,7 @@ code CLASS::block_confirmable(const header_link& link) const NOEXCEPT
382387 point_set set{};
383388 table::transaction::get_set_ref get{ {}, set };
384389 if (!store_.tx .get (tx, get))
385- failure.store (error::integrity7 );
390+ failure.store (error::integrity10 );
386391
387392 points.fetch_add (set.points .size (), std::memory_order_relaxed);
388393 return set;
@@ -473,18 +478,20 @@ bool CLASS::set_unstrong(const header_link& link) NOEXCEPT
473478}
474479
475480TEMPLATE
476- bool CLASS::set_prevouts (const header_link& link, const block& block) NOEXCEPT
481+ code CLASS::set_prevouts (const header_link& link, const block& block) NOEXCEPT
477482{
483+ code ec{};
478484 tx_links spenders{};
479- if (! get_double_spenders (spenders, block))
480- return false ;
485+ if ((ec = get_double_spenders (spenders, block) ))
486+ return ec ;
481487
482488 // ========================================================================
483489 const auto scope = store_.get_transactor ();
484490
485491 // Clean single allocation failure (e.g. disk full).
486- const table::prevout::record_put_ref prevouts{ {}, spenders, block };
487- return store_.prevout .put (link, prevouts);
492+ const table::prevout::slab_put_ref prevouts{ {}, spenders, block };
493+ return store_.prevout .put (link, prevouts) ? error::success :
494+ error::integrity11;
488495 // ========================================================================
489496}
490497
0 commit comments