This commit is contained in:
Denis Angell
2023-11-19 19:39:22 +01:00
parent ab54d3c6e1
commit 9c35fe9067
8 changed files with 72 additions and 106 deletions

28
hook/tsh.c Normal file
View File

@@ -0,0 +1,28 @@
#include "hookapi.h"
int64_t hook(uint32_t reserved) {
TRACESTR("tsh.c: Start.");
switch (reserved)
{
case 0:
TRACESTR("tsh.c: Strong. Execute BEFORE transaction is applied to ledger");
break;
case 1:
TRACESTR("tsh.c: Weak. Execute AFTER transaction is applied to ledger");
break;
case 2:
TRACESTR("tsh.c: Weak Again. Execute AFTER transaction is applied to ledger");
break;
default:
break;
}
TRACESTR("tsh.c: End.");
uint8_t r_buf[4];
UINT32_TO_BUF(r_buf, reserved);
accept(SBUF(r_buf), __LINE__);
_g(1,1);
// unreachable
return 0;
}

1
hook/tsh.h Normal file

File diff suppressed because one or more lines are too long

19
hook/xahau.py Normal file
View File

@@ -0,0 +1,19 @@
import binascii
name: str = "tsh"
with open(f"build/{name}.wasm", "rb") as file:
wasm = file.read()
data = wasm.hex().upper()
# print(data)
# Convert hexadecimal data to bytes
binary_data = binascii.unhexlify(data)
# Generate C array
c_array = ', '.join([f"0x{b:02x}U" for b in binary_data])
with open(f"hook/{name}.h", "w") as file:
file.write(f'static const std::vector<uint8_t> {name.capitalize()}Hook = {"{"}')
file.write(c_array)
file.write("};\n")

View File

@@ -145,111 +145,78 @@ private:
}; };
// VFALCO TODO This should only be enabled for maps. // VFALCO TODO This should only be enabled for maps.
class pair_value_compare class pair_value_compare : public Compare
: public beast::detail::empty_base_optimization<Compare>
#ifdef _LIBCPP_VERSION
,
public std::binary_function<value_type, value_type, bool>
#endif
{ {
public: public:
#ifndef _LIBCPP_VERSION
using first_argument = value_type; using first_argument = value_type;
using second_argument = value_type; using second_argument = value_type;
using result_type = bool; using result_type = bool;
#endif
bool bool
operator()(value_type const& lhs, value_type const& rhs) const operator()(value_type const& lhs, value_type const& rhs) const
{ {
return this->member()(lhs.first, rhs.first); return Compare::operator()(lhs.first, rhs.first);
} }
pair_value_compare() pair_value_compare()
{ {
} }
pair_value_compare(pair_value_compare const& other) pair_value_compare(pair_value_compare const& other) : Compare(other)
: beast::detail::empty_base_optimization<Compare>(other)
{ {
} }
private: private:
friend aged_ordered_container; friend aged_ordered_container;
pair_value_compare(Compare const& compare) pair_value_compare(Compare const& compare) : Compare(compare)
: beast::detail::empty_base_optimization<Compare>(compare)
{ {
} }
}; };
// Compares value_type against element, used in insert_check // Compares value_type against element, used in insert_check
// VFALCO TODO hoist to remove template argument dependencies // VFALCO TODO hoist to remove template argument dependencies
class KeyValueCompare class KeyValueCompare : public Compare
: public beast::detail::empty_base_optimization<Compare>
#ifdef _LIBCPP_VERSION
,
public std::binary_function<Key, element, bool>
#endif
{ {
public: public:
#ifndef _LIBCPP_VERSION
using first_argument = Key; using first_argument = Key;
using second_argument = element; using second_argument = element;
using result_type = bool; using result_type = bool;
#endif
KeyValueCompare() = default; KeyValueCompare() = default;
KeyValueCompare(Compare const& compare) KeyValueCompare(Compare const& compare) : Compare(compare)
: beast::detail::empty_base_optimization<Compare>(compare)
{ {
} }
// VFALCO NOTE WE might want only to enable these overloads
// if Compare has is_transparent
#if 0
template <class K>
bool operator() (K const& k, element const& e) const
{
return this->member() (k, extract (e.value));
}
template <class K>
bool operator() (element const& e, K const& k) const
{
return this->member() (extract (e.value), k);
}
#endif
bool bool
operator()(Key const& k, element const& e) const operator()(Key const& k, element const& e) const
{ {
return this->member()(k, extract(e.value)); return Compare::operator()(k, extract(e.value));
} }
bool bool
operator()(element const& e, Key const& k) const operator()(element const& e, Key const& k) const
{ {
return this->member()(extract(e.value), k); return Compare::operator()(extract(e.value), k);
} }
bool bool
operator()(element const& x, element const& y) const operator()(element const& x, element const& y) const
{ {
return this->member()(extract(x.value), extract(y.value)); return Compare::operator()(extract(x.value), extract(y.value));
} }
Compare& Compare&
compare() compare()
{ {
return beast::detail::empty_base_optimization<Compare>::member(); return *this;
} }
Compare const& Compare const&
compare() const compare() const
{ {
return beast::detail::empty_base_optimization<Compare>::member(); return *this;
} }
}; };

View File

