mirror of
https://codeberg.org/wownero/wownero-lws
synced 2026-01-10 23:55:16 -08:00
New accounts are 'pushed' to worker threads (#102)
This commit is contained in:
committed by
Lee *!* Clagett
parent
f300bff69f
commit
80604e8133
@@ -27,7 +27,7 @@
|
||||
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
set(monero-lws-wire_sources error.cpp read.cpp write.cpp)
|
||||
set(monero-lws-wire_headers crypto.h error.h field.h filters.h fwd.h json.h read.h traits.h vector.h write.h)
|
||||
set(monero-lws-wire_headers error.h field.h filters.h fwd.h json.h read.h traits.h vector.h write.h)
|
||||
|
||||
add_library(monero-lws-wire ${monero-lws-wire_sources} ${monero-lws-wire_headers})
|
||||
target_include_directories(monero-lws-wire PUBLIC "${LMDB_INCLUDE}")
|
||||
|
||||
@@ -41,6 +41,12 @@ namespace crypto
|
||||
{
|
||||
source.binary(epee::as_mut_byte_span(unwrap(unwrap(self))));
|
||||
}
|
||||
|
||||
template<typename W>
|
||||
void write_bytes(W& dest, const crypto::secret_key& self)
|
||||
{
|
||||
dest.binary(epee::as_byte_span(unwrap(unwrap(self))));
|
||||
}
|
||||
}
|
||||
|
||||
namespace wire
|
||||
50
src/wire/adapted/pair.h
Normal file
50
src/wire/adapted/pair.h
Normal file
@@ -0,0 +1,50 @@
|
||||
// Copyright (c) 2024, The Monero Project
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other
|
||||
// materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
||||
// used to endorse or promote products derived from this software without specific
|
||||
// prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "wire/field.h"
|
||||
#include "wire/read.h"
|
||||
#include "wire/write.h"
|
||||
|
||||
namespace wire
|
||||
{
|
||||
template<typename F, typename T>
|
||||
void map_pair(F& format, T& self)
|
||||
{
|
||||
wire::object(format, WIRE_FIELD_ID(0, first), WIRE_FIELD_ID(1, second));
|
||||
}
|
||||
|
||||
template<typename R, typename T, typename U>
|
||||
void read_bytes(R& source, std::pair<T, U>& dest)
|
||||
{ map_pair(source, dest); }
|
||||
|
||||
template<typename W, typename T, typename U>
|
||||
void write_bytes(W& dest, const std::pair<T, U>& source)
|
||||
{ map_pair(dest, source); }
|
||||
}
|
||||
|
||||
@@ -170,6 +170,11 @@ namespace wire
|
||||
inline std::enable_if_t<is_blob<T>::value> read_bytes(R& source, T& dest)
|
||||
{ source.binary(epee::as_mut_byte_span(dest)); }
|
||||
|
||||
//! Use `read_bytes(...)` method if available for `T`.
|
||||
template<typename R, typename T>
|
||||
inline auto read_bytes(R& source, T& dest) -> decltype(dest.read_bytes(source))
|
||||
{ return dest.read_bytes(source); }
|
||||
|
||||
namespace integer
|
||||
{
|
||||
[[noreturn]] void throw_exception(std::intmax_t value, std::intmax_t min, std::intmax_t max);
|
||||
|
||||
76
src/wire/wrapper/trusted_array.h
Normal file
76
src/wire/wrapper/trusted_array.h
Normal file
@@ -0,0 +1,76 @@
|
||||
// Copyright (c) 2024, The Monero Project
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other
|
||||
// materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
||||
// used to endorse or promote products derived from this software without specific
|
||||
// prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <limits>
|
||||
#include "wire/traits.h"
|
||||
#include "wire/read.h"
|
||||
#include "wire/write.h"
|
||||
|
||||
namespace wire
|
||||
{
|
||||
//! \brief Wrapper that removes read constraints
|
||||
template<typename T>
|
||||
struct trusted_array_
|
||||
{
|
||||
using container_type = wire::unwrap_reference_t<T>;
|
||||
T container;
|
||||
|
||||
const container_type& get_container() const noexcept { return container; }
|
||||
container_type& get_container() noexcept { return container; }
|
||||
|
||||
// concept requirements for optional fields
|
||||
|
||||
explicit operator bool() const noexcept { return !get_container().empty(); }
|
||||
trusted_array_& emplace() noexcept { return *this; }
|
||||
|
||||
trusted_array_& operator*() noexcept { return *this; }
|
||||
const trusted_array_& operator*() const noexcept { return *this; }
|
||||
|
||||
void reset() { get_container().clear(); }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
trusted_array_<T> trusted_array(T value)
|
||||
{
|
||||
return {std::move(value)};
|
||||
}
|
||||
|
||||
template<typename R, typename T>
|
||||
void read_bytes(R& source, trusted_array_<T> dest)
|
||||
{
|
||||
wire_read::array_unchecked(source, dest.get_container(), 0, std::numeric_limits<std::size_t>::max());
|
||||
}
|
||||
|
||||
template<typename W, typename T>
|
||||
void write_bytes(W& dest, const trusted_array_<T> source)
|
||||
{
|
||||
wire_write::array(dest, source.get_container());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user