I am new to libp2p. I am designing a new libp2p protocol. I have 2 different message types, which means, messages with different structure and content.
Do I need a different protocol for each and therefore and independent handler, or can I reuse it?
For now I have one handler
host.SetStreamHandler(ID, service.ServiceHandler)
The service has 2 different functions, which I can use to send the different message types:
func (v *Service) SendBlock(ctx context.Context, blk Block)
func (v *Service) SendTx(ctx context.Context, tx Tx)
This means the handler will have to evaluate what is incoming. Probably I could just try unpacking in the handler for one of the types, and if it fails, try the other (and error if it's none of the two).
Just wondering if this is a non-issue, meaning there's no better or worse, or if there is some kind of libp2p pattern which is better applied here. Thanks.