### Initialize Mainline DHT in Server Mode with Public IP Source: https://github.com/pubky/mainline/blob/main/README.md Explicitly configure the DHT to start in server mode and provide a known public IP address. This bypasses the need for the node to discover its public IP through network responses, useful when running behind a firewall. ```rust Dht::builder().server_mode().public_ip().build() ``` -------------------------------- ### Advanced Logging Configuration Source: https://github.com/pubky/mainline/blob/main/examples/README.md Provides an example of advanced logging configuration for the DHT node. This is useful for debugging and monitoring network activity. ```sh cargo run --example logging ``` -------------------------------- ### Bootstrap a DHT Node Source: https://github.com/pubky/mainline/blob/main/examples/README.md Demonstrates how to bootstrap a DHT node. This is a fundamental step for participating in the DHT network. ```sh cargo run --example bootstrap ``` -------------------------------- ### Initialize Mainline DHT as a Client Source: https://github.com/pubky/mainline/blob/main/README.md Use this to create a DHT instance that can store and query values but cannot accept incoming requests. Ensure the `mainline` crate is added as a dependency. ```rust use mainline::Dht; let dht = Dht::client().unwrap(); ``` -------------------------------- ### Initialize Mainline DHT as a Server Source: https://github.com/pubky/mainline/blob/main/README.md Instantiate a DHT node that acts as a routing and storing node, responding to incoming requests. This mode supports general DHT routing and storage capacity. Alternatively, use `Dht::builder::server_mode().build();` for explicit server configuration. ```rust use mainline::Dht; let dht = Dht::server().unwrap(); // or `Dht::builder::server_mode().build();` ``` -------------------------------- ### Create Version Commit and Push Source: https://github.com/pubky/mainline/blob/main/RELEASING.md Create a new branch, stage changes to Cargo.toml and CHANGELOG.md, commit them with a descriptive message, and push the branch to the remote repository. ```bash git checkout -b chore/v7.0.0 git add Cargo.toml CHANGELOG.md git commit -m "chore: v7.0.0" git push origin chore/v7.0.0 ``` -------------------------------- ### Run DHT Size Estimation Simulation Source: https://github.com/pubky/mainline/blob/main/docs/dht_size_estimate.md Execute the simulation to estimate DHT size. This is typically run from the root directory of the project. ```bash cd ./simulation cargo run ``` -------------------------------- ### Cache and Reuse Bootstrap Nodes Source: https://github.com/pubky/mainline/blob/main/examples/README.md Illustrates caching and reusing bootstrap nodes for improved DHT connection efficiency. This can speed up node startup and reduce network overhead. ```sh cargo run --example cache_bootstrap ``` -------------------------------- ### Store Immutable Data in DHT Source: https://github.com/pubky/mainline/blob/main/examples/README.md Demonstrates how to store arbitrary immutable data in the DHT. The data is provided as a string. ```sh cargo run --example put_immutable ``` -------------------------------- ### Announce Peer to DHT Source: https://github.com/pubky/mainline/blob/main/examples/README.md Demonstrates how to announce your presence as a peer in the DHT network. Requires a 40-byte hex info_hash. ```sh cargo run --example announce_peer <40 bytes hex info_hash> ``` -------------------------------- ### Find Peers in DHT Source: https://github.com/pubky/mainline/blob/main/examples/README.md Shows how to find other peers in the DHT network for a given info_hash. Requires a 40-byte hex info_hash. ```sh cargo run --example get_peers <40 bytes hex info_hash> ``` -------------------------------- ### Estimate DHT Size using Mark-Recapture Source: https://github.com/pubky/mainline/blob/main/examples/README.md An analysis tool that estimates the total size of the DHT network using the Mark-Recapture method. Provided for research purposes. ```sh cargo run --example mark_recapture_dht ``` -------------------------------- ### Implement Custom Request Filter Source: https://github.com/pubky/mainline/blob/main/examples/README.md Shows how to implement a custom request filter for DHT nodes. This allows for fine-grained control over incoming requests. ```sh cargo run --example request_filter ``` -------------------------------- ### Retrieve Mutable Data from DHT Source: https://github.com/pubky/mainline/blob/main/examples/README.md Shows how to retrieve mutable data from the DHT. Requires a 40-byte hex target, typically derived from the info_hash of the mutable item. ```sh cargo run --example get_mutable <40 bytes hex target from put_mutable> ``` -------------------------------- ### Store Mutable Data in DHT Source: https://github.com/pubky/mainline/blob/main/examples/README.md Demonstrates how to store arbitrary mutable data in the DHT, associated with a secret key. Requires a 64-byte hex secret key and the string data. ```sh cargo run --example put_mutable <64 bytes hex secret_key> ``` -------------------------------- ### Tag and Push Release Commit Source: https://github.com/pubky/mainline/blob/main/RELEASING.md After merging the version PR, checkout the main branch, pull the latest changes, tag the commit with the release version, and push the tag to the remote repository to trigger the release workflow. ```bash git checkout main git pull origin main git tag v7.0.0 git push origin v7.0.0 ``` -------------------------------- ### Troubleshooting: Delete and Re-push Tag Source: https://github.com/pubky/mainline/blob/main/RELEASING.md If a CI build fails after pushing a tag, delete the local and remote tag, fix the issue, commit, and then re-tag and push the new tag. ```bash git tag -d v7.0.0 git push origin :refs/tags/v7.0.0 # fix the issue, commit, push git tag v7.0.0 git push origin v7.0.0 ``` -------------------------------- ### Retrieve Immutable Data from DHT Source: https://github.com/pubky/mainline/blob/main/examples/README.md Shows how to retrieve immutable data from the DHT using its target hash. Requires a 40-byte hex target obtained from a previous `put_immutable` operation. ```sh cargo run --example get_immutable <40 bytes hex target from put_immutable> ``` -------------------------------- ### Analyze DHT Node Distribution Source: https://github.com/pubky/mainline/blob/main/examples/README.md A research tool to analyze the distribution of DHT nodes based on their IP addresses relative to a key. This is not part of the core API. ```sh cargo run --example count_ips_close_to_key ``` -------------------------------- ### Update Version in Cargo.toml Source: https://github.com/pubky/mainline/blob/main/RELEASING.md Modify the version field in Cargo.toml to reflect the new release version. Ensure this is done on the most recent main branch. ```toml [package] version = "7.0.0" # bump appropriately ``` -------------------------------- ### Measure DHT Network Size Source: https://github.com/pubky/mainline/blob/main/examples/README.md A research tool for measuring the overall size of the DHT network. This is intended for analysis and research, not core API usage. ```sh cargo run --example measure_dht ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.