EOS代码分析6 P2P主动握手过程

  

主动链接对端
连接(seed_node);链接同行节点
如果(start_session (c)) {c→send_handshake ();//发送握手协议}
c→send_handshake ();//初始化结构体,发送握手协议,协议最后要排队
handshake_initializer::填充
queue_write ();发送缓冲过去[发送缓冲后,如何把缓冲发送过去?]

  

主动发送的握手数据内容
空白
handshake_initializer::填充(handshake_message和你好){
hello.network_version=net_version_base + net_version;
你好。chain_id=my_impl→chain_id;//系统选项可以设定
你好。node_id=my_impl→node_id;
你好。关键=my_impl→get_authentication_key ();//公钥
你好。时间=std::空间::system_clock::现在().time_since_epoch () .count ();
你好。令牌=fc:: sha256::哈希(hello.time);
你好。sig=my_impl→sign_compact(你好。键,hello.token);
//如果我们不能签署,不要发送令牌。
如果你好。sig==链:signature_type ())
你好。令牌=sha256 ();
你好。p2p_address=my_impl→p2p_address +“;——“;+ hello.node_id.str () .substr (0、7);
#如果定义(<强>苹果)
你好。操作系统=皁sx"
# elif定义(linux <强> )
你好。操作系统=發inux"
# elif定义(_MSC_VER)
你好。操作系统=皐in32"
#
你好。操作系统=皁ther"
# endif
你好。代理=my_impl→user_agent_name;

  
 <代码> controller&cc=my_impl→chain_plug→链();
  你好。head_id=fc: sha256 ();
  你好。last_irreversible_block_id=fc: sha256 ();
  你好。head_num=cc.head_block_num ();
  你好。last_irreversible_block_num=cc.last_irreversible_block_num ();
  如果你好。last_irreversible_block_num) {
  尝试{
  你好。last_irreversible_block_id=cc.get_block_id_for_num (hello.last_irreversible_block_num);
  }
  抓住(const unknown_block_exception和前女友){
  ilog(“抓住unkown_block”);
  你好。last_irreversible_block_num=0;
  }
  }
  如果你好。head_num) {
  尝试{
  你好。head_id=cc.get_block_id_for_num(你好。head_num);
  }
  抓住(const unknown_block_exception和前女友){
  你好。head_num=0;
  }
  } 
  

}

EOS代码分析6 P2P主动握手过程