Skip to content

Commit 64c39cd

Browse files
committed
Electrum handle node::chase::transaction, move reorg fn.
1 parent 810a746 commit 64c39cd

2 files changed

Lines changed: 17 additions & 18 deletions

File tree

src/protocols/electrum/protocol_electrum.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,9 @@ bool protocol_electrum::handle_event(const code&, node::chase event_,
136136
if (stopped())
137137
return false;
138138

139-
// TODO: collapse three atomics this into a single enumeration.
140139
switch (event_)
141140
{
142-
////case node::chase::transaction:
141+
case node::chase::transaction:
143142
case node::chase::organized:
144143
{
145144
if (subscribed_height_.load(relaxed))
@@ -185,6 +184,22 @@ bool protocol_electrum::handle_event(const code&, node::chase event_,
185184
return true;
186185
}
187186

187+
// regress
188+
// ----------------------------------------------------------------------------
189+
190+
// The chain has been reduced in height, clear all midstate cache and cursors.
191+
void protocol_electrum::do_reorganized(node::header_t) NOEXCEPT
192+
{
193+
BC_ASSERT(notification_strand_.running_in_this_thread());
194+
195+
for (auto& [key, sub]: address_subscriptions_)
196+
{
197+
// writer.flush resets hash accumulator, sub.type remains unchanged.
198+
sub.state.writer.flush();
199+
sub.cursor = {};
200+
}
201+
}
202+
188203
BC_POP_WARNING()
189204

190205
} // namespace server

src/protocols/electrum/protocol_electrum_subscribe.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -227,22 +227,6 @@ void protocol_electrum::scripthash_notify(const hash_digest& status,
227227
}, 128, BIND(handle_send, _1));
228228
}
229229

230-
// regress
231-
// ----------------------------------------------------------------------------
232-
233-
// The chain has been reduced in height, clear all midstate cache and cursors.
234-
void protocol_electrum::do_reorganized(node::header_t) NOEXCEPT
235-
{
236-
BC_ASSERT(notification_strand_.running_in_this_thread());
237-
238-
for (auto& [key, sub]: address_subscriptions_)
239-
{
240-
// writer.flush resets hash accumulator, sub.type remains unchanged.
241-
sub.state.writer.flush();
242-
sub.cursor = {};
243-
}
244-
}
245-
246230
// utility
247231
// ----------------------------------------------------------------------------
248232
// private

0 commit comments

Comments
 (0)