lokinet/llarp/pow.hpp
Thomas Winget 7caa87862e standardize include format and pragma once
All #ifndef guards on headers have been removed, I think,
in favor of #pragma once

Headers are now included as `#include "filename"` if the included file
resides in the same directory as the file including it, or any
subdirectory therein.  Otherwise they are included as
`#include <project/top/dir/relative/path/filename>`

The above does not include system/os headers.
2021-03-09 19:01:41 -05:00

51 lines
1016 B
C++

#pragma once
#include "router_id.hpp"
#include "util/buffer.hpp"
namespace llarp
{
/// proof of work
struct PoW
{
static constexpr size_t MaxSize = 128;
llarp_time_t timestamp = 0s;
llarp_time_t extendedLifetime = 0s;
AlignedBuffer<32> nonce;
uint64_t version = LLARP_PROTO_VERSION;
~PoW();
bool
IsValid(llarp_time_t now) const;
bool
DecodeKey(const llarp_buffer_t& k, llarp_buffer_t* val);
bool
BEncode(llarp_buffer_t* buf) const;
bool
operator==(const PoW& other) const
{
return timestamp == other.timestamp && version == other.version
&& extendedLifetime == other.extendedLifetime && nonce == other.nonce;
}
bool
operator!=(const PoW& other) const
{
return !(*this == other);
}
std::ostream&
print(std::ostream& stream, int level, int spaces) const;
};
inline std::ostream&
operator<<(std::ostream& out, const PoW& p)
{
return p.print(out, -1, -1);
}
} // namespace llarp