Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio Namespace Reference

Namespaces

namespace  chain
 
namespace  chain_apis
 
namespace  client
 
namespace  detail
 
namespace  finality_status
 
namespace  resource_monitor
 
namespace  state_history
 
namespace  test
 
namespace  test_control_apis
 
namespace  testing
 
namespace  trace_api
 
namespace  version
 
namespace  vm
 
namespace  wallet
 
namespace  wasm_backend
 

Classes

struct  async_result_visitor
 
struct  block_buffer_factory
 
class  block_status_monitor
 
struct  buffer_factory
 
class  chain_api_plugin
 
class  chain_api_plugin_impl
 
class  chain_plugin
 
class  chain_plugin_impl
 
struct  chain_size_message
 
class  connection
 
struct  connection_status
 
class  db_size_api_plugin
 
struct  db_size_index_count
 
struct  db_size_stats
 
class  dispatch_manager
 
struct  error_results
 Structure used to create JSON error responses. More...
 
struct  finality_status_object
 tracks status related to a transaction in the blockchain More...
 
class  fixed_bytes
 
class  fixed_key
 
struct  go_away_message
 
struct  handshake_message
 
class  http_client_plugin
 
class  http_plugin
 
struct  http_plugin_defaults
 
class  http_plugin_impl
 
class  login_plugin
 
class  login_plugin_impl
 
struct  login_request
 
struct  login_request_pub_key_index
 
struct  login_request_time_index
 
struct  msg_handler
 
class  multisig
 
class  net_api_plugin
 
class  net_plugin
 
class  net_plugin_impl
 
struct  node_transaction_state
 
struct  notice_message
 
struct  peer_block_state
 
struct  peer_sync_state
 
class  pending_snapshot
 
class  producer_api_plugin
 
class  producer_plugin
 
class  producer_plugin_impl
 
class  queued_buffer
 
struct  request_message
 
class  resource_monitor_plugin
 
class  resource_monitor_plugin_impl
 
struct  select_ids
 
class  state_history_log
 
struct  state_history_log_header
 
struct  state_history_log_prune_config
 
class  state_history_plugin
 
struct  state_history_plugin_impl
 
class  sub_chain_plugin
 
class  sub_chain_plugin_impl
 
class  subjective_billing
 
class  sync_manager
 
struct  sync_request_message
 
class  template_plugin
 
class  template_plugin_impl
 
class  test_control_api_plugin
 
class  test_control_api_plugin_impl
 
class  test_control_plugin
 
class  test_control_plugin_impl
 
struct  time_message
 
class  token
 
struct  trace_api_common_impl
 
class  trace_api_plugin
 
struct  trace_api_plugin_impl
 
class  trace_api_rpc_plugin
 
struct  trace_api_rpc_plugin_impl
 
struct  transaction_id_with_expiry
 
struct  trx_buffer_factory
 
class  txn_test_gen_plugin
 
struct  txn_test_gen_plugin_impl
 
class  wallet_api_plugin
 
class  wallet_plugin
 
class  wrap
 

Typedefs

typedef fixed_key< 32 > key256
 
using vm_type = wasm_interface::vm_type
 
using finality_status_multi_index
 
using websocket_server_type = websocketpp::server<detail::asio_with_stub_log<websocketpp::transport::asio::basic_socket::endpoint>>
 
using websocket_local_server_type = websocketpp::server<detail::asio_local_with_stub_log>
 
using websocket_server_tls_type = websocketpp::server<detail::asio_with_stub_log<websocketpp::transport::asio::tls_socket::endpoint>>
 
using ssl_context_ptr = websocketpp::lib::shared_ptr<websocketpp::lib::asio::ssl::context>
 
using http_plugin_impl_ptr = std::shared_ptr<class http_plugin_impl>
 
using url_response_callback = std::function<void(int,fc::variant)>
 A callback function provided to a URL handler to allow it to specify the HTTP response code and body.
 
using url_handler = std::function<void(string,string,url_response_callback)>
 Callback type for a URL handler.
 
using api_description = std::map<string, url_handler>
 An API, containing URLs and handlers.
 
using login_request_container
 
typedef std::chrono::system_clock::duration::rep tstamp
 
using ordered_txn_ids = select_ids<transaction_id_type>
 
using ordered_blk_ids = select_ids<block_id_type>
 
using net_message
 
using connection_ptr = std::shared_ptr<connection>
 
using connection_wptr = std::weak_ptr<connection>
 
typedef multi_index_container< node_transaction_state, indexed_by< ordered_unique< tag< by_id >, composite_key< node_transaction_state, member< node_transaction_state, transaction_id_type, &node_transaction_state::id >, member< node_transaction_state, uint32_t, &node_transaction_state::connection_id > >, composite_key_compare< sha256_less, std::less< uint32_t > > >, ordered_non_unique< tag< by_expiry >, member< node_transaction_state, fc::time_point_sec, &node_transaction_state::expires > > > > node_transaction_index
 
typedef multi_index_container< sysio::peer_block_state, indexed_by< ordered_unique< tag< by_id >, composite_key< peer_block_state, member< peer_block_state, uint32_t, &sysio::peer_block_state::connection_id >, member< peer_block_state, block_id_type, &sysio::peer_block_state::id > >, composite_key_compare< std::less< uint32_t >, sha256_less > >, ordered_non_unique< tag< by_peer_block_id >, composite_key< peer_block_state, member< peer_block_state, block_id_type, &sysio::peer_block_state::id >, member< peer_block_state, bool, &sysio::peer_block_state::have_block > >, composite_key_compare< sha256_less, std::greater< bool > > >, ordered_non_unique< tag< by_block_num >, member< sysio::peer_block_state, uint32_t, &sysio::peer_block_state::block_num > > > > peer_block_state_index
 
using send_buffer_type = std::shared_ptr<std::vector<char>>
 
using transaction_id_with_expiry_index
 
using pending_snapshot_index
 
typedef shared_ptr< struct state_history_plugin_implstate_history_ptr
 
typedef std::shared_ptr< class test_control_plugin_impltest_control_ptr
 

Enumerations

enum  https_ecdh_curve_t { SECP384R1 , PRIME256V1 }
 
enum class  http_params_types { no_params = 0 , params_required = 1 , possible_no_params = 2 }
 
