Skip to content

Commit 0a4b89a

Browse files
committed
Implement set_prevouts and change from link to height, comments.
1 parent 9229a59 commit 0a4b89a

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

include/bitcoin/database/impl/query/confirm.ipp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,10 @@ error::error_t CLASS::spent_prevout(const point_link& link, index index,
277277
// But if we hold the spend.pk/prevout.tx we can just read the
278278
// spend.hash/index, so we don't need to store the index, and we need to
279279
// read the spend.hash anyway, so index is free (no paging). So that's now
280-
// just spend[4] + tx[4], back to 8 bytes (19GB).
280+
// just spend[4] + tx[4], back to 8 bytes (19GB). But getting spends is
281+
// relatively cheap, just search txs[hash] and navigate puts. The downside
282+
// is the extra search and puts is > 2x prevouts and can't be pruned.
283+
// The upside is half the prevout size (read/write/page) and store increase.
281284

282285
// Iterate points by point hash (of output tx) because may be conflicts.
283286
auto point = store_.point.it(get_point_key(link));
@@ -705,13 +708,14 @@ bool CLASS::set_unstrong(const header_link& link) NOEXCEPT
705708
}
706709

707710
TEMPLATE
708-
bool CLASS::set_prevouts(const header_link&, const block&) NOEXCEPT
711+
bool CLASS::set_prevouts(size_t height, const block& block) NOEXCEPT
709712
{
710713
// ========================================================================
711714
const auto scope = store_.get_transactor();
712715

713-
// TODO: implement.
714-
return {};
716+
// Clean single allocation failure (e.g. disk full).
717+
const table::prevout::record_put_ref prevouts{ {}, block };
718+
return store_.prevout.put(height, prevouts);
715719
// ========================================================================
716720
}
717721

include/bitcoin/database/query.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ class query
510510
/// Block association relies on strong (confirmed or pending).
511511
bool set_strong(const header_link& link) NOEXCEPT;
512512
bool set_unstrong(const header_link& link) NOEXCEPT;
513-
bool set_prevouts(const header_link& link, const block& block) NOEXCEPT;
513+
bool set_prevouts(size_t height, const block& block) NOEXCEPT;
514514
code block_confirmable(const header_link& link) const NOEXCEPT;
515515
////code tx_confirmable(const tx_link& link, const context& ctx) const NOEXCEPT;
516516
code unspent_duplicates(const header_link& coinbase,

0 commit comments

Comments
 (0)