Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

EOS Code Analysis of 6 P2P active handshake process

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Active link to the peer

Connect (seed_node); link peer node

If (start_session (c)) {c-> send_handshake (); / / send handshake protocol}

C-> send_handshake (); / / initialize the structure, send the handshake protocol, and finally enqueue the protocol.

Handshake_initializer::populate

Queue_write (); send buffer past [how to send buffer after sending buffer?]

Actively sent handshake data content

Void

Handshake_initializer::populate (handshake_message & hello) {

Hello.network_version = net_version_base + net_version

Hello.chain_id = my_impl- > chain_id; / / system options can be set

Hello.node_id = my_impl- > node_id

Hello.key = my_impl- > get_authentication_key (); / / Public key

Hello.time = std::chrono::system_clock::now (). Time_since_epoch (). Count ()

Hello.token = fc::sha256::hash (hello.time)

Hello.sig = my_impl- > sign_compact (hello.key, hello.token)

/ / If we couldn't sign, don't send a token.

If (hello.sig = = chain::signature_type ())

Hello.token = sha256 ()

Hello.p2p_address = my_impl- > p2p_address + "-" + hello.node_id.str (). Substr (0pr 7)

# if defined (APPLE)

Hello.os = "osx"

# elif defined (linux)

Hello.os = "linux"

# elif defined (_ MSC_VER)

Hello.os = "win32"

# else

Hello.os = "other"

# endif

Hello.agent = my_impl- > user_agent_name

Controller& cc = my_impl- > chain_plug- > chain (); hello.head_id = fc::sha256 (); hello.last_irreversible_block_id = fc::sha256 (); hello.head_num = cc.head_block_num (); hello.last_irreversible_block_num = cc.last_irreversible_block_num () If (hello.last_irreversible_block_num) {try {hello.last_irreversible_block_id = cc.get_block_id_for_num (hello.last_irreversible_block_num);} catch (const unknown_block_exception & ex) {ilog ("caught unkown_block"); hello.last_irreversible_block_num = 0 }} if (hello.head_num) {try {hello.head_id = cc.get_block_id_for_num (hello.head_num);} catch (const unknown_block_exception & ex) {hello.head_num = 0;}}

}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 236

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report