Generic decentralized service layer for mesh networks. Includes FAPP (psychotherapy) and Housing as reference services. - ServiceMessage with Ed25519 signatures - Wire protocol (64-byte header + CBOR) - ServiceRouter with pluggable handlers - Verification framework (3 trust levels) - 32 tests, 3 examples
1.5 KiB
1.5 KiB
MeshService — Agent Notes
Purpose
Generic decentralized service layer. Any P2P service following Announce→Query→Response→Reserve can be built on this.
Quick Commands
# Run tests
cargo test
# Run examples
cargo run --example fapp_service
cargo run --example housing_service
cargo run --example multi_service
Key Files
| File | Purpose |
|---|---|
src/router.rs |
Main entry point, ServiceRouter |
src/message.rs |
ServiceMessage struct |
src/services/fapp.rs |
FAPP implementation (reference) |
src/services/housing.rs |
Housing (second service example) |
Adding a New Service
- Create
src/services/myservice.rs - Define payload structs with serde
- Implement
ServiceHandler - Add to
src/services/mod.rs - Add service ID to
lib.rs
Wire Format
64-byte header (fixed) + signature (64 bytes) + payload (CBOR) + optional verifications.
See src/wire.rs for encoding/decoding.
Integration with quicprochat-p2p
The ServiceRouter is transport-agnostic. To integrate:
// Receive from transport
let msg = wire::decode(&incoming_bytes)?;
let action = router.handle(msg, Some(sender_pubkey))?;
// Handle action
match action {
ServiceAction::StoreAndForward => {
// Re-broadcast msg.forwarded() via transport
}
ServiceAction::Respond(response) => {
// Send response back
}
_ => {}
}
Costs
- No external API calls
- Pure Rust, runs locally
- Memory: Store grows with cached announces (configurable limits)