dnet p2p is a shared library that adds LAN peer-to-peer discovery. It exposes two modes (inspired from MPI terms):
- Manager: the manager of the local network, is able to dispatch tasks to all other. There can only be one manager.
- Worker: every non-manager is expected to be a worker, connected via the LAN to serve their compute power to the manager.
Install from the source via:
cargo install --git https://github.com/firstbatchxyz/dnet-p2pYou can run DnetP2P as follows:
# worker
cargo run
# manager
cargo run -m
# passive, just monitors others
cargo run -pNote that there can only be one manager at a time.
Include the shared library within your loader step, e.g. -L some/directory -ldnet_p2p. Then, include dnet_p2p.h in your code.
- You can create a new service object with
dnet_p2p_newwhich returns you an object pointer, and free it later withdnet_p2p_free. - You can start the service with
dnet_p2p_startwhich returns you a thread handle pointer, and then stop it withdnet_p2p_stop.
See the header file for more specific instructions.
A utility class is provided within dnet_p2p.py that wraps the function calls for the shared library using ctypes. It provides both context usage (i.e. with) and normal usage.
See the example usage at main.py that you can run with:
# worker
RUST_LOG=info uv run main.py
# manager
RUST_LOG=info uv run main.py -mRun tests with:
cargo testSee license file.