lokinet/llarp/exit/policy.cpp
Stephen Shelton 273270916e
The Great Wall of Blame
This commit reflects changes to clang-format rules. Unfortunately,
these rule changes create a massive change to the codebase, which
causes an apparent rewrite of git history.

Git blame's --ignore-rev flag can be used to ignore this commit when
attempting to `git blame` some code.
2020-04-07 12:38:56 -06:00

40 lines
1.0 KiB
C++

#include <exit/policy.hpp>
namespace llarp
{
namespace exit
{
bool
Policy::BEncode(llarp_buffer_t* buf) const
{
if (!bencode_start_dict(buf))
return false;
if (!BEncodeWriteDictInt("a", proto, buf))
return false;
if (!BEncodeWriteDictInt("b", port, buf))
return false;
if (!BEncodeWriteDictInt("d", drop, buf))
return false;
if (!BEncodeWriteDictInt("v", version, buf))
return false;
return bencode_end(buf);
}
bool
Policy::DecodeKey(const llarp_buffer_t& k, llarp_buffer_t* buf)
{
bool read = false;
if (!BEncodeMaybeReadDictInt("a", proto, read, k, buf))
return false;
if (!BEncodeMaybeReadDictInt("b", port, read, k, buf))
return false;
if (!BEncodeMaybeReadDictInt("d", drop, read, k, buf))
return false;
if (!BEncodeMaybeReadDictInt("v", version, read, k, buf))
return false;
return read;
}
} // namespace exit
} // namespace llarp