mirror of
https://codeberg.org/wownero/wownero-lws
synced 2026-01-11 08:05:16 -08:00
Basic "chain hardening" for slightly untrusted daemons (#93)
This commit is contained in:
committed by
Lee *!* Clagett
parent
db66d410cd
commit
351ccaa872
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user