Example is in examples/statemachine, run demo with go run .
Only the simplest happy path is implemented to demonstrate the idea.
Key points of approach
Queries are executed by a hierarchical state machine (with thanks to rust-libp2p design)
KademliaHandler runs the event loop and query state machine
IPFS-specific logic lives in IpfsDht
KademliaHandler doesn't know anything about IPFS messages, just knows how to perform a query and send a MinKadRequestMessage to each node.
FindNodeRequest and FindNodeResponse are the messages that the IpfsDht knows about, in reality they would be the protobuf messages
The state machine and event model provides a lot of extensibility and possibilities for notifying multiple components about changes such as new peers being discovered or found to be unresponsive
Example is in
examples/statemachine
, run demo withgo run .
Only the simplest happy path is implemented to demonstrate the idea.
Key points of approach