Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

incremental improvement for the p2p networking #107

Merged
merged 1 commit into from
Jul 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions plugins/net_plugin/include/eos/net_plugin/protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ namespace eos {
using namespace chain;
using namespace fc;

using node_id_type = fc::sha256;

struct handshake_message {
int16_t network_version = 0;
chain_id_type chain_id; ///< used to identify chain
fc::sha256 node_id; ///< used to identify peers and prevent self-connect
node_id_type node_id; ///< used to identify peers and prevent self-connect
string p2p_address;
uint32_t last_irreversible_block_num = 0;
block_id_type last_irreversible_block_id;
Expand All @@ -22,6 +24,7 @@ namespace eos {
struct notice_message {
vector<transaction_id_type> known_trx;
vector<block_id_type> known_blocks;
vector<node_id_type> known_to;
};


Expand All @@ -33,6 +36,8 @@ namespace eos {
struct block_summary_message {
signed_block block;
vector<transaction_id_type> trx_ids;
vector<node_id_type> known_to;

};

struct sync_request_message {
Expand All @@ -41,7 +46,7 @@ namespace eos {
};

struct peer_message {
vector<fc::ip::endpoint> peers;
vector<node_id_type> peers;
};

using net_message = static_variant<handshake_message,
Expand All @@ -53,6 +58,10 @@ namespace eos {
SignedTransaction,
signed_block>;

using forward_message = static_variant<peer_message,
notice_message,
block_summary_message>;

} // namespace eos


Expand All @@ -64,7 +73,7 @@ FC_REFLECT( eos::handshake_message,
(os)(agent) )

FC_REFLECT( eos::block_summary_message, (block)(trx_ids) )
FC_REFLECT( eos::notice_message, (known_trx)(known_blocks) )
FC_REFLECT( eos::notice_message, (known_trx)(known_blocks)(known_to) )
FC_REFLECT( eos::request_message, (req_trx)(req_blocks) )
FC_REFLECT( eos::sync_request_message, (start_block)(end_block) )
FC_REFLECT( eos::peer_message, (peers) )
Expand Down
Loading