Skip to content

Latest commit

 

History

History

README.md

Examples

Core API Examples

These examples demonstrate the main functionality of the Mainline DHT library:

Setup

# Bootstrap a DHT node
cargo run --example bootstrap

# Implement a custom request filter
cargo run --example request_filter

# Cache and reuse bootstrap nodes
cargo run --example cache_bootstrap

# Advanced logging configuration
cargo run --example logging

Anounce/GET Peers

# Announce as a peer
cargo run --example announce_peer <40 bytes hex info_hash>

# Find peers
cargo run --example get_peers <40 bytes hex info_hash>

PUT/GET Arbitrary Immutable values.

# Store immutable data
cargo run --example put_immutable <string>

# Retrieve immutable data
cargo run --example get_immutable <40 bytes hex target from put_immutable>

PUT/GET Arbitrary Mutable items.

# Store mutable data
cargo run --example put_mutable <64 bytes hex secret_key> <string>

# Retrieve mutable data
cargo run --example get_mutable <40 bytes hex target from put_mutable>

Analysis & Research Tools

These examples are for DHT network analysis and research purposes:

Note: These tools are not part of the main API and are provided for curiosity/research only.

# Analyze DHT node distribution
cargo run --example count_ips_close_to_key

# Estimate DHT size (Mark-Recapture method)
cargo run --example mark_recapture_dht

# Measure DHT network size
cargo run --example measure_dht