Created networking flow (markdown)

Ștefan Talpalaru 2020-03-03 00:49:03 +01:00
parent 4e6fb25fe8
commit 96787ae6aa
1 changed files with 31 additions and 0 deletions

31
networking-flow.md Normal file

@ -0,0 +1,31 @@
This is a collection of notes following networking related code in a beacon_node instance using the Nim libp2p implementation on Linux.
beacon_chain/beacon_node.nim:
- BeaconNode.start() waitsFor node.connectToNetwork()
- BeaconNode.connectToNetwork() awaits node.network.connectToNetwork(node.bootstrapNodes, node.bootstrapEnrs)
beacon_chain/eth2_network.nim:
- Eth2Node.connectToNetwork(seq[ENode], seq[enr.Record])
- for each bootstrap ENR, calls Eth2Node.addKnownPeer()
- awaits Eth2Node.start()
beacon_chain/libp2p_backend.nim:
- Eth2Node.start()
- calls Eth2DiscoveryProtocol.open()
- calls Eth2DiscoveryProtocol.start()
- awaits Switch.start() and stores the resulting seq[Future[void]] in Eth2Node.libp2pTransportLoops; nothing further is done with those futures
- tracesAsyncErrors Eth2Node.runDiscoveryLoop()
vendor/nim-libp2p/libp2p/switch.nim:
- Switch.start()
- for each Switch.transports and each Switch.peerInfo awaits Transport.listen(MultiAddress, inner `handle` closure)
- returns a seq of these futures
- Switch.start.handle(Connection)
- awaits Switch.upgradeIncoming(Connection)
- awaits Connection.close()
- awaits Switch.cleanupConn(Connection)