Skip to content

Commit c5b76d2

Browse files
committed
Move notification handlers into headers.
1 parent 06e7806 commit c5b76d2

2 files changed

Lines changed: 46 additions & 46 deletions

File tree

src/protocols/electrum/protocol_electrum.cpp

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -186,52 +186,6 @@ bool protocol_electrum::handle_event(const code&, node::chase event_,
186186
return true;
187187
}
188188

189-
// height/header notifications.
190-
// ----------------------------------------------------------------------------
191-
// Each notification is an independent message.
192-
193-
// Notifier for handle_blockchain_number_of_blocks_subscribe events.
194-
void protocol_electrum::do_height(node::header_t link) NOEXCEPT
195-
{
196-
BC_ASSERT(stranded());
197-
198-
const auto& query = archive();
199-
const auto height = query.get_height(link);
200-
201-
if (height.is_terminal())
202-
{
203-
LOGF("Electrum::do_height, height not found (" << link << ").");
204-
return;
205-
}
206-
207-
send_notification("blockchain.numblocks.subscribe", array_t
208-
{
209-
height.value
210-
}, 48, BIND(complete, _1));
211-
}
212-
213-
// Notifier for blockchain_headers_subscribe events.
214-
void protocol_electrum::do_header(node::header_t link) NOEXCEPT
215-
{
216-
BC_ASSERT(stranded());
217-
218-
const auto& query = archive();
219-
const auto height = query.get_height(link);
220-
const auto header = query.get_wire_header(link);
221-
222-
if (height.is_terminal())
223-
{
224-
LOGF("Electrum::do_header, header not found (" << link << ").");
225-
return;
226-
}
227-
228-
send_notification("blockchain.headers.subscribe", object_t
229-
{
230-
{ "height", height.value },
231-
{ "hex", encode_base16(header) }
232-
}, 64, BIND(complete, _1));
233-
}
234-
235189
BC_POP_WARNING()
236190

237191
} // namespace server

src/protocols/electrum/protocol_electrum_headers.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,52 @@ void protocol_electrum::handle_blockchain_headers_subscribe(const code& ec,
371371
}, 256, BIND(complete, _1));
372372
}
373373

374+
// height/header notifications.
375+
// ----------------------------------------------------------------------------
376+
// Each notification is an independent message.
377+
378+
// Notifier for handle_blockchain_number_of_blocks_subscribe events.
379+
void protocol_electrum::do_height(node::header_t link) NOEXCEPT
380+
{
381+
BC_ASSERT(stranded());
382+
383+
const auto& query = archive();
384+
const auto height = query.get_height(link);
385+
386+
if (height.is_terminal())
387+
{
388+
LOGF("Electrum::do_height, height not found (" << link << ").");
389+
return;
390+
}
391+
392+
send_notification("blockchain.numblocks.subscribe", array_t
393+
{
394+
height.value
395+
}, 48, BIND(complete, _1));
396+
}
397+
398+
// Notifier for blockchain_headers_subscribe events.
399+
void protocol_electrum::do_header(node::header_t link) NOEXCEPT
400+
{
401+
BC_ASSERT(stranded());
402+
403+
const auto& query = archive();
404+
const auto height = query.get_height(link);
405+
const auto header = query.get_wire_header(link);
406+
407+
if (height.is_terminal())
408+
{
409+
LOGF("Electrum::do_header, header not found (" << link << ").");
410+
return;
411+
}
412+
413+
send_notification("blockchain.headers.subscribe", object_t
414+
{
415+
{ "height", height.value },
416+
{ "hex", encode_base16(header) }
417+
}, 64, BIND(complete, _1));
418+
}
419+
374420
BC_POP_WARNING()
375421

376422
} // namespace server

0 commit comments

Comments
 (0)