libplanet icon indicating copy to clipboard operation
libplanet copied to clipboard

Refactor `AsyncDelegate<T>`

Open greymistcube opened this issue 1 year ago • 0 comments

Rationale:

  • Considering how AsyncDelegate is used, there should be no need for higher level objects such as Swarm, KademliaProtocol, or Gossip to know Message.Identity.
  • Note that the entire call stack for retrieving reply Messages via AsyncDelegate is under the context of ReceiveMessage(). Although Message.Identity is used as an earmark for dispatching reply Messages internally for an ITransport, this design is only due to how Messages are encoded which in turn is due to the design of NetMQ.

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

greymistcube avatar Nov 25 '24 08:11 greymistcube