BitShares-Core  5.0.0
BitShares blockchain implementation and command-line interface software
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
graphene::net::peer_connection Class Reference

#include <peer_connection.hpp>

Inheritance diagram for graphene::net::peer_connection:
graphene::net::message_oriented_connection_delegate

Classes

struct  timestamp_index
 
struct  timestamped_item_id
 

Public Types

enum  our_connection_state { our_connection_state::disconnected, our_connection_state::just_connected, our_connection_state::connection_accepted, our_connection_state::connection_rejected }
 
enum  their_connection_state { their_connection_state::disconnected, their_connection_state::just_connected, their_connection_state::connection_accepted, their_connection_state::connection_rejected }
 
enum  connection_negotiation_status {
  connection_negotiation_status::disconnected, connection_negotiation_status::connecting, connection_negotiation_status::connected, connection_negotiation_status::accepting,
  connection_negotiation_status::accepted, connection_negotiation_status::hello_sent, connection_negotiation_status::peer_connection_accepted, connection_negotiation_status::peer_connection_rejected,
  connection_negotiation_status::negotiation_complete, connection_negotiation_status::closing, connection_negotiation_status::closed
}
 
typedef std::unordered_map< item_id, fc::time_pointitem_to_time_map_type
 

Public Member Functions

fc::time_point get_connection_time () const
 
fc::time_point get_connection_terminated_time () const
 
virtual ~peer_connection ()
 
fc::tcp_socketget_socket ()
 
void accept_connection ()
 
void connect_to (const fc::ip::endpoint &remote_endpoint, fc::optional< fc::ip::endpoint > local_endpoint=fc::optional< fc::ip::endpoint >())
 
void on_message (message_oriented_connection *originating_connection, const message &received_message) override
 
void on_connection_closed (message_oriented_connection *originating_connection) override
 
void send_queueable_message (std::unique_ptr< queued_message > &&message_to_send)
 
void send_message (const message &message_to_send, size_t message_send_time_field_offset=(size_t)-1)
 
void send_item (const item_id &item_to_send)
 
void close_connection ()
 
void destroy_connection ()
 
uint64_t get_total_bytes_sent () const
 
uint64_t get_total_bytes_received () const
 
fc::time_point get_last_message_sent_time () const
 
fc::time_point get_last_message_received_time () const
 
fc::optional< fc::ip::endpointget_remote_endpoint ()
 
fc::ip::endpoint get_local_endpoint ()
 
void set_remote_endpoint (fc::optional< fc::ip::endpoint > new_remote_endpoint)
 
bool busy () const
 
bool idle () const
 
bool is_currently_handling_message () const
 
bool is_transaction_fetching_inhibited () const
 
fc::sha512 get_shared_secret () const
 
void clear_old_inventory ()
 
bool is_inventory_advertised_to_us_list_full_for_transactions () const
 
bool is_inventory_advertised_to_us_list_full () const
 
bool performing_firewall_check () const
 
fc::optional< fc::ip::endpointget_endpoint_for_connecting () const
 

Static Public Member Functions

static peer_connection_ptr make_shared (peer_connection_delegate *delegate)
 

Public Attributes

fc::time_point connection_initiation_time
 
fc::time_point connection_closed_time
 
fc::time_point connection_terminated_time
 
peer_connection_direction direction = peer_connection_direction::unknown
 
firewalled_state is_firewalled = firewalled_state::unknown
 
fc::microseconds clock_offset
 
fc::microseconds round_trip_delay
 
our_connection_state our_state = our_connection_state::disconnected
 
bool they_have_requested_close = false
 
their_connection_state their_state = their_connection_state::disconnected
 
bool we_have_requested_close = false
 
connection_negotiation_status negotiation_status = connection_negotiation_status::disconnected
 
fc::oexception connection_closed_error
 
fc::time_point transaction_fetching_inhibited_until
 
uint32_t last_known_fork_block_number = 0
 
fc::future< void > accept_or_connect_task_done
 
firewall_check_state_datafirewall_check_state = nullptr
 
node_id_t node_public_key
 
node_id_t node_id
 
uint32_t core_protocol_version = 0
 
std::string user_agent
 
fc::optional< std::string > graphene_git_revision_sha
 
fc::optional< fc::time_point_secgraphene_git_revision_unix_timestamp
 
fc::optional< std::string > fc_git_revision_sha
 
fc::optional< fc::time_point_secfc_git_revision_unix_timestamp
 
fc::optional< std::string > platform
 
fc::optional< uint32_t > bitness
 
fc::ip::address inbound_address
 