enum  go_away_reason {
  no_reason , self , duplicate , wrong_chain ,
  wrong_version , forked , unlinkable , bad_transaction ,
  validation , benign_other , fatal_other , authentication
}
 
enum  id_list_modes { none , catch_up , last_irr_catch_up , normal }
 
enum class  pending_block_mode { producing , speculating }
 

Functions

template<size_t Size>
bool operator== (const fixed_key< Size > &c1, const fixed_key< Size > &c2)
 Compares two fixed_key variables c1 and c2.
 
template<size_t Size>
bool operator!= (const fixed_key< Size > &c1, const fixed_key< Size > &c2)
 Compares two fixed_key variables c1 and c2.
 
template<size_t Size>
bool operator> (const fixed_key< Size > &c1, const fixed_key< Size > &c2)
 Compares two fixed_key variables c1 and c2.
 
template<size_t Size>
bool operator< (const fixed_key< Size > &c1, const fixed_key< Size > &c2)
 Compares two fixed_key variables c1 and c2.
 
uint64_t ship_magic (uint16_t version, uint16_t features=0)
 
bool is_ship (uint64_t magic)
 
uint16_t get_ship_version (uint64_t magic)
 
uint16_t get_ship_features (uint64_t magic)
 
bool is_ship_supported_version (uint64_t magic)
 
bool is_ship_log_pruned (uint64_t magic)
 
uint64_t clear_ship_log_pruned_feature (uint64_t magic)
 
template<>
chain_apis::read_only::get_transaction_status_params parse_params< chain_apis::read_only::get_transaction_status_params, http_params_types::params_required > (const std::string &body)
 
fc::time_point calculate_genesis_timestamp (string tstr)
 
void clear_directory_contents (const fc::path &p)
 
void clear_chainbase_files (const fc::path &p)
 
std::optional< builtin_protocol_featureread_builtin_protocol_feature (const fc::path &p)
 
protocol_feature_set initialize_protocol_features (const fc::path &p, bool populate_missing_builtins=true)
 
template<>
bool http_plugin_impl::allow_host< detail::asio_local_with_stub_log > (const detail::asio_local_with_stub_log::request_type &req, websocketpp::server< detail::asio_local_with_stub_log >::connection_ptr con)
 
std::istream & operator>> (std::istream &in, https_ecdh_curve_t &curve)
 
std::ostream & operator<< (std::ostream &osm, https_ecdh_curve_t curve)
 
std::string_view make_trimmed_string_view (const std::string &body)
 Used to trim whitespace from body. Returned string_view valid only for lifetime of body.
 
bool is_empty_content (const std::string &body)
 
template<typename T , http_params_types params_type>
T parse_params (const std::string &body)
 
constexpr auto reason_str (go_away_reason rsn)
 
constexpr auto modes_str (id_list_modes m)
 
template<typename Strand >
void verify_strand_in_this_thread (const Strand &strand, const char *func, int line)
 
const fc::string logger_name ("net_plugin_impl")
 
template<class enum_type , class = typename std::enable_if<std::is_enum<enum_type>::value>::type>
enum_typeoperator|= (enum_type &lhs, const enum_type &rhs)
 
template<typename Function >
void for_each_connection (Function f)
 
template<typename Function >
void for_each_block_connection (Function f)
 
size_t calc_trx_size (const packed_transaction_ptr &trx)
 
template<typename T >
T dejsonify (const string &s)
 
void new_chain_banner (const sysio::chain::controller &db)
 
template<typename F >
auto catch_and_log (F f)
 

Variables

constexpr size_t max_p2p_address_length = 253 + 6
 
constexpr size_t max_handshake_str_length = 384
 
constexpr auto def_send_buffer_size_mb = 4
 
constexpr auto def_send_buffer_size = 1024*1024*def_send_buffer_size_mb
 
constexpr auto def_max_write_queue_size = def_send_buffer_size*10
 
constexpr auto def_max_trx_in_progress_size = 100*1024*1024
 
constexpr auto def_max_consecutive_immediate_connection_close = 9
 
constexpr auto def_max_clients = 25
 
constexpr auto def_max_nodes_per_host = 1
 
constexpr auto def_conn_retry_wait = 30
 
constexpr auto def_txn_expire_wait = std::chrono::seconds(3)
 
constexpr auto def_resp_expected_wait = std::chrono::seconds(5)
 
constexpr auto def_sync_fetch_span = 100
 
constexpr auto def_keepalive_interval = 10000
 
constexpr auto message_header_size = sizeof(uint32_t)
 
constexpr uint32_t signed_block_which = fc::get_index<net_message, signed_block>()
 
constexpr uint32_t packed_transaction_which = fc::get_index<net_message, packed_transaction>()
 
fc::logger logger
 
std::string peer_log_format
 
constexpr uint16_t net_version_base = 0x04b5
 
constexpr uint16_t net_version_range = 106
 
constexpr uint16_t proto_base = 0
 
constexpr uint16_t proto_explicit_sync = 1
 
constexpr uint16_t proto_block_id_notify = 2
 
constexpr uint16_t proto_pruned_types = 3
 
constexpr uint16_t proto_heartbeat_interval = 4
 
constexpr uint16_t proto_dup_goaway_resolution = 5
 
constexpr uint16_t proto_dup_node_id_goaway = 6
 
constexpr uint16_t proto_wire_sysio_initial = 7
 
constexpr uint16_t net_version_max = proto_wire_sysio_initial
 

Typedef Documentation

◆ api_description

An API is composed of several calls, where each call has a URL and a handler. The URL is the path on the web server that triggers the call, and the handler is the function which implements the API call

Definition at line 38 of file http_plugin.hpp.

◆ connection_ptr

using sysio::connection_ptr = std::shared_ptr<connection>

Definition at line 50 of file net_plugin.cpp.

◆ connection_wptr

using sysio::connection_wptr = std::weak_ptr<connection>

Definition at line 51 of file net_plugin.cpp.

◆ finality_status_multi_index

