nu-p2p/CLAUDE.md
Mukan Erkin ba51b72ed2 feat(p2p): add HTTP publish API for nu-node integration
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-24 16:49:26 +03:00

1.3 KiB
Raw Permalink Blame History

nu-p2p — CLAUDE.md

P2P ağ katmanı. nu-node'dan ayrı tutulur — test ederken network mock'lanabilir.

Stack

  • libp2p 0.54 — Gossipsub, Kademlia DHT, Identify, Ping
  • Tokio async runtime

Modüller

Dosya Sorumluluk
behaviour.rs libp2p NetworkBehaviour kompozisyonu
messages.rs Gossip topic sabitleri + mesaj tipleri
peer.rs PeerRegistry (max 50 bağlantı)
config.rs Listen addr, bootstrap peers, max peers

Gossip Topics

nu/blocks/1      → BlockAnnounce, BlockRequest, BlockResponse
nu/txs/1         → TxGossip
nu/votes/1       → VoteAnnounce
nu/validators/1  → ValidatorHeartbeat

nu-node Entegrasyonu

nu-p2p ayrı bir process olarak çalışır. nu-node, --p2p-api flag'i ile bu servisin HTTP adresini alır ve mesajları POST /publish üzerinden iletir.

# Nu-p2p başlat (publish API dahil)
cargo run --bin nu-p2p -- \
  --listen /ip4/0.0.0.0/tcp/30333 \
  --api-addr 127.0.0.1:30334

# Nu-node'u P2P'ye bağlı başlat
cd ../nu-node && cargo run -- --dev --validator --p2p-api http://127.0.0.1:30334

# İki node gossip testi
cargo run --bin nu-p2p -- \
  --listen /ip4/0.0.0.0/tcp/30335 \
  --api-addr 127.0.0.1:30336 \
  --bootstrap /ip4/127.0.0.1/tcp/30333