Skip to content

Commit 413ce51

Browse files
committed
index: update + clean bip352 index to latest master
1 parent 3e4eb1e commit 413ce51

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

src/index/bip352.cpp

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ bool BIP352Index::GetSilentPaymentKeys(const std::vector<CTransactionRef>& txs,
114114
return true;
115115
}
116116

117+
interfaces::Chain::NotifyOptions BIP352Index::CustomOptions()
118+
{
119+
interfaces::Chain::NotifyOptions options;
120+
options.connect_undo_data = true;
121+
return options;
122+
}
123+
117124
bool BIP352Index::CustomAppend(const interfaces::BlockInfo& block)
118125
{
119126
// Exclude genesis block transaction because outputs are not spendable. This
@@ -123,26 +130,8 @@ bool BIP352Index::CustomAppend(const interfaces::BlockInfo& block)
123130
// Exclude pre-taproot
124131
if (block.height < m_start_height) return true;
125132

126-
assert(block.data);
127-
128-
std::vector<std::pair<uint256, CPubKey>> items;
129-
130-
const CBlockIndex* block_index = WITH_LOCK(cs_main, return m_chainstate->m_blockman.LookupBlockIndex(block.hash));
131-
// TODO: fix sloppy rebase, DANGER!
132-
assert(block_index != nullptr);
133-
134-
135-
CBlockUndo block_undo;
136-
137-
if (!(m_chainstate->m_blockman.ReadBlockUndo(block_undo, *block_index))) {
138-
// Should be impossible on an unpruned node
139-
LogError("Failed to read undo file for %s", GetName());
140-
return false;
141-
};
142-
143133
tweak_index_entry index_entry;
144-
GetSilentPaymentKeys(block.data->vtx, block_undo, index_entry);
145-
134+
GetSilentPaymentKeys(Assert(block.data)->vtx, *Assert(block.undo_data), index_entry);
146135
return m_db->WriteSilentPayments(make_pair(block.hash, index_entry));
147136
}
148137

src/index/bip352.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ class BIP352Index final : public BaseIndex
5858
bool GetSilentPaymentKeys(const std::vector<CTransactionRef>& txs, const CBlockUndo& block_undo, tweak_index_entry& index_entry) const;
5959

6060
protected:
61+
interfaces::Chain::NotifyOptions CustomOptions() override;
62+
6163
bool CustomAppend(const interfaces::BlockInfo& block) override;
6264

6365
BaseIndex::DB& GetDB() const override;

0 commit comments

Comments
 (0)