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.
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