Skip to content

src/primitives/apply_result.hpp

Namespaces

Name
sgns
sgns::primitives

Types

Name
enum class uint8_t ApplyOutcome
enum class uint8_t ApplyError
using boost::variant< ApplyOutcome, ApplyError > ApplyResult

Functions

Name
template <class Stream ,typename =std::enable_if_t>
Stream &
operator<<(Stream & s, const ApplyOutcome & outcome)
template <class Stream ,typename =std::enable_if_t>
Stream &
operator>>(Stream & s, ApplyOutcome & outcome)
template <class Stream ,typename =std::enable_if_t>
Stream &
operator<<(Stream & s, const ApplyError & error)
template <class Stream ,typename =std::enable_if_t>
Stream &
operator>>(Stream & s, ApplyError & error)

Types Documentation

enum ApplyOutcome

Enumerator Value Description
SUCCESS 0
FAIL 1

enum ApplyError

Enumerator Value Description
BAD_SIGNATURE 0 Bad signature.
STALE 1 Nonce too low.
FUTURE 2 Nonce too high.
CANT_PAY 3 Sending account had too low a balance.
FULL_BLOCK 255 Block is full, no more extrinsics can be applied.

using ApplyResult

using sgns::primitives::ApplyResult = boost::variant<ApplyOutcome, ApplyError>;

Functions Documentation

function operator<<

template <class Stream ,
typename  =std::enable_if_t<Stream::is_encoder_stream>>
Stream & operator<<(
    Stream & s,
    const ApplyOutcome & outcome
)

function operator>>

template <class Stream ,
typename  =std::enable_if_t<Stream::is_decoder_stream>>
Stream & operator>>(
    Stream & s,
    ApplyOutcome & outcome
)

function operator<<

template <class Stream ,
typename  =std::enable_if_t<Stream::is_encoder_stream>>
Stream & operator<<(
    Stream & s,
    const ApplyError & error
)

function operator>>

template <class Stream ,
typename  =std::enable_if_t<Stream::is_decoder_stream>>
Stream & operator>>(
    Stream & s,
    ApplyError & error
)

Source code

#ifndef SUPERGENIUS_SRC_PRIMITIVES_APPLY_RESULT_HPP
#define SUPERGENIUS_SRC_PRIMITIVES_APPLY_RESULT_HPP

#include <boost/variant.hpp>

namespace sgns::primitives {

  enum class ApplyOutcome : uint8_t { SUCCESS = 0, FAIL = 1 };

  template <class Stream,
            typename = std::enable_if_t<Stream::is_encoder_stream>>
  Stream &operator<<(Stream &s, const ApplyOutcome &outcome) {
    uint8_t r{static_cast<uint8_t>(outcome)};
    return s << r;
  }

  template <class Stream,
            typename = std::enable_if_t<Stream::is_decoder_stream>>
  Stream &operator>>(Stream &s, ApplyOutcome &outcome) {
    uint8_t int_res = 0;
    s >> int_res;
    outcome = ApplyOutcome{int_res};
    return s;
  }

  enum class ApplyError : uint8_t {
    BAD_SIGNATURE = 0,
    STALE = 1,
    FUTURE = 2,
    CANT_PAY = 3,
    FULL_BLOCK = 255,
  };

  template <class Stream,
            typename = std::enable_if_t<Stream::is_encoder_stream>>
  Stream &operator<<(Stream &s, const ApplyError &error) {
    uint8_t r{static_cast<uint8_t>(error)};
    return s << r;
  }

  template <class Stream,
            typename = std::enable_if_t<Stream::is_decoder_stream>>
  Stream &operator>>(Stream &s, ApplyError &error) {
    uint8_t int_err = 0;
    s >> int_err;
    error = ApplyError{int_err};
    return s;
  }

  using ApplyResult = boost::variant<ApplyOutcome, ApplyError>;

}  // namespace sgns::primitives

#endif  // SUPERGENIUS_SRC_PRIMITIVES_APPLY_RESULT_HPP

Updated on 2026-03-04 at 13:10:44 -0800