Skip to content

discv4/discv4_error.hpp

Namespaces

Name
discv4

Types

Name
enum class discv4Error { kNetworkSendFailed, kNetworkReceiveFailed, kPacketTooSmall, kInvalidPacketType, kHashMismatch, kSignatureParseFailed, kSignatureRecoveryFailed, kSigningFailed, kContextCreationFailed, kInvalidPublicKey, kRlpPayloadEmpty, kPongTimeout, kPongParseFailed}
Discovery v4 protocol error codes.
template <typename T >
using outcome::result< T, discv4Error, outcome::policy::all_narrow >
Result
Result type for Discovery v4 operations.
using outcome::result< void, discv4Error, outcome::policy::all_narrow > VoidResult
Result type for Discovery v4 operations without return value.

Functions

Name
const char * to_string(discv4Error error)
Convert error code to human-readable string.

Types Documentation

enum discv4Error

Enumerator Value Description
kNetworkSendFailed
kNetworkReceiveFailed
kPacketTooSmall
kInvalidPacketType
kHashMismatch
kSignatureParseFailed
kSignatureRecoveryFailed
kSigningFailed
kContextCreationFailed
kInvalidPublicKey
kRlpPayloadEmpty
kPongTimeout
kPongParseFailed

Discovery v4 protocol error codes.

using Result

template <typename T >
using discv4::Result = outcome::result<T, discv4Error, outcome::policy::all_narrow>;

Result type for Discovery v4 operations.

Template Parameters:

  • T The success value type

using VoidResult

using discv4::VoidResult = outcome::result<void, discv4Error, outcome::policy::all_narrow>;

Result type for Discovery v4 operations without return value.

Functions Documentation

function to_string

const char * to_string(
    discv4Error error
)

Convert error code to human-readable string.

Parameters:

  • error The error code

Return: Error description string

Source code

// Copyright 2025 GeniusVentures
// SPDX-License-Identifier: Apache-2.0

#ifndef discv4_ERROR_HPP
#define discv4_ERROR_HPP

#include <boost/outcome/result.hpp>
#include <boost/outcome/try.hpp>

namespace discv4 {

namespace outcome = BOOST_OUTCOME_V2_NAMESPACE;

enum class discv4Error {
    kNetworkSendFailed,           // Failed to send UDP packet
    kNetworkReceiveFailed,        // Failed to receive UDP packet
    kPacketTooSmall,              // Packet size below minimum (98 bytes)
    kInvalidPacketType,           // Unknown or invalid packet type
    kHashMismatch,                // Packet hash verification failed
    kSignatureParseFailed,        // Failed to parse ECDSA signature
    kSignatureRecoveryFailed,     // Failed to recover public key from signature
    kSigningFailed,               // Failed to sign packet with private key
    kContextCreationFailed,       // Failed to create secp256k1 context
    kInvalidPublicKey,            // Invalid or malformed public key
    kRlpPayloadEmpty,             // RLP payload generation returned empty
    kPongTimeout,                 // PONG response timeout
    kPongParseFailed,             // Failed to parse PONG packet
};

template<typename T>
using Result = outcome::result<T, discv4Error, outcome::policy::all_narrow>;

using VoidResult = outcome::result<void, discv4Error, outcome::policy::all_narrow>;

const char* to_string(discv4Error error) noexcept;

} // namespace discv4

#endif // discv4_ERROR_HPP

Updated on 2026-04-13 at 23:22:46 -0700