Initial value:
boost::multi_index_container<
finality_status_object,
indexed_by<
bmi::hashed_unique< tag<finality_status::by_trx_id>,
member<finality_status_object, chain::transaction_id_type, &finality_status_object::trx_id> >,
ordered_non_unique< tag<finality_status::by_status_expiry>,
composite_key< finality_status_object,
const_mem_fun<finality_status_object, bool, &finality_status_object::is_in_block>,
member< finality_status_object, fc::time_point, &finality_status_object::received >
>
>,
ordered_non_unique< tag<finality_status::by_block_num>,
const_mem_fun<finality_status_object, uint32_t, &finality_status_object::block_num> >
>
>

Definition at line 44 of file finality_status_object.hpp.

◆ http_plugin_impl_ptr

Definition at line 175 of file http_plugin.cpp.

◆ key256

typedef fixed_key<32> sysio::key256

Definition at line 220 of file fixed_key.hpp.

◆ login_request_container

Initial value:
boost::multi_index_container<
login_request,
indexed_by<
ordered_unique<tag<login_request_pub_key_index>,
member<login_request, chain::public_key_type, &login_request::server_ephemeral_pub_key>>,
ordered_non_unique<tag<login_request_time_index>,
member<login_request, chain::time_point_sec, &login_request::expiration_time>>
>>

Definition at line 22 of file login_plugin.cpp.

◆ net_message

Initial value:
std::variant<handshake_message,
chain_size_message,
go_away_message,
time_message,
notice_message,
request_message,
sync_request_message,
signed_block,
packed_transaction>

Definition at line 138 of file protocol.hpp.

◆ node_transaction_index

typedef multi_index_container< node_transaction_state, indexed_by< ordered_unique< tag<by_id>, composite_key< node_transaction_state, member<node_transaction_state, transaction_id_type, &node_transaction_state::id>, member<node_transaction_state, uint32_t, &node_transaction_state::connection_id> >, composite_key_compare< sha256_less, std::less<uint32_t> > >, ordered_non_unique< tag< by_expiry >, member< node_transaction_state, fc::time_point_sec, &node_transaction_state::expires > > > > sysio::node_transaction_index

Definition at line 85 of file net_plugin.cpp.

◆ ordered_blk_ids

Definition at line 119 of file protocol.hpp.

◆ ordered_txn_ids

◆ peer_block_state_index

typedef multi_index_container< sysio::peer_block_state, indexed_by< ordered_unique< tag<by_id>, composite_key< peer_block_state, member<peer_block_state, uint32_t, &sysio::peer_block_state::connection_id>, member<peer_block_state, block_id_type, &sysio::peer_block_state::id> >, composite_key_compare< std::less<uint32_t>, sha256_less > >, ordered_non_unique< tag<by_peer_block_id>, composite_key< peer_block_state, member<peer_block_state, block_id_type, &sysio::peer_block_state::id>, member<peer_block_state, bool, &sysio::peer_block_state::have_block> >, composite_key_compare< sha256_less, std::greater<bool> > >, ordered_non_unique< tag<by_block_num>, member<sysio::peer_block_state, uint32_t, &sysio::peer_block_state::block_num > > > > sysio::peer_block_state_index

Definition at line 116 of file net_plugin.cpp.

◆ pending_snapshot_index

Initial value:
multi_index_container<
pending_snapshot,
indexed_by<
hashed_unique<tag<by_id>, BOOST_MULTI_INDEX_MEMBER(pending_snapshot, block_id_type, block_id)>,
ordered_non_unique<tag<by_height>, BOOST_MULTI_INDEX_CONST_MEM_FUN( pending_snapshot, uint32_t, get_height)>
>
>
unsigned int uint32_t
Definition stdint.h:126

Definition at line 177 of file producer_plugin.cpp.

◆ send_buffer_type

using sysio::send_buffer_type = std::shared_ptr<std::vector<char>>

Definition at line 1320 of file net_plugin.cpp.

◆ ssl_context_ptr

using sysio::ssl_context_ptr = websocketpp::lib::shared_ptr<websocketpp::lib::asio::ssl::context>

Definition at line 174 of file http_plugin.cpp.

◆ state_history_ptr

Definition at line 15 of file state_history_plugin.hpp.

◆ test_control_ptr

Definition at line 11 of file test_control_plugin.hpp.

◆ transaction_id_with_expiry_index

Initial value:
multi_index_container<
transaction_id_with_expiry,
indexed_by<
hashed_unique<tag<by_id>, BOOST_MULTI_INDEX_MEMBER(transaction_id_with_expiry, transaction_id_type, trx_id)>,
ordered_non_unique<tag<by_expiry>, BOOST_MULTI_INDEX_MEMBER(transaction_id_with_expiry, fc::time_point, expiry)>
>
>

Definition at line 112 of file producer_plugin.cpp.

◆ tstamp

typedef std::chrono::system_clock::duration::rep sysio::tstamp

Definition at line 11 of file protocol.hpp.

◆ url_handler

using sysio::url_handler = std::function<void(string,string,url_response_callback)>

URL handlers have this type

The handler must gaurantee that url_response_callback() is called; otherwise, the connection will hang and result in a memory leak.

Arguments: url, request_body, response_callback

Definition at line 29 of file http_plugin.hpp.

◆ url_response_callback

using sysio::url_response_callback = std::function<void(int,fc::variant)>

Arguments: response_code, response_body

Definition at line 17 of file http_plugin.hpp.

◆ vm_type

Definition at line 131 of file chain_plugin.cpp.

◆ websocket_local_server_type

◆ websocket_server_tls_type

◆ websocket_server_type

Enumeration Type Documentation

◆ go_away_reason

Enumerator
no_reason 

no reason to go away

self 

the connection is to itself

duplicate 

the connection is redundant

wrong_chain 

the peer's chain id doesn't match

wrong_version 

the peer's network version doesn't match

forked 

the peer's irreversible blocks are different

unlinkable 

the peer sent a block we couldn't use

bad_transaction 

the peer sent a transaction that failed verification

validation 

the peer sent a block that failed validation

benign_other 

reasons such as a timeout. not fatal but warrant resetting

fatal_other 

a catch-all for errors we don't have discriminated

authentication 

peer failed authenicatio

Definition at line 46 of file protocol.hpp.

