@@ -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+
374420BC_POP_WARNING ()
375421
376422} // namespace server
0 commit comments