uint16_t inbound_port = 0
 
uint16_t outbound_port = 0
 
boost::container::deque< item_hash_tids_of_items_to_get
 
std::set< item_hash_tids_of_items_being_processed
 id of items in the blockchain that this peer has told us about More...
 
uint32_t number_of_unfetched_item_ids = 0
 list of all items this peer has offered use that we've already handed to the client but the client hasn't finished processing More...
 
bool peer_needs_sync_items_from_us = false
 number of items in the blockchain that follow ids_of_items_to_get but the peer hasn't yet told us their ids More...
 
bool we_need_sync_items_from_peer = false
 
fc::optional< boost::tuple< std::vector< item_hash_t >, fc::time_point > > item_ids_requested_from_peer
 
fc::time_point last_sync_item_received_time
 we check this to detect a timed-out request and in busy() More...
 
std::set< item_hash_tsync_items_requested_from_peer
 the time we received the last sync item or the time we sent the last batch of sync item requests to this peer More...
 
item_hash_t last_block_delegate_has_seen
 ids of blocks we've requested from this peer during sync. fetch from another peer if this peer disconnects More...
 
fc::time_point_sec last_block_time_delegate_has_seen
 the hash of the last block this peer has told us about that the peer knows More...
 
bool inhibit_fetching_sync_blocks = false
 
typedef 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,&timestamped_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,&timestamped_item_id::timestamp > > > > timestamped_items_set_type
 
timestamped_items_set_type inventory_peer_advertised_to_us
 
timestamped_items_set_type inventory_advertised_to_peer
 
item_to_time_map_type items_requested_from_peer
 

Detailed Description

Definition at line 74 of file peer_connection.hpp.

Member Typedef Documentation

Definition at line 217 of file peer_connection.hpp.

typedef 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, &timestamped_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, &timestamped_item_id::timestamp> > > > graphene::net::peer_connection::timestamped_items_set_type

Definition at line 250 of file peer_connection.hpp.

Member Enumeration Documentation

Enumerator
disconnected 
connecting 
connected 
accepting 
accepted 
hello_sent 
peer_connection_accepted 
peer_connection_rejected 
negotiation_complete 
closing 
closed 

Definition at line 92 of file peer_connection.hpp.

Enumerator
disconnected 
just_connected 
connection_accepted 
connection_rejected 

Definition at line 78 of file peer_connection.hpp.

Enumerator
disconnected 
just_connected 
connection_accepted 
connection_rejected 

Definition at line 85 of file peer_connection.hpp.

Constructor & Destructor Documentation

graphene::net::peer_connection::~peer_connection ( )
virtual

Definition at line 176 of file peer_connection.cpp.

Member Function Documentation

void graphene::net::peer_connection::accept_connection ( )

Definition at line 188 of file peer_connection.cpp.

bool graphene::net::peer_connection::busy ( ) const

Definition at line 448 of file peer_connection.cpp.

void graphene::net::peer_connection::clear_old_inventory ( )

Definition at line 478 of file peer_connection.cpp.

void graphene::net::peer_connection::close_connection ( )

Definition at line 391 of file peer_connection.cpp.

void graphene::net::peer_connection::connect_to ( const fc::ip::endpoint remote_endpoint,
fc::optional< fc::ip::endpoint local_endpoint = fc::optional<fc::ip::endpoint>() 
)

Definition at line 225 of file peer_connection.cpp.

void graphene::net::peer_connection::destroy_connection ( )

Definition at line 400 of file peer_connection.cpp.

fc::time_point graphene::net::peer_connection::get_connection_terminated_time ( ) const
inline

Definition at line 189 of file peer_connection.hpp.

fc::time_point graphene::net::peer_connection::get_connection_time ( ) const
inline

Definition at line 188 of file peer_connection.hpp.

fc::optional< fc::ip::endpoint > graphene::net::peer_connection::get_endpoint_for_connecting ( ) const

Definition at line 523 of file peer_connection.cpp.

fc::time_point graphene::net::peer_connection::get_last_message_received_time ( ) const

Definition at line 425 of file peer_connection.cpp.

fc::time_point graphene::net::peer_connection::get_last_message_sent_time ( ) const

Definition at line 419 of file peer_connection.cpp.

fc::ip::endpoint graphene::net::peer_connection::get_local_endpoint ( )

Definition at line 436 of file peer_connection.cpp.

fc::optional< fc::ip::endpoint > graphene::net::peer_connection::get_remote_endpoint ( )

Definition at line 431 of file peer_connection.cpp.

fc::sha512 graphene::net::peer_connection::get_shared_secret ( ) const