46 {
47 no_reason,
48 self,
49 duplicate,
52 forked,
55 validation,
59 };
@ duplicate
the connection is redundant
Definition protocol.hpp:49
@ self
the connection is to itself
Definition protocol.hpp:48
@ no_reason
no reason to go away
Definition protocol.hpp:47
@ wrong_chain
the peer's chain id doesn't match
Definition protocol.hpp:50
@ wrong_version
the peer's network version doesn't match
Definition protocol.hpp:51
@ unlinkable
the peer sent a block we couldn't use
Definition protocol.hpp:53
@ bad_transaction
the peer sent a transaction that failed verification
Definition protocol.hpp:54
@ fatal_other
a catch-all for errors we don't have discriminated
Definition protocol.hpp:57
@ forked
the peer's irreversible blocks are different
Definition protocol.hpp:52
@ authentication
peer failed authenicatio
Definition protocol.hpp:58
@ benign_other
reasons such as a timeout. not fatal but warrant resetting
Definition protocol.hpp:56

◆ http_params_types

Enumerator
no_params 
params_required 
possible_no_params 

Definition at line 215 of file http_plugin.hpp.

◆ https_ecdh_curve_t

Enumerator
SECP384R1 
PRIME256V1 

Definition at line 48 of file http_plugin.cpp.

48 {
51 };

◆ id_list_modes

Enumerator
none 
catch_up 
last_irr_catch_up 
normal 

Definition at line 92 of file protocol.hpp.

92 {
93 none,
96 normal
97 };
@ normal
Definition protocol.hpp:96
@ last_irr_catch_up
Definition protocol.hpp:95
@ catch_up
Definition protocol.hpp:94

◆ pending_block_mode

Enumerator
producing 
speculating 

Definition at line 185 of file producer_plugin.cpp.

Function Documentation

◆ calc_trx_size()

size_t sysio::calc_trx_size ( const packed_transaction_ptr & trx)

Definition at line 3106 of file net_plugin.cpp.

3106 {
3107 return trx->get_estimated_size();
3108 }
Here is the caller graph for this function:

◆ calculate_genesis_timestamp()

fc::time_point sysio::calculate_genesis_timestamp ( string tstr)

Definition at line 386 of file chain_plugin.cpp.

386 {
387 fc::time_point genesis_timestamp;
388 if( strcasecmp (tstr.c_str(), "now") == 0 ) {
389 genesis_timestamp = fc::time_point::now();
390 } else {
391 genesis_timestamp = time_point::from_iso_string( tstr );
392 }
393
394 auto epoch_us = genesis_timestamp.time_since_epoch().count();
395 auto diff_us = epoch_us % config::block_interval_us;
396 if (diff_us > 0) {
397 auto delay_us = (config::block_interval_us - diff_us);
398 genesis_timestamp += fc::microseconds(delay_us);
399 dlog("pausing ${us} microseconds to the next interval",("us",delay_us));
400 }
401
402 ilog( "Adjusting genesis timestamp to ${timestamp}", ("timestamp", genesis_timestamp) );
403 return genesis_timestamp;
404}
constexpr int64_t count() const
Definition time.hpp:26
static time_point now()
Definition time.cpp:14
constexpr const microseconds & time_since_epoch() const
Definition time.hpp:52
#define dlog(FORMAT,...)
Definition logger.hpp:101
#define ilog(FORMAT,...)
Definition logger.hpp:118
Here is the call graph for this function:
Here is the caller graph for this function:

◆ catch_and_log()

template<typename F >
auto sysio::catch_and_log ( F f)

Definition at line 31 of file state_history_plugin.cpp.

31 {
32 try {
33 return f();
34 } catch (const fc::exception& e) {
35 elog("${e}", ("e", e.to_detail_string()));
36 } catch (const std::exception& e) {
37 elog("${e}", ("e", e.what()));
38 } catch (...) {
39 elog("unknown exception");
40 }
41}
Used to generate a useful error report when an exception is thrown.
Definition exception.hpp:58
std::string to_detail_string(log_level ll=log_level::all) const
#define elog(FORMAT,...)
Definition logger.hpp:130
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear_chainbase_files()

void sysio::clear_chainbase_files ( const fc::path & p)

Definition at line 417 of file chain_plugin.cpp.

417 {
418 if( !fc::is_directory( p ) )
419 return;
420
421 fc::remove( p / "shared_memory.bin" );
422 fc::remove( p / "shared_memory.meta" );
423}
const mie::Vuint & p
Definition bn.cpp:27
bool remove(const path &p)
bool is_directory(const path &p)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear_directory_contents()

void sysio::clear_directory_contents ( const fc::path & p)

Definition at line 406 of file chain_plugin.cpp.

406 {
407 using boost::filesystem::directory_iterator;
408
409 if( !fc::is_directory( p ) )
410 return;
411
412 for( directory_iterator enditr, itr{p}; itr != enditr; ++itr ) {
413 fc::remove_all( itr->path() );
414 }
415}
void remove_all(const path &p)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear_ship_log_pruned_feature()

uint64_t sysio::clear_ship_log_pruned_feature ( uint64_t magic)
inline

Definition at line 52 of file log.hpp.

52{ return ship_magic(get_ship_version(magic), get_ship_features(magic) & ~ship_feature_pruned_log); }
uint16_t get_ship_features(uint64_t magic)
Definition log.hpp:47
uint16_t get_ship_version(uint64_t magic)
Definition log.hpp:46
uint64_t ship_magic(uint16_t version, uint16_t features=0)
Definition log.hpp:38
Here is the call graph for this function:

◆ dejsonify()

template<typename T >
T sysio::dejsonify ( const string & s)

Definition at line 3592 of file net_plugin.cpp.

3592 {
3593 return fc::json::from_string(s).as<T>();
3594 }
static variant from_string(const string &utf8_str, const parse_type ptype=parse_type::legacy_parser, uint32_t max_depth=DEFAULT_MAX_RECURSION_DEPTH)
Definition json.cpp:442
T as() const
Definition variant.hpp:327
#define T(meth, val, expected)
char * s
Here is the call graph for this function:
Here is the caller graph for this function:

◆ for_each_block_connection()

template<typename Function >
void sysio::for_each_block_connection ( Function f)

Definition at line 868 of file net_plugin.cpp.

