discv5/discv5_types.hpp¶
Namespaces¶
| Name |
|---|
| discv5 |
Classes¶
| Name | |
|---|---|
| struct | discv5::EnrRecord Parsed Ethereum Node Record as defined by EIP-778. |
| struct | discv5::Discv5Peer A peer discovered by the discv5 crawler. |
| struct | discv5::discv5Config Configuration for the discv5 client and crawler. |
| struct | discv5::ForkId Ethereum EIP-2124 fork identifier used for chain-correctness filtering. |
| struct | discv5::ValidatedPeer Minimal peer descriptor produced by both discv4 and discv5 crawlers. |
Types¶
| Name | |
|---|---|
| using std::function< void(const ValidatedPeer &)> | PeerDiscoveredCallback Invoked when a new valid peer has been discovered and passed all configured filters (chain filter, address validation, dedup). |
| using std::function< void(const std::string &)> | ErrorCallback Invoked when a non-fatal error occurs inside the crawler (e.g. a malformed ENR from a remote node). |
| using std::array< uint8_t, 64 > | NodeId Node identifier — 64-byte uncompressed secp256k1 public key (without the 0x04 prefix). |
Types Documentation¶
using PeerDiscoveredCallback¶
Invoked when a new valid peer has been discovered and passed all configured filters (chain filter, address validation, dedup).
using ErrorCallback¶
Invoked when a non-fatal error occurs inside the crawler (e.g. a malformed ENR from a remote node).
using NodeId¶
Node identifier — 64-byte uncompressed secp256k1 public key (without the 0x04 prefix).
Source code¶
// Copyright 2025 GeniusVentures
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include <array>
#include <chrono>
#include <cstdint>
#include <functional>
#include <optional>
#include <string>
#include <unordered_map>
#include <vector>
#include <discv5/discv5_constants.hpp>
#include <discovery/discovered_peer.hpp>
namespace discv5
{
// Import shared aliases so callers don't have to qualify separately.
using discovery::NodeId;
using discovery::ForkId;
using discovery::ValidatedPeer;
// ---------------------------------------------------------------------------
// EnrRecord
// ---------------------------------------------------------------------------
struct EnrRecord
{
uint64_t seq{};
std::vector<uint8_t> raw_rlp{};
NodeId node_id{};
std::array<uint8_t, kCompressedKeyBytes> compressed_pubkey{};
std::string ip{};
std::string ip6{};
uint16_t udp_port{};
uint16_t tcp_port{};
uint16_t udp6_port{};
uint16_t tcp6_port{};
std::string identity_scheme{};
std::optional<ForkId> eth_fork_id{};
std::unordered_map<std::string, std::vector<uint8_t>> extra_fields{};
};
// ---------------------------------------------------------------------------
// Discv5Peer
// ---------------------------------------------------------------------------
struct Discv5Peer
{
EnrRecord enr{};
ValidatedPeer peer{};
std::chrono::steady_clock::time_point last_seen{};
};
// ---------------------------------------------------------------------------
// discv5Config
// ---------------------------------------------------------------------------
struct discv5Config
{
std::string bind_ip = "0.0.0.0";
uint16_t bind_port = kDefaultUdpPort;
uint16_t tcp_port = kDefaultTcpPort;
std::array<uint8_t, kPrivateKeyBytes> private_key{};
NodeId public_key{};
std::vector<std::string> bootstrap_enrs{};
size_t max_concurrent_queries = kDefaultMaxConcurrent;
uint32_t query_interval_sec = kDefaultQueryIntervalSec;
uint32_t peer_expiry_sec = kDefaultPeerExpirySec;
std::optional<ForkId> required_fork_id{};
};
// ---------------------------------------------------------------------------
// Callback types
// ---------------------------------------------------------------------------
using PeerDiscoveredCallback = std::function<void(const ValidatedPeer&)>;
using ErrorCallback = std::function<void(const std::string&)>;
} // namespace discv5
Updated on 2026-04-13 at 23:22:46 -0700