BitShares-Core
7.0.2
BitShares blockchain node software and command-line wallet software
|
Go to the documentation of this file.
31 #include <boost/tuple/tuple.hpp>
33 #include <boost/multi_index_container.hpp>
34 #include <boost/multi_index/ordered_index.hpp>
35 #include <boost/multi_index/mem_fun.hpp>
36 #include <boost/multi_index/member.hpp>
37 #include <boost/multi_index/tag.hpp>
38 #include <boost/multi_index/hashed_index.hpp>
41 #include <boost/container/deque.hpp>
46 class peer_connection;
52 const message& received_message) = 0;
59 public std::enable_shared_from_this<peer_connection>
100 struct queued_message
107 enqueue_time(enqueue_time)
110 virtual message get_message(peer_connection_delegate* node) = 0;
114 virtual size_t get_size_in_queue() = 0;
115 virtual ~queued_message() =
default;
121 struct real_queued_message : queued_message
123 message message_to_send;
124 size_t message_send_time_field_offset;
126 real_queued_message(message message_to_send,
127 size_t message_send_time_field_offset = (
size_t)-1) :
128 message_to_send(
std::move(message_to_send)),
129 message_send_time_field_offset(message_send_time_field_offset)
132 message get_message(peer_connection_delegate* node)
override;
133 size_t get_size_in_queue()
override;
140 struct virtual_queued_message : queued_message
142 item_id item_to_send;
144 explicit virtual_queued_message(item_id the_item_to_send) :
145 item_to_send(
std::move(the_item_to_send))
148 message get_message(peer_connection_delegate* node)
override;
149 size_t get_size_in_queue()
override;
153 size_t _total_queued_messages_size = 0;
154 std::queue<std::unique_ptr<queued_message>, std::list<std::unique_ptr<queued_message> > > _queued_messages;
247 boost::multi_index::indexed_by<
248 boost::multi_index::hashed_unique<
249 boost::multi_index::member<timestamped_item_id, item_id, ×tamped_item_id::item>,
252 boost::multi_index::ordered_non_unique<
253 boost::multi_index::tag<timestamp_index>,
254 boost::multi_index::member<timestamped_item_id, fc::time_point_sec, ×tamped_item_id::timestamp>
280 unsigned _send_message_queue_tasks_running = 0;
282 bool _currently_handling_message =
false;
302 virtual void send_message(
const message& message_to_send,
size_t message_send_time_field_offset = (
size_t)-1 );
328 void send_queued_messages_task();
329 void accept_connection_task();
339 (connection_accepted)
340 (connection_rejected))
343 (connection_accepted)
344 (connection_rejected))
351 (peer_connection_accepted)
352 (peer_connection_rejected)
353 (negotiation_complete)
void send_item(const item_id &item_to_send)
fc::ip::address inbound_address
bool we_have_requested_close
their_connection_state their_state
virtual void on_message(peer_connection *originating_peer, const message &received_message)=0
connection_negotiation_status negotiation_status
bool is_transaction_fetching_inhibited() const
item_to_time_map_type items_requested_from_peer
fc::time_point get_last_message_received_time() const
@ peer_connection_rejected
uint32_t number_of_unfetched_item_ids
Number of items in the blockchain that follow ids_of_items_to_get but the peer hasn't yet told us the...
peer_connection_direction direction
fc::time_point connection_closed_time
void on_connection_closed(message_oriented_connection *originating_connection) override
@ connection_rejected
We have sent them a connection_rejected.
fc::time_point connection_initiation_time
uint64_t get_total_bytes_sent() const
static peer_connection_ptr make_shared(peer_connection_delegate *delegate)
Use this instead of the constructor.
virtual ~peer_connection()
uint64_t get_total_bytes_received() const
connection_negotiation_status
bool is_inventory_advertised_to_us_list_full() const
our_connection_state our_state
bool peer_needs_sync_items_from_us
std::set< item_hash_t > sync_items_requested_from_peer
IDs of blocks we've requested from this peer during sync. Fetch from another peer if this peer discon...
virtual ~peer_connection_delegate()=default
node_id_t node_public_key
void clear_old_inventory()
virtual message get_message_for_item(const item_id &item)=0
bool inhibit_fetching_sync_blocks
fc::time_point get_connection_terminated_time() const
fc::time_point connection_terminated_time
fc::sha512 get_shared_secret() const
void on_message(message_oriented_connection *originating_connection, const message &received_message) override
void send_queueable_message(std::unique_ptr< queued_message > &&message_to_send)
@ peer_connection_accepted
timestamped_items_set_type inventory_advertised_to_peer
fc::time_point last_sync_item_received_time
virtual void send_message(const message &message_to_send, size_t message_send_time_field_offset=(size_t) -1)
fc::optional< fc::ip::endpoint > get_endpoint_for_connecting() const
std::shared_ptr< peer_connection > peer_connection_ptr
void set_remote_endpoint(fc::optional< fc::ip::endpoint > new_remote_endpoint)
fc::time_point get_connection_time() const
fc::optional< fc::ip::endpoint > get_remote_endpoint()
uint32_t last_known_fork_block_number
fc::ip::endpoint get_local_endpoint()
firewalled_state is_firewalled
bool they_have_requested_close
fc::time_point transaction_fetching_inhibited_until
fc::optional< std::string > platform
peer_connection_direction
fc::time_point get_last_message_sent_time() const
fc::oexception connection_closed_error
fc::microseconds clock_offset
peer_connection(peer_connection_delegate *delegate)
fc::optional< uint32_t > bitness
fc::tcp_socket & get_socket()
bool is_currently_handling_message() const
void destroy_connection()
fc::flat_map< fc::ip::endpoint, firewalled_state > potential_inbound_endpoints
Potential inbound endpoints of the peer.
fc::flat_set< fc::ip::endpoint > additional_inbound_endpoints
Some nodes may be listening on multiple endpoints.
fc::optional< std::string > fc_git_revision_sha
FC_REFLECT_ENUM(graphene::net::core_message_type_enum,(trx_message_type)(block_message_type)(core_message_type_first)(item_ids_inventory_message_type)(blockchain_item_ids_inventory_message_type)(fetch_blockchain_item_ids_message_type)(fetch_items_message_type)(item_not_available_message_type)(hello_message_type)(connection_accepted_message_type)(connection_rejected_message_type)(address_request_message_type)(address_message_type)(closing_connection_message_type)(current_time_request_message_type)(current_time_reply_message_type)(check_firewall_message_type)(check_firewall_reply_message_type)(get_current_connections_request_message_type)(get_current_connections_reply_message_type)(core_message_type_last))(different_chain)(already_connected)(connected_to_self)(not_accepting_connections)(blocked)(invalid_hello_message)(client_too_old))(inbound)(outbound))(firewalled)(not_firewalled))(unable_to_connect)(connection_successful)) namespace std
virtual void on_connection_closed(peer_connection *originating_peer)=0
fc::microseconds round_trip_delay
bool we_need_sync_items_from_peer
bool expecting_address_message
Whether we're waiting for an address message.
fc::optional< boost::tuple< std::vector< item_hash_t >, fc::time_point > > item_ids_requested_from_peer
We check this to detect a timed-out request and in busy()
fc::optional< std::string > graphene_git_revision_sha
@ connection_accepted
We have sent them a connection_accepted.
fc::optional< fc::time_point_sec > graphene_git_revision_unix_timestamp
void connect_to(const fc::ip::endpoint &remote_endpoint, const fc::optional< fc::ip::endpoint > &local_endpoint=fc::optional< fc::ip::endpoint >())
std::set< item_hash_t > ids_of_items_being_processed
fc::optional< fc::ip::endpoint > remote_inbound_endpoint
The inbound endpoint of the remote peer (our best guess)
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
uint32_t core_protocol_version
@ just_connected
We have not yet received a hello_message.
boost::multi_index_container< timestamped_item_id, boost::multi_index::indexed_by< boost::multi_index::hashed_unique< boost::multi_index::member< timestamped_item_id, item_id, ×tamped_item_id::item >, std::hash< item_id > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< timestamp_index >, boost::multi_index::member< timestamped_item_id, fc::time_point_sec, ×tamped_item_id::timestamp > > > > timestamped_items_set_type
timestamped_item_id(const item_id &item, const fc::time_point_sec timestamp)
fc::optional< fc::time_point_sec > fc_git_revision_unix_timestamp
bool is_inventory_advertised_to_us_list_full_for_transactions() const
fc::time_point_sec last_block_time_delegate_has_seen
@ just_connected
If in this state, we have sent a hello_message.
fc::time_point_sec timestamp
fc::future< void > accept_or_connect_task_done
item_hash_t last_block_delegate_has_seen
The hash of the last block this peer has told us about that the peer knows.
boost::container::deque< item_hash_t > ids_of_items_to_get
timestamped_items_set_type inventory_peer_advertised_to_us
std::unordered_map< item_id, fc::time_point > item_to_time_map_type
fc::time_point get_connection_time() const