BitShares-Core  4.0.0
BitShares blockchain implementation and command-line interface software
application_impl.hxx
Go to the documentation of this file.
1 #pragma once
2 
4 #include <fc/thread/parallel.hpp>
5 
10 #include <graphene/net/message.hpp>
11 
12 namespace graphene { namespace app { namespace detail {
13 
14 
16  {
17  public:
19  bool _is_block_producer = false;
20  bool _force_validate = false;
22 
23  void reset_p2p_node(const fc::path& data_dir);
24 
26 
28 
30 
31  explicit application_impl(application* self)
32  : _self(self),
33  _chain_db(std::make_shared<chain::database>())
34  {
35  }
36 
38  {
39  }
40 
41  void set_dbg_init_key( graphene::chain::genesis_state_type& genesis, const std::string& init_key );
42  void set_api_limit();
43 
44  void startup();
45 
46  fc::optional< api_access_info > get_api_access_info(const string& username)const;
47 
48  void set_api_access_info(const string& username, api_access_info&& permissions);
49 
53  virtual bool has_item(const net::item_id& id) override;
54 
63  virtual bool handle_block(const graphene::net::block_message& blk_msg, bool sync_mode,
64  std::vector<fc::uint160_t>& contained_transaction_message_ids) override;
65 
66  virtual void handle_transaction(const graphene::net::trx_message& transaction_message) override;
67 
68  void handle_message(const graphene::net::message& message_to_process) override;
69 
71 
81  virtual std::vector<graphene::net::item_hash_t> get_block_ids(const std::vector<graphene::net::item_hash_t>& blockchain_synopsis,
82  uint32_t& remaining_item_count,
83  uint32_t limit) override;
84 
88  virtual graphene::net::message get_item(const graphene::net::item_id& id) override;
89 
90  virtual graphene::chain::chain_id_type get_chain_id()const override;
91 
150  virtual std::vector<graphene::net::item_hash_t> get_blockchain_synopsis(const graphene::net::item_hash_t& reference_point,
151  uint32_t number_of_blocks_after_reference_point) override;
152 
160  virtual void sync_status(uint32_t item_type, uint32_t item_count) override;
161 
165  virtual void connection_count_changed(uint32_t c) override;
166 
167  virtual uint32_t get_block_number(const graphene::net::item_hash_t& block_id) override;
168 
173  virtual fc::time_point_sec get_block_time(const graphene::net::item_hash_t& block_id) override;
174 
175  virtual graphene::net::item_hash_t get_head_block_id() const override;
176 
177  virtual uint32_t estimate_last_known_fork_from_git_revision_timestamp(uint32_t unix_timestamp) const override;
178 
179  virtual void error_encountered(const std::string& message, const fc::oexception& error) override;
180 
181  uint8_t get_current_block_interval_in_seconds() const override;
182 
184 
186  const boost::program_options::variables_map* _options = nullptr;
188 
189  std::shared_ptr<graphene::chain::database> _chain_db;
190  std::shared_ptr<graphene::net::node> _p2p_network;
191  std::shared_ptr<fc::http::websocket_server> _websocket_server;
192  std::shared_ptr<fc::http::websocket_tls_server> _websocket_tls_server;
193 
194  std::map<string, std::shared_ptr<abstract_plugin>> _active_plugins;
195  std::map<string, std::shared_ptr<abstract_plugin>> _available_plugins;
196 
197  bool _is_finished_syncing = false;
198  private:
199  fc::serial_valve valve;
200  };
201 
202 }}} // namespace graphene namespace app namespace detail
virtual std::vector< graphene::net::item_hash_t > get_block_ids(const std::vector< graphene::net::item_hash_t > &blockchain_synopsis, uint32_t &remaining_item_count, uint32_t limit) override
virtual bool handle_block(const graphene::net::block_message &blk_msg, bool sync_mode, std::vector< fc::uint160_t > &contained_transaction_message_ids) override
allows the application to validate an item prior to broadcasting to peers.
fc::optional< api_access_info > get_api_access_info(const string &username) const
virtual bool has_item(const net::item_id &id) override
tracks the blockchain state in an extensible manner
Definition: database.hpp:70
void set_dbg_init_key(graphene::chain::genesis_state_type &genesis, const std::string &init_key)
virtual void error_encountered(const std::string &message, const fc::oexception &error) override
Definition: api.cpp:56
bool is_included_block(const graphene::chain::block_id_type &block_id)
virtual uint32_t get_block_number(const graphene::net::item_hash_t &block_id) override
used by node reports status to client or fetch data from client
Definition: node.hpp:61
virtual void connection_count_changed(uint32_t c) override
fc::optional< fc::temp_file > _lock_file
std::shared_ptr< websocket_connection > websocket_connection_ptr
Definition: websocket.hpp:41
virtual graphene::net::item_hash_t get_head_block_id() const override
std::shared_ptr< graphene::net::node > _p2p_network
virtual void handle_transaction(const graphene::net::trx_message &transaction_message) override
Called when a new transaction comes in from the network.
uint8_t get_current_block_interval_in_seconds() const override
virtual std::vector< graphene::net::item_hash_t > get_blockchain_synopsis(const graphene::net::item_hash_t &reference_point, uint32_t number_of_blocks_after_reference_point) override
void set_api_access_info(const string &username, api_access_info &&permissions)
virtual fc::time_point_sec get_block_time(const graphene::net::item_hash_t &block_id) override
const boost::program_options::variables_map * _options
std::shared_ptr< fc::http::websocket_tls_server > _websocket_tls_server
virtual uint32_t estimate_last_known_fork_from_git_revision_timestamp(uint32_t unix_timestamp) const override
void handle_message(const graphene::net::message &message_to_process) override
Called when a new message comes in from the network other than a block or a transaction. Currently there are no other possible messages, so this should never be called.
std::map< string, std::shared_ptr< abstract_plugin > > _active_plugins
virtual void sync_status(uint32_t item_type, uint32_t item_count) override
void new_connection(const fc::http::websocket_connection_ptr &c)
std::shared_ptr< graphene::chain::database > _chain_db
virtual graphene::net::message get_item(const graphene::net::item_id &id) override
wraps boost::filesystem::path to provide platform independent path manipulation.
Definition: filesystem.hpp:28
std::shared_ptr< fc::http::websocket_server > _websocket_server
void reset_p2p_node(const fc::path &data_dir)
std::map< string, std::shared_ptr< abstract_plugin > > _available_plugins
virtual graphene::chain::chain_id_type get_chain_id() const override