Open crystalwwj opened 6 years ago
fine i will solve it, wait me baby
current fix: add control code to distinguish between different types of packets. Can handle hello, disconnect, and data transfers (ex: transaction) for now. Might consider adopting more flexible options if suitable.
The current implementation is based on Ethereum's pydevp2p which can be referenced here. However, pydevp2p uses tcp as its transport protocol whereas we want a udp version of p2p. Furthermore, pydevp2p defines a broad class BaseProtocol to flexibly take care of different packet transportations, such as transaction packets, block packets, hello and ping/pong packets(for tcp), and disconnect requests. BaseProtocol allows users to define methods to take care of packets from each category upon receiving the packets, but suppose we want to remove that utility from the protocol class and delegate message handling to another class outside the p2p process, how do we efficiently handle connection initializing and disconnect requests? Adding a 'control code' at the beginning of a transmission session could probably work, but are there better options?