libplanet
libplanet copied to clipboard
Refactor `AsyncDelegate<T>`
Rationale:
- Considering how
AsyncDelegateis used, there should be no need for higher level objects such asSwarm,KademliaProtocol, orGossipto knowMessage.Identity. - Note that the entire call stack for retrieving reply
Messages viaAsyncDelegateis under the context ofReceiveMessage(). AlthoughMessage.Identityis used as an earmark for dispatching replyMessages internally for anITransport, this design is only due to howMessages are encoded which in turn is due to the design ofNetMQ.
PS - I think it might even be better for the delegate to be of the form Func<BoundPeer, MessageContent, Channel<MessageContent>, Task> instead of Func<Message, Channel<MessageContent>, Task> if we can be sure if other layers shouldn't really care about Message.Timestamp or Message.Version. 🙄