Skip to content

Commit fdea6c5

Browse files
authored
Merge pull request #690 from evoskuil/master
Add to_confirmed(tx_hash).
2 parents dd2beaa + c59ab50 commit fdea6c5

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

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

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,18 @@ output_link CLASS::to_prevout(const point_link& link) const NOEXCEPT
165165
// block/tx to block (reverse navigation)
166166
// ----------------------------------------------------------------------------
167167

168+
// Required for confirmation processing.
169+
TEMPLATE
170+
header_link CLASS::to_block(const tx_link& key) const NOEXCEPT
171+
{
172+
table::strong_tx::record strong{};
173+
if (!store_.strong_tx.find(key, strong) || !strong.positive())
174+
return {};
175+
176+
// Terminal implies not in strong block (reorganized).
177+
return strong.header_fk();
178+
}
179+
168180
// Required for confirmation processing.
169181
TEMPLATE
170182
header_link CLASS::to_strong(const hash_digest& tx_hash) const NOEXCEPT
@@ -184,7 +196,6 @@ header_link CLASS::to_strong(const hash_digest& tx_hash) const NOEXCEPT
184196

185197
return {};
186198
}
187-
188199
TEMPLATE
189200
header_link CLASS::to_parent(const header_link& link) const NOEXCEPT
190201
{
@@ -196,16 +207,25 @@ header_link CLASS::to_parent(const header_link& link) const NOEXCEPT
196207
return header.parent_fk;
197208
}
198209

210+
// to confirmed objects (reverse navigation)
211+
// ----------------------------------------------------------------------------
212+
199213
TEMPLATE
200-
header_link CLASS::to_block(const tx_link& key) const NOEXCEPT
214+
header_link CLASS::to_confirmed_block(
215+
const hash_digest& tx_hash) const NOEXCEPT
201216
{
202-
// Required for confirmation processing.
203-
table::strong_tx::record strong{};
204-
if (!store_.strong_tx.find(key, strong) || !strong.positive())
217+
const auto block = to_strong(tx_hash);
218+
if (!is_confirmed_block(block))
205219
return {};
206220

207-
// Terminal implies not in strong block (reorganized).
208-
return strong.header_fk();
221+
return block;
222+
}
223+
224+
TEMPLATE
225+
point_link CLASS::to_confirmed_spender(const point&) const NOEXCEPT
226+
{
227+
// TODO: implement.
228+
return {};
209229
}
210230

211231
// output to spenders (reverse navigation)

include/bitcoin/database/query.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,13 @@ class query
287287
output_link to_prevout(const point_link& link) const NOEXCEPT;
288288

289289
/// block/tx to block (reverse navigation)
290+
header_link to_block(const tx_link& key) const NOEXCEPT;
290291
header_link to_strong(const hash_digest& tx_hash) const NOEXCEPT;
291292
header_link to_parent(const header_link& link) const NOEXCEPT;
292-
header_link to_block(const tx_link& key) const NOEXCEPT;
293+
294+
/// to confirmed objects (reverse navigation)
295+
header_link to_confirmed_block(const hash_digest& tx_hash) const NOEXCEPT;
296+
point_link to_confirmed_spender(const point& prevout) const NOEXCEPT;
293297

294298
/// output to spenders (reverse navigation)
295299
point_links to_spenders(const point& prevout) const NOEXCEPT;

0 commit comments

Comments
 (0)