Definition at line 472 of file peer_connection.cpp.

fc::tcp_socket & graphene::net::peer_connection::get_socket ( )

Definition at line 182 of file peer_connection.cpp.

uint64_t graphene::net::peer_connection::get_total_bytes_received ( ) const

Definition at line 413 of file peer_connection.cpp.

uint64_t graphene::net::peer_connection::get_total_bytes_sent ( ) const

Definition at line 407 of file peer_connection.cpp.

bool graphene::net::peer_connection::idle ( ) const

Definition at line 454 of file peer_connection.cpp.

bool graphene::net::peer_connection::is_currently_handling_message ( ) const

Definition at line 460 of file peer_connection.cpp.

bool graphene::net::peer_connection::is_inventory_advertised_to_us_list_full ( ) const

Definition at line 507 of file peer_connection.cpp.

bool graphene::net::peer_connection::is_inventory_advertised_to_us_list_full_for_transactions ( ) const

Definition at line 501 of file peer_connection.cpp.

bool graphene::net::peer_connection::is_transaction_fetching_inhibited ( ) const

Definition at line 466 of file peer_connection.cpp.

peer_connection_ptr graphene::net::peer_connection::make_shared ( peer_connection_delegate delegate)
static

Definition at line 100 of file peer_connection.cpp.

void graphene::net::peer_connection::on_connection_closed ( message_oriented_connection originating_connection)
overridevirtual
void graphene::net::peer_connection::on_message ( message_oriented_connection originating_connection,
const message received_message 
)
overridevirtual
bool graphene::net::peer_connection::performing_firewall_check ( ) const

Definition at line 518 of file peer_connection.cpp.

void graphene::net::peer_connection::send_item ( const item_id item_to_send)

Definition at line 382 of file peer_connection.cpp.

void graphene::net::peer_connection::send_message ( const message message_to_send,
size_t  message_send_time_field_offset = (size_t)-1 
)

Definition at line 373 of file peer_connection.cpp.

void graphene::net::peer_connection::send_queueable_message ( std::unique_ptr< queued_message > &&  message_to_send)

Definition at line 341 of file peer_connection.cpp.

void graphene::net::peer_connection::set_remote_endpoint ( fc::optional< fc::ip::endpoint new_remote_endpoint)

Definition at line 442 of file peer_connection.cpp.

Member Data Documentation

fc::future<void> graphene::net::peer_connection::accept_or_connect_task_done

Definition at line 263 of file peer_connection.hpp.

fc::optional<uint32_t> graphene::net::peer_connection::bitness

Definition at line 207 of file peer_connection.hpp.

fc::microseconds graphene::net::peer_connection::clock_offset

Definition at line 177 of file peer_connection.hpp.

fc::oexception graphene::net::peer_connection::connection_closed_error

Definition at line 186 of file peer_connection.hpp.

fc::time_point graphene::net::peer_connection::connection_closed_time

Definition at line 172 of file peer_connection.hpp.

fc::time_point graphene::net::peer_connection::connection_initiation_time

Definition at line 171 of file peer_connection.hpp.

fc::time_point graphene::net::peer_connection::connection_terminated_time

Definition at line 173 of file peer_connection.hpp.

uint32_t graphene::net::peer_connection::core_protocol_version = 0

Definition at line 200 of file peer_connection.hpp.

peer_connection_direction graphene::net::peer_connection::direction = peer_connection_direction::unknown

Definition at line 174 of file peer_connection.hpp.

fc::optional<std::string> graphene::net::peer_connection::fc_git_revision_sha

Definition at line 204 of file peer_connection.hpp.

fc::optional<fc::time_point_sec> graphene::net::peer_connection::fc_git_revision_unix_timestamp

Definition at line 205 of file peer_connection.hpp.

firewall_check_state_data* graphene::net::peer_connection::firewall_check_state = nullptr

Definition at line 265 of file peer_connection.hpp.

fc::optional<std::string> graphene::net::peer_connection::graphene_git_revision_sha

Definition at line 202 of file peer_connection.hpp.

fc::optional<fc::time_point_sec> graphene::net::peer_connection::graphene_git_revision_unix_timestamp

Definition at line 203 of file peer_connection.hpp.

std::set<item_hash_t> graphene::net::peer_connection::ids_of_items_being_processed

id of items in the blockchain that this peer has told us about

Definition at line 222 of file peer_connection.hpp.

boost::container::deque<item_hash_t> graphene::net::peer_connection::ids_of_items_to_get

blockchain synchronization state data