868 {
869 std::shared_lock<std::shared_mutex> g( my_impl->connections_mtx );
870 for( auto& c : my_impl->connections ) {
871 if( c->is_transactions_only_connection() ) continue;
872 if( !f( c ) ) return;
873 }
874 }
std::shared_mutex connections_mtx
std::set< connection_ptr > connections
Here is the caller graph for this function:

◆ for_each_connection()

template<typename Function >
void sysio::for_each_connection ( Function f)

Definition at line 860 of file net_plugin.cpp.

860 {
861 std::shared_lock<std::shared_mutex> g( my_impl->connections_mtx );
862 for( auto& c : my_impl->connections ) {
863 if( !f( c ) ) return;
864 }
865 }
Here is the caller graph for this function:

◆ get_ship_features()

uint16_t sysio::get_ship_features ( uint64_t magic)
inline

Definition at line 47 of file log.hpp.

47{ return magic>>16; }
Here is the caller graph for this function:

◆ get_ship_version()

uint16_t sysio::get_ship_version ( uint64_t magic)
inline

Definition at line 46 of file log.hpp.

46{ return magic; }
Here is the caller graph for this function:

◆ http_plugin_impl::allow_host< detail::asio_local_with_stub_log >()

◆ initialize_protocol_features()

protocol_feature_set sysio::initialize_protocol_features ( const fc::path & p,
bool populate_missing_builtins = true )

Definition at line 438 of file chain_plugin.cpp.

438 {
439 using boost::filesystem::directory_iterator;
440
442
443 bool directory_exists = true;
444
445 if( fc::exists( p ) ) {
446 SYS_ASSERT( fc::is_directory( p ), plugin_exception,
447 "Path to protocol-features is not a directory: ${path}",
448 ("path", p.generic_string())
449 );
450 } else {
451 if( populate_missing_builtins )
452 bfs::create_directories( p );
453 else
454 directory_exists = false;
455 }
456
457 auto log_recognized_protocol_feature = []( const builtin_protocol_feature& f, const digest_type& feature_digest ) {
458 if( f.subjective_restrictions.enabled ) {
459 if( f.subjective_restrictions.preactivation_required ) {
460 if( f.subjective_restrictions.earliest_allowed_activation_time == time_point{} ) {
461 ilog( "Support for builtin protocol feature '${codename}' (with digest of '${digest}') is enabled with preactivation required",
462 ("codename", builtin_protocol_feature_codename(f.get_codename()))
463 ("digest", feature_digest)
464 );
465 } else {
466 ilog( "Support for builtin protocol feature '${codename}' (with digest of '${digest}') is enabled with preactivation required and with an earliest allowed activation time of ${earliest_time}",
467 ("codename", builtin_protocol_feature_codename(f.get_codename()))
468 ("digest", feature_digest)
469 ("earliest_time", f.subjective_restrictions.earliest_allowed_activation_time)
470 );
471 }
472 } else {
473 if( f.subjective_restrictions.earliest_allowed_activation_time == time_point{} ) {
474 ilog( "Support for builtin protocol feature '${codename}' (with digest of '${digest}') is enabled without activation restrictions",
475 ("codename", builtin_protocol_feature_codename(f.get_codename()))
476 ("digest", feature_digest)
477 );
478 } else {
479 ilog( "Support for builtin protocol feature '${codename}' (with digest of '${digest}') is enabled without preactivation required but with an earliest allowed activation time of ${earliest_time}",
480 ("codename", builtin_protocol_feature_codename(f.get_codename()))
481 ("digest", feature_digest)
482 ("earliest_time", f.subjective_restrictions.earliest_allowed_activation_time)
483 );
484 }
485 }
486 } else {
487 ilog( "Recognized builtin protocol feature '${codename}' (with digest of '${digest}') but support for it is not enabled",
488 ("codename", builtin_protocol_feature_codename(f.get_codename()))
489 ("digest", feature_digest)
490 );
491 }
492 };
493
494 map<builtin_protocol_feature_t, fc::path> found_builtin_protocol_features;
495 map<digest_type, std::pair<builtin_protocol_feature, bool> > builtin_protocol_features_to_add;
496 // The bool in the pair is set to true if the builtin protocol feature has already been visited to add
497 map< builtin_protocol_feature_t, std::optional<digest_type> > visited_builtins;
498
499 // Read all builtin protocol features
500 if( directory_exists ) {
501 for( directory_iterator enditr, itr{p}; itr != enditr; ++itr ) {
502 auto file_path = itr->path();
503 if( !fc::is_regular_file( file_path ) || file_path.extension().generic_string().compare( ".json" ) != 0 )
504 continue;
505
506 auto f = read_builtin_protocol_feature( file_path );
507
508 if( !f ) continue;
509
510 auto res = found_builtin_protocol_features.emplace( f->get_codename(), file_path );
511
512 SYS_ASSERT( res.second, plugin_exception,
513 "Builtin protocol feature '${codename}' was already included from a previous_file",
514 ("codename", builtin_protocol_feature_codename(f->get_codename()))
515 ("current_file", file_path.generic_string())
516 ("previous_file", res.first->second.generic_string())
517 );
518
519 const auto feature_digest = f->digest();
520
521 builtin_protocol_features_to_add.emplace( std::piecewise_construct,
522 std::forward_as_tuple( feature_digest ),
523 std::forward_as_tuple( *f, false ) );
524 }
525 }
526
527 // Add builtin protocol features to the protocol feature manager in the right order (to satisfy dependencies)
528 using itr_type = map<digest_type, std::pair<builtin_protocol_feature, bool>>::iterator;
529 std::function<void(const itr_type&)> add_protocol_feature =
530 [&pfs, &builtin_protocol_features_to_add, &visited_builtins, &log_recognized_protocol_feature, &add_protocol_feature]( const itr_type& itr ) -> void {
531 if( itr->second.second ) {
532 return;
533 } else {
534 itr->second.second = true;
535 visited_builtins.emplace( itr->second.first.get_codename(), itr->first );
536 }
537
538 for( const auto& d : itr->second.first.dependencies ) {
539 auto itr2 = builtin_protocol_features_to_add.find( d );
540 if( itr2 != builtin_protocol_features_to_add.end() ) {
541 add_protocol_feature( itr2 );
542 }
543 }
544
545 pfs.add_feature( itr->second.first );
546
547 log_recognized_protocol_feature( itr->second.first, itr->first );
548 };
549
550 for( auto itr = builtin_protocol_features_to_add.begin(); itr != builtin_protocol_features_to_add.end(); ++itr ) {
551 add_protocol_feature( itr );
552 }
553
554 auto output_protocol_feature = [&p]( const builtin_protocol_feature& f, const digest_type& feature_digest ) {
555 string filename( "BUILTIN-" );
556 filename += builtin_protocol_feature_codename( f.get_codename() );
557 filename += ".json";
558
559 auto file_path = p / filename;
560
561 SYS_ASSERT( !fc::exists( file_path ), plugin_exception,
562 "Could not save builtin protocol feature with codename '${codename}' because a file at the following path already exists: ${path}",
563 ("codename", builtin_protocol_feature_codename( f.get_codename() ))
564 ("path", file_path.generic_string())
565 );
566
567 if( fc::json::save_to_file( f, file_path ) ) {
568 ilog( "Saved default specification for builtin protocol feature '${codename}' (with digest of '${digest}') to: ${path}",
569 ("codename", builtin_protocol_feature_codename(f.get_codename()))
570 ("digest", feature_digest)
571 ("path", file_path.generic_string())
572 );
573 } else {
574 elog( "Error occurred while writing default specification for builtin protocol feature '${codename}' (with digest of '${digest}') to: ${path}",
575 ("codename", builtin_protocol_feature_codename(f.get_codename()))
576 ("digest", feature_digest)
577 ("path", file_path.generic_string())
578 );
579 }
580 };
581
582 std::function<digest_type(builtin_protocol_feature_t)> add_missing_builtins =
583 [&pfs, &visited_builtins, &output_protocol_feature, &log_recognized_protocol_feature, &add_missing_builtins, populate_missing_builtins]
584 ( builtin_protocol_feature_t codename ) -> digest_type {
585 auto res = visited_builtins.emplace( codename, std::optional<digest_type>() );
586 if( !res.second ) {
587 SYS_ASSERT( res.first->second, protocol_feature_exception,
588 "invariant failure: cycle found in builtin protocol feature dependencies"
589 );
590 return *res.first->second;
591 }
592
593 auto f = protocol_feature_set::make_default_builtin_protocol_feature( codename,
594 [&add_missing_builtins]( builtin_protocol_feature_t d ) {
595 return add_missing_builtins( d );
596 } );
597
598 if( !populate_missing_builtins )
599 f.subjective_restrictions.enabled = false;
600
601 const auto& pf = pfs.add_feature( f );
602 res.first->second = pf.feature_digest;
603
604 log_recognized_protocol_feature( f, pf.feature_digest );
605
606 if( populate_missing_builtins )
607 output_protocol_feature( f, pf.feature_digest );
608
609 return pf.feature_digest;
610 };
611
612 for( const auto& p : builtin_protocol_feature_codenames ) {
613 auto itr = found_builtin_protocol_features.find( p.first );
614 if( itr != found_builtin_protocol_features.end() ) continue;
615
616 add_missing_builtins( p.first );
617 }
618
619 return pfs;
620}
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
Definition exceptions.hpp:7
static bool save_to_file(const T &v, const fc::path &fi, const bool pretty=true, const output_formatting format=output_formatting::stringify_large_ints_and_doubles)
Definition json.hpp:45
const protocol_feature & add_feature(const builtin_protocol_feature &f)
bool exists(const path &p)
bool is_regular_file(const path &p)
checksum_type digest_type
Definition types.hpp:237
const char * builtin_protocol_feature_codename(builtin_protocol_feature_t)
std::optional< builtin_protocol_feature > read_builtin_protocol_feature(const fc::path &p)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_empty_content()

