Basic "chain hardening" for slightly untrusted daemons (#93)

This commit is contained in:
Lee *!* Clagett
2024-03-07 17:39:18 -05:00
committed by Lee *!* Clagett
parent db66d410cd
commit 351ccaa872
15 changed files with 1063 additions and 82 deletions

View File

@@ -201,6 +201,43 @@ namespace db
}
WIRE_DEFINE_OBJECT(block_info, map_block_info);
namespace
{
template<typename F, typename T>
void map_block_difficulty(F& format, T& self)
{
wire::object(format, WIRE_FIELD_ID(0, high), WIRE_FIELD_ID(1, low));
}
}
WIRE_DEFINE_OBJECT(block_difficulty, map_block_difficulty);
void block_difficulty::set_difficulty(const unsigned_int& in)
{
high = ((in >> 64) & 0xffffffffffffffff).convert_to<std::uint64_t>();
low = (in & 0xffffffffffffffff).convert_to<std::uint64_t>();
}
block_difficulty::unsigned_int block_difficulty::get_difficulty() const
{
unsigned_int out = high;
out <<= 64;
out += low;
return out;
}
namespace
{
template<typename F, typename T>
void map_block_pow(F& format, T& self)
{
wire::object(format,
WIRE_FIELD_ID(0, id),
WIRE_FIELD_ID(1, timestamp),
WIRE_FIELD_ID(2, cumulative_diff)
);
}
}
WIRE_DEFINE_OBJECT(block_pow, map_block_pow);
namespace
{
template<typename F, typename T>