nervosnetwork / tentacle

A multiplexed p2p network framework that supports custom protocols
https://docs.rs/tentacle
MIT License
54 stars 24 forks source link

feat: add before handle #158

Closed driftluo closed 5 years ago

driftluo commented 5 years ago

Currently, all the handles on the framework are after handles. If you want to use the before operation on the upper layer, it will be very tricky and difficult to maintain.

Just like you want to add a compressed feature to some of the upper layers of the protocol. The current way of coding can only be as shown in https://github.com/nervosnetwork/ckb/pull/859.

The p2p framework is very different from the web framework in that there is a need for broadcasting. If the function of compressing messages is done in the codec, it will waste a lot of CPU time, because the same message will increase the compression time as the number of connections grows.

We need a unified way of handling broadcast messages, not exactly the same as codec, just like global preprocessing. This pr adds two preprocessing methods for each protocol, which makes it easier to preprocess messages.

Good luck to you

nervos-bot[bot] commented 5 years ago

@zhangsoledad is assigned as the chief reviewer