bool sysio::is_empty_content ( const std::string & body)
inline

Definition at line 195 of file http_plugin.hpp.

195 {
196 const auto trimmed_body_view = make_trimmed_string_view(body);
197 if (trimmed_body_view.empty()) {
198 return true;
199 }
200 const size_t body_size = trimmed_body_view.size();
201 if ((body_size > 1) && (trimmed_body_view.at(0) == '{') && (trimmed_body_view.at(body_size - 1) == '}')) {
202 for(size_t idx=1; idx<body_size-1; ++idx)
203 {
204 if ((trimmed_body_view.at(idx) != ' ') && (trimmed_body_view.at(idx) != '\t'))
205 {
206 return false;
207 }
208 }
209 } else {
210 return false;
211 }
212 return true;
213 }
std::string_view make_trimmed_string_view(const std::string &body)
Used to trim whitespace from body. Returned string_view valid only for lifetime of body.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_ship()

bool sysio::is_ship ( uint64_t magic)
inline

Definition at line 42 of file log.hpp.

42 {
43 using namespace sysio::chain::literals;
44 return (magic & 0xffff'ffff'0000'0000) == "ship"_n.to_uint64_t();
45}
Here is the caller graph for this function:

◆ is_ship_log_pruned()

bool sysio::is_ship_log_pruned ( uint64_t magic)
inline

Definition at line 51 of file log.hpp.

51{ return get_ship_features(magic) & ship_feature_pruned_log; }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_ship_supported_version()

bool sysio::is_ship_supported_version ( uint64_t magic)
inline

Definition at line 48 of file log.hpp.

48{ return get_ship_version(magic) == 0; }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ logger_name()

const fc::string sysio::logger_name ( "net_plugin_impl" )
Here is the caller graph for this function:

◆ make_trimmed_string_view()

std::string_view sysio::make_trimmed_string_view ( const std::string & body)
inline

Definition at line 166 of file http_plugin.hpp.

166 {
167 if (body.empty()) {
168 return {};
169 }
170 size_t left = 0;
171 size_t right = body.size() - 1;
172
173 while(left < right)
174 {
175 if (body[left] == ' ') {
176 ++left;
177 } else {
178 break;
179 }
180 }
181 while(left < right)
182 {
183 if (body[right] == ' ') {
184 --right;
185 } else {
186 break;
187 }
188 }
189 if ((left == right) && (body[left] == ' ')) {
190 return {};
191 }
192 return std::string_view(body).substr(left, right-left+1);
193 }
Here is the caller graph for this function:

◆ modes_str()

auto sysio::modes_str ( id_list_modes m)
constexpr

Definition at line 99 of file protocol.hpp.

99 {
100 switch( m ) {
101 case none : return "none";
102 case catch_up : return "catch up";
103 case last_irr_catch_up : return "last irreversible";
104 case normal : return "normal";
105 default: return "undefined mode";
106 }
107 }
Here is the caller graph for this function:

◆ new_chain_banner()

void sysio::new_chain_banner ( const sysio::chain::controller & db)

Definition at line 803 of file producer_plugin.cpp.

804{
805 std::cerr << "\n"
806 "*******************************\n"
807 "* *\n"
808 "* ------ NEW CHAIN ------ *\n"
809 "* - Welcome to SYSIO! - *\n"
810 "* ----------------------- *\n"
811 "* *\n"
812 "*******************************\n"
813 "\n";
814
815 if( db.head_block_state()->header.timestamp.to_time_point() < (fc::time_point::now() - fc::milliseconds(200 * config::block_interval_ms)))
816 {
817 std::cerr << "Your genesis seems to have an old timestamp\n"
818 "Please consider using the --genesis-timestamp option to give your genesis a recent timestamp\n"
819 "\n"
820 ;
821 }
822 return;
823}
block_state_ptr head_block_state() const
constexpr microseconds milliseconds(int64_t s)
Definition time.hpp:33
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator<<()

std::ostream & sysio::operator<< ( std::ostream & osm,
https_ecdh_curve_t curve )

Definition at line 1011 of file http_plugin.cpp.

1011 {
1012 if (curve == SECP384R1) {
1013 osm << "secp384r1";
1014 } else if (curve == PRIME256V1) {
1015 osm << "prime256v1";
1016 }
1017
1018 return osm;
1019 }

◆ operator>>()

std::istream & sysio::operator>> ( std::istream & in,
https_ecdh_curve_t & curve )

Definition at line 999 of file http_plugin.cpp.

999 {
1000 std::string s;
1001 in >> s;
1002 if (s == "secp384r1")
1003 curve = SECP384R1;
1004 else if (s == "prime256v1")
1005 curve = PRIME256V1;
1006 else
1007 in.setstate(std::ios_base::failbit);
1008 return in;
1009 }

◆ operator|=()

template<class enum_type , class = typename std::enable_if<std::is_enum<enum_type>::value>::type>
enum_type & sysio::operator|= ( enum_type & lhs,
const enum_type & rhs )
inline

Definition at line 393 of file net_plugin.cpp.

394 {
395 using T = std::underlying_type_t <enum_type>;
396 return lhs = static_cast<enum_type>(static_cast<T>(lhs) | static_cast<T>(rhs));
397 }

◆ parse_params()

template<typename T , http_params_types params_type>
T sysio::parse_params ( const std::string & body)

Definition at line 222 of file http_plugin.hpp.

222 {
223 if constexpr (params_type == http_params_types::params_required) {
224 if (is_empty_content(body)) {
225 SYS_THROW(chain::invalid_http_request, "A Request body is required");
226 }
227 }
228
229 try {
230 try {
231 if constexpr (params_type == http_params_types::no_params || params_type == http_params_types::possible_no_params) {
232 if (is_empty_content(body)) {
233 if constexpr (std::is_same_v<T, std::string>) {
234 return std::string("{}");
235 }
236 return {};
237 }
238 if constexpr (params_type == http_params_types::no_params) {
239 SYS_THROW(chain::invalid_http_request, "no parameter should be given");
240 }
241 }
242 return fc::json::from_string(body).as<T>();
243 } catch (const chain::chain_exception& e) { // SYS_RETHROW_EXCEPTIONS does not re-type these so, re-code it
244 throw fc::exception(e);
245 }
246 } SYS_RETHROW_EXCEPTIONS(chain::invalid_http_request, "Unable to parse valid input from POST body");
247 }
#define SYS_THROW(exc_type, FORMAT,...)
#define SYS_RETHROW_EXCEPTIONS(exception_type, FORMAT,...)
bool is_empty_content(const std::string &body)
Here is the call graph for this function:

◆ parse_params< chain_apis::read_only::get_transaction_status_params, http_params_types::params_required >()

Definition at line 36 of file chain_api_plugin.cpp.

37 {
38 if (body.empty()) {
39 SYS_THROW(chain::invalid_http_request, "A Request body is required");
40 }
41
42 try {
43 auto v = fc::json::from_string( body ).as<chain_apis::read_only::get_transaction_status_params>();
44 if( v.id == transaction_id_type() ) throw false;
45 return v;
46 } catch( ... ) {
47 SYS_THROW(chain::invalid_http_request, "Invalid transaction id");
48 }
49}
Here is the call graph for this function:

◆ read_builtin_protocol_feature()

std::optional< builtin_protocol_feature > sysio::read_builtin_protocol_feature ( const fc::path & p)

Definition at line 425 of file chain_plugin.cpp.

425 {
426 try {
428 } catch( const fc::exception& e ) {
429 wlog( "problem encountered while reading '${path}':\n${details}",
430 ("path", p.generic_string())("details",e.to_detail_string()) );
431 } catch( ... ) {
432 dlog( "unknown problem encountered while reading '${path}'",
433 ("path", p.generic_string()) );
434 }
435 return {};
436}
static variant from_file(const fc::path &p, const parse_type ptype=parse_type::legacy_parser, const uint32_t max_depth=DEFAULT_MAX_RECURSION_DEPTH)
Definition json.cpp:797
#define wlog(FORMAT,...)
Definition logger.hpp:124
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reason_str()

auto sysio::reason_str ( go_away_reason rsn)
constexpr

Definition at line 61 of file protocol.hpp.

61 {
62 switch (rsn ) {
63 case no_reason : return "no reason";
64 case self : return "self connect";
65 case duplicate : return "duplicate";
66 case wrong_chain : return "wrong chain";
67 case wrong_version : return "wrong version";
68 case forked : return "chain is forked";
69 case unlinkable : return "unlinkable block received";
70 case bad_transaction : return "bad transaction";
71 case validation : return "invalid block";
72 case authentication : return "authentication failure";
73 case fatal_other : return "some other failure";
74 case benign_other : return "some other non-fatal condition, possibly unknown block";
75 default : return "some crazy reason";
76 }
77 }
Here is the caller graph for this function:

◆ ship_magic()

uint64_t sysio::ship_magic ( uint16_t version,
uint16_t features = 0 )
inline

Definition at line 38 of file log.hpp.

38 {
39 using namespace sysio::chain::literals;
40 return "ship"_n.to_uint64_t() | version | features<<16;
41}
Here is the caller graph for this function:

◆ verify_strand_in_this_thread()

template<typename Strand >
void sysio::verify_strand_in_this_thread ( const Strand & strand,
const char * func,
int line )

Definition at line 54 of file net_plugin.cpp.

54 {
55 if( !strand.running_in_this_thread() ) {
56 elog( "wrong strand: ${f} : line ${n}, exiting", ("f", func)("n", line) );
57 app().quit();
58 }
59 }
application & app()
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ def_conn_retry_wait

auto sysio::def_conn_retry_wait = 30
constexpr

Definition at line 208 of file net_plugin.cpp.

◆ def_keepalive_interval

auto sysio::def_keepalive_interval = 10000
constexpr

Definition at line 212 of file net_plugin.cpp.

◆ def_max_clients

auto sysio::def_max_clients = 25
constexpr

Definition at line 206 of file net_plugin.cpp.

◆ def_max_consecutive_immediate_connection_close

auto sysio::def_max_consecutive_immediate_connection_close = 9
constexpr

Definition at line 205 of file net_plugin.cpp.

◆ def_max_nodes_per_host

auto sysio::def_max_nodes_per_host = 1
constexpr

Definition at line 207 of file net_plugin.cpp.

◆ def_max_trx_in_progress_size

auto sysio::def_max_trx_in_progress_size = 100*1024*1024
constexpr

Definition at line 204 of file net_plugin.cpp.

◆ def_max_write_queue_size

auto sysio::def_max_write_queue_size = def_send_buffer_size*10
constexpr

Definition at line 203 of file net_plugin.cpp.

◆ def_resp_expected_wait

auto sysio::def_resp_expected_wait = std::chrono::seconds(5)
constexpr

Definition at line 210 of file net_plugin.cpp.

◆ def_send_buffer_size

auto sysio::def_send_buffer_size = 1024*1024*def_send_buffer_size_mb
constexpr

Definition at line 202 of file net_plugin.cpp.

◆ def_send_buffer_size_mb

auto sysio::def_send_buffer_size_mb = 4
constexpr

default value initializers

Definition at line 201 of file net_plugin.cpp.

◆ def_sync_fetch_span

auto sysio::def_sync_fetch_span = 100
constexpr

Definition at line 211 of file net_plugin.cpp.

◆ def_txn_expire_wait

auto sysio::def_txn_expire_wait = std::chrono::seconds(3)
constexpr

Definition at line 209 of file net_plugin.cpp.

◆ logger

Definition at line 355 of file net_plugin.cpp.

◆ max_handshake_str_length

size_t sysio::max_handshake_str_length = 384
constexpr

Definition at line 25 of file protocol.hpp.

◆ max_p2p_address_length

size_t sysio::max_p2p_address_length = 253 + 6
constexpr

Definition at line 24 of file protocol.hpp.

◆ message_header_size

auto sysio::message_header_size = sizeof(uint32_t)
constexpr

Definition at line 214 of file net_plugin.cpp.

◆ net_version_base

uint16_t sysio::net_version_base = 0x04b5
constexpr

For a while, network version was a 16 bit value equal to the second set of 16 bits of the current build's git commit id. We are now replacing that with an integer protocol identifier. Based on historical analysis of all git commit identifiers, the larges gap between ajacent commit id values is shown below. these numbers were found with the following commands on the master branch:

git log | grep "^commit" | awk '{print substr($2,5,4)}' | sort -u > sorted.txt rm -f gap.txt; prev=0; for a in $(cat sorted.txt); do echo $prev $((0x$a - 0x$prev)) $a >> gap.txt; prev=$a; done; sort -k2 -n gap.txt | tail

DO NOT EDIT net_version_base OR net_version_range!

Definition at line 413 of file net_plugin.cpp.

◆ net_version_max

uint16_t sysio::net_version_max = proto_wire_sysio_initial
constexpr

Definition at line 431 of file net_plugin.cpp.

◆ net_version_range

uint16_t sysio::net_version_range = 106
constexpr

Definition at line 414 of file net_plugin.cpp.

◆ packed_transaction_which

uint32_t sysio::packed_transaction_which = fc::get_index<net_message, packed_transaction>()
constexpr

Definition at line 216 of file net_plugin.cpp.

◆ peer_log_format

std::string sysio::peer_log_format

Definition at line 356 of file net_plugin.cpp.

◆ proto_base

uint16_t sysio::proto_base = 0
constexpr

If there is a change to network protocol or behavior, increment net version to identify the need for compatibility hooks

Definition at line 421 of file net_plugin.cpp.

◆ proto_block_id_notify

uint16_t sysio::proto_block_id_notify = 2
constexpr

Definition at line 423 of file net_plugin.cpp.

◆ proto_dup_goaway_resolution

uint16_t sysio::proto_dup_goaway_resolution = 5
constexpr

Definition at line 426 of file net_plugin.cpp.

◆ proto_dup_node_id_goaway

uint16_t sysio::proto_dup_node_id_goaway = 6
constexpr

Definition at line 427 of file net_plugin.cpp.

◆ proto_explicit_sync

uint16_t sysio::proto_explicit_sync = 1
constexpr

Definition at line 422 of file net_plugin.cpp.

◆ proto_heartbeat_interval

uint16_t sysio::proto_heartbeat_interval = 4
constexpr

Definition at line 425 of file net_plugin.cpp.

◆ proto_pruned_types

uint16_t sysio::proto_pruned_types = 3
constexpr

Definition at line 424 of file net_plugin.cpp.

◆ proto_wire_sysio_initial

uint16_t sysio::proto_wire_sysio_initial = 7
constexpr

Definition at line 428 of file net_plugin.cpp.

◆ signed_block_which

uint32_t sysio::signed_block_which = fc::get_index<net_message, signed_block>()
constexpr

Definition at line 215 of file net_plugin.cpp.