@@ -30,7 +30,7 @@ namespace libbitcoin {
3030namespace server {
3131
3232class BCS_API server_node
33- /* : full_node */
33+ : public node::full_node
3434{
3535public:
3636 typedef std::function<void (size_t , const bc::block_type&)>
@@ -41,66 +41,49 @@ class BCS_API server_node
4141 server_node (settings_type& config);
4242 bool start (settings_type& config);
4343
44- // Should only be called from the main thread.
45- // It's an error to join() a thread from inside it.
46- bool stop ();
44+ virtual void subscribe_blocks (block_notify_callback notify_block);
45+ virtual void subscribe_transactions (transaction_notify_callback notify_tx);
4746
48- void subscribe_blocks (block_notify_callback notify_block);
49- void subscribe_transactions (transaction_notify_callback notify_tx);
50-
51- // Access to underlying services.
52- bc::chain::blockchain& blockchain ();
53- bc::chain::transaction_pool& transaction_pool ();
54- bc::node::transaction_indexer& transaction_indexer ();
55- bc::network::protocol& protocol ();
47+ static void fullnode_fetch_history (server_node& node,
48+ const incoming_message& request, queue_send_callback queue_send);
5649
57- // Threadpool for memory related operations.
58- bc::threadpool& memory_related_threadpool ();
50+ protected:
51+ // Result of store operation in transaction pool.
52+ virtual void new_unconfirm_valid_tx (const std::error_code& ec,
53+ const index_list& unconfirmed, const transaction_type& tx);
5954
60- // TODO: use existing libbitcoin-node implementation.
61- static void fullnode_fetch_history (server_node& node,
62- const incoming_message& request, queue_send_callback queue_send );
55+ virtual void server_node::broadcast_new_blocks ( const std::error_code& ec,
56+ uint32_t fork_point, const chain::blockchain::block_list& new_blocks,
57+ const chain::blockchain::block_list& replaced_blocks );
6358
6459private:
6560 typedef std::vector<block_notify_callback> block_notify_list;
6661 typedef std::vector<transaction_notify_callback> transaction_notify_list;
6762
68- void start_session ();
69- void wait_and_retry_start (const std::error_code& ec);
63+ // Subscriptions for server API.
64+ block_notify_list block_sunscriptions_;
65+ transaction_notify_list tx_subscriptions_;
7066
71- // New connection has been started.
72- // Subscribe to new transaction messages from the network.
73- void monitor_tx (const std::error_code& ec, bc::network::channel_ptr node);
74- // New transaction message from the network.
75- // Attempt to validate it by storing it in the transaction pool.
76- void recv_transaction (const std::error_code& ec,
77- const bc::transaction_type& tx, bc::network::channel_ptr node);
78- // Result of store operation in transaction pool.
79- void handle_mempool_store (const std::error_code& ec,
80- const bc::index_list& unconfirmed, const bc::transaction_type& tx,
81- bc::network::channel_ptr node);
82-
83- void reorganize (const std::error_code& ec, size_t fork_point,
84- const bc::chain::blockchain::block_list& new_blocks,
85- const bc::chain::blockchain::block_list& replaced_blocks);
86-
87- bc::ofstream outfile_, errfile_;
88- // Threadpools
89- bc::threadpool network_pool_, disk_pool_, mem_pool_;
90- // Services
91- bc::network::hosts hosts_;
67+ // Logs.
68+ bc::ofstream outfile_;
69+ bc::ofstream errfile_;
70+
71+ // Services.
72+ bc::threadpool network_threads_;
73+ bc::threadpool database_threads_;
74+ bc::threadpool memory_threads_;
75+ bc::network::hosts host_pool_;
9276 bc::network::handshake handshake_;
9377 bc::network::network network_;
9478 bc::network::protocol protocol_;
95- bc::chain::blockchain_impl chain_;
79+ bc::chain::blockchain_impl blockchain_;
80+ bc::chain::transaction_pool tx_pool_;
81+ bc::node::indexer tx_indexer_;
9682 bc::node::poller poller_;
97- bc::chain::transaction_pool txpool_;
98- bc::node::transaction_indexer indexer_;
9983 bc::node::session session_;
84+ bc::node::responder responder_;
10085
101- block_notify_list notify_blocks_;
102- transaction_notify_list notify_txs_;
103-
86+ // Timer.
10487 boost::asio::deadline_timer retry_start_timer_;
10588};
10689
0 commit comments