@@ -148,115 +148,84 @@ private:
}; };
// VFALCO TODO hoist to remove template argument dependencies // VFALCO TODO hoist to remove template argument dependencies
class ValueHash : private beast::detail::empty_base_optimization<Hash> class ValueHash : public Hash
#ifdef _LIBCPP_VERSION
,
public std::unary_function<element, std::size_t>
#endif
{ {
public: public:
#ifndef _LIBCPP_VERSION
using argument_type = element; using argument_type = element;
using result_type = size_t; using result_type = size_t;
#endif
ValueHash() ValueHash()
{ {
} }
ValueHash(Hash const& h) ValueHash(Hash const& h) : Hash(h)
: beast::detail::empty_base_optimization<Hash>(h)
{ {
} }
std::size_t std::size_t
operator()(element const& e) const operator()(element const& e) const
{ {
return this->member()(extract(e.value)); return Hash::operator()(extract(e.value));
} }
Hash& Hash&
hash_function() hash_function()
{ {
return this->member(); return *this;
} }
Hash const& Hash const&
hash_function() const hash_function() const
{ {
return this->member(); return *this;
} }
}; };
// Compares value_type against element, used in find/insert_check // Compares value_type against element, used in find/insert_check
// VFALCO TODO hoist to remove template argument dependencies // VFALCO TODO hoist to remove template argument dependencies
class KeyValueEqual class KeyValueEqual : public KeyEqual
: private beast::detail::empty_base_optimization<KeyEqual>
#ifdef _LIBCPP_VERSION
,
public std::binary_function<Key, element, bool>
#endif
{ {
public: public:
#ifndef _LIBCPP_VERSION
using first_argument_type = Key; using first_argument_type = Key;
using second_argument_type = element; using second_argument_type = element;
using result_type = bool; using result_type = bool;
#endif
KeyValueEqual() KeyValueEqual()
{ {
} }
KeyValueEqual(KeyEqual const& keyEqual) KeyValueEqual(KeyEqual const& keyEqual) : KeyEqual(keyEqual)
: beast::detail::empty_base_optimization<KeyEqual>(keyEqual)
{ {
} }
// VFALCO NOTE WE might want only to enable these overloads
// if KeyEqual has is_transparent
#if 0
template <class K>
bool operator() (K const& k, element const& e) const
{
return this->member() (k, extract (e.value));
}
template <class K>
bool operator() (element const& e, K const& k) const
{
return this->member() (extract (e.value), k);
}
#endif
bool bool
operator()(Key const& k, element const& e) const operator()(Key const& k, element const& e) const
{ {
return this->member()(k, extract(e.value)); return KeyEqual::operator()(k, extract(e.value));
} }
bool bool
operator()(element const& e, Key const& k) const operator()(element const& e, Key const& k) const
{ {
return this->member()(extract(e.value), k); return KeyEqual::operator()(extract(e.value), k);
} }
bool bool
operator()(element const& lhs, element const& rhs) const operator()(element const& lhs, element const& rhs) const
{ {
return this->member()(extract(lhs.value), extract(rhs.value)); return KeyEqual::operator()(extract(lhs.value), extract(rhs.value));
} }
KeyEqual& KeyEqual&
key_eq() key_eq()
{ {
return this->member(); return *this;
} }
KeyEqual const& KeyEqual const&
key_eq() const key_eq() const
{ {
return this->member(); return *this;
} }
}; };

View File

@@ -91,17 +91,10 @@ private:
using value_type = map_type::value_type; using value_type = map_type::value_type;
struct Transform struct Transform
#ifdef _LIBCPP_VERSION
: std::unary_function<
map_type::right_map::const_iterator::value_type const&,
beast::IP::Endpoint const&>
#endif
{ {
#ifndef _LIBCPP_VERSION
using first_argument_type = using first_argument_type =
map_type::right_map::const_iterator::value_type const&; map_type::right_map::const_iterator::value_type const&;
using result_type = beast::IP::Endpoint const&; using result_type = beast::IP::Endpoint const&;
#endif
explicit Transform() = default; explicit Transform() = default;

View File

@@ -69,14 +69,9 @@ public:
public: public:
// Iterator transformation to extract the endpoint from Element // Iterator transformation to extract the endpoint from Element
struct Transform struct Transform
#ifdef _LIBCPP_VERSION
: public std::unary_function<Element, Endpoint>
#endif
{ {
#ifndef _LIBCPP_VERSION
using first_argument = Element; using first_argument = Element;
using result_type = Endpoint; using result_type = Endpoint;
#endif
explicit Transform() = default; explicit Transform() = default;
@@ -239,15 +234,9 @@ public:
template <bool IsConst> template <bool IsConst>
struct Transform struct Transform
#ifdef _LIBCPP_VERSION
: public std::
unary_function<typename lists_type::value_type, Hop<IsConst>>
#endif
{ {
#ifndef _LIBCPP_VERSION
using first_argument = typename lists_type::value_type; using first_argument = typename lists_type::value_type;
using result_type = Hop<IsConst>; using result_type = Hop<IsConst>;
#endif
explicit Transform() = default; explicit Transform() = default;

View File

@@ -398,7 +398,7 @@ SHAMapInnerNode::canonicalizeChild(
void void
SHAMapInnerNode::invariants(bool is_root) const SHAMapInnerNode::invariants(bool is_root) const
{ {
unsigned count = 0; [[maybe_unused]] unsigned count = 0;
auto [numAllocated, hashes, children] = auto [numAllocated, hashes, children] =
hashesAndChildren_.getHashesAndChildren(); hashesAndChildren_.getHashesAndChildren();