Definition at line 221 of file peer_connection.hpp.

fc::ip::address graphene::net::peer_connection::inbound_address

Definition at line 212 of file peer_connection.hpp.

uint16_t graphene::net::peer_connection::inbound_port = 0

Definition at line 213 of file peer_connection.hpp.

bool graphene::net::peer_connection::inhibit_fetching_sync_blocks = false

Definition at line 231 of file peer_connection.hpp.

timestamped_items_set_type graphene::net::peer_connection::inventory_advertised_to_peer

Definition at line 252 of file peer_connection.hpp.

timestamped_items_set_type graphene::net::peer_connection::inventory_peer_advertised_to_us

Definition at line 251 of file peer_connection.hpp.

firewalled_state graphene::net::peer_connection::is_firewalled = firewalled_state::unknown

Definition at line 176 of file peer_connection.hpp.

fc::optional<boost::tuple<std::vector<item_hash_t>, fc::time_point> > graphene::net::peer_connection::item_ids_requested_from_peer

Definition at line 226 of file peer_connection.hpp.

item_to_time_map_type graphene::net::peer_connection::items_requested_from_peer

Definition at line 254 of file peer_connection.hpp.

item_hash_t graphene::net::peer_connection::last_block_delegate_has_seen

ids of blocks we've requested from this peer during sync. fetch from another peer if this peer disconnects

Definition at line 229 of file peer_connection.hpp.

fc::time_point_sec graphene::net::peer_connection::last_block_time_delegate_has_seen

the hash of the last block this peer has told us about that the peer knows

Definition at line 230 of file peer_connection.hpp.

uint32_t graphene::net::peer_connection::last_known_fork_block_number = 0

Definition at line 261 of file peer_connection.hpp.

fc::time_point graphene::net::peer_connection::last_sync_item_received_time

we check this to detect a timed-out request and in busy()

Definition at line 227 of file peer_connection.hpp.

connection_negotiation_status graphene::net::peer_connection::negotiation_status = connection_negotiation_status::disconnected

Definition at line 185 of file peer_connection.hpp.

node_id_t graphene::net::peer_connection::node_id

the unique identifier we'll use to refer to the node with. zero-initialized before we receive the hello message, at which time it will be filled with either the "node_id" from the user_data field of the hello, or if none is present it will be filled with a copy of node_public_key

Definition at line 199 of file peer_connection.hpp.

node_id_t graphene::net::peer_connection::node_public_key

data about the peer nodenode_public_key from the hello message, zero-initialized before we get the hello

Definition at line 194 of file peer_connection.hpp.

uint32_t graphene::net::peer_connection::number_of_unfetched_item_ids = 0

list of all items this peer has offered use that we've already handed to the client but the client hasn't finished processing

Definition at line 223 of file peer_connection.hpp.

our_connection_state graphene::net::peer_connection::our_state = our_connection_state::disconnected

Definition at line 180 of file peer_connection.hpp.

uint16_t graphene::net::peer_connection::outbound_port = 0

Definition at line 214 of file peer_connection.hpp.

bool graphene::net::peer_connection::peer_needs_sync_items_from_us = false

number of items in the blockchain that follow ids_of_items_to_get but the peer hasn't yet told us their ids

Definition at line 224 of file peer_connection.hpp.

fc::optional<std::string> graphene::net::peer_connection::platform

Definition at line 206 of file peer_connection.hpp.

fc::microseconds graphene::net::peer_connection::round_trip_delay

Definition at line 178 of file peer_connection.hpp.

std::set<item_hash_t> graphene::net::peer_connection::sync_items_requested_from_peer

the time we received the last sync item or the time we sent the last batch of sync item requests to this peer

Definition at line 228 of file peer_connection.hpp.

their_connection_state graphene::net::peer_connection::their_state = their_connection_state::disconnected

Definition at line 182 of file peer_connection.hpp.

bool graphene::net::peer_connection::they_have_requested_close = false

Definition at line 181 of file peer_connection.hpp.

fc::time_point graphene::net::peer_connection::transaction_fetching_inhibited_until

items we've requested from this peer during normal operation. fetch from another peer if this peer disconnects

Definition at line 259 of file peer_connection.hpp.

std::string graphene::net::peer_connection::user_agent

Definition at line 201 of file peer_connection.hpp.

bool graphene::net::peer_connection::we_have_requested_close = false

Definition at line 183 of file peer_connection.hpp.

bool graphene::net::peer_connection::we_need_sync_items_from_peer = false

Definition at line 225 of file peer_connection.hpp.


The documentation for this class was generated from the following files: