mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 16:22:35 +01:00
ircd:Ⓜ️ Further overload the event::hashes stack; use proper return types.
This commit is contained in:
parent
0d833cda4f
commit
3ec0a1c7c8
2 changed files with 32 additions and 6 deletions
|
@ -123,7 +123,7 @@ struct ircd::m::event
|
|||
friend ed25519::sig sign(const event &);
|
||||
static ed25519::sig sign(json::iov &event, const json::iov &content, const ed25519::sk &);
|
||||
static ed25519::sig sign(json::iov &event, const json::iov &content);
|
||||
static string_view signatures(const mutable_buffer &, json::iov &event, const json::iov &content);
|
||||
static json::object signatures(const mutable_buffer &, json::iov &event, const json::iov &content);
|
||||
friend event signatures(const mutable_buffer &, const m::event &);
|
||||
|
||||
friend bool verify_sha256b64(const event &, const string_view &);
|
||||
|
@ -132,7 +132,8 @@ struct ircd::m::event
|
|||
|
||||
friend sha256::buf hash(const event &);
|
||||
static sha256::buf hash(json::iov &event, const string_view &content);
|
||||
static string_view hashes(const mutable_buffer &, json::iov &event, const string_view &content);
|
||||
static json::object hashes(const mutable_buffer &, json::iov &event, const string_view &content);
|
||||
friend json::object hashes(const mutable_buffer &, const event &);
|
||||
|
||||
using super_type::tuple;
|
||||
using super_type::operator=;
|
||||
|
|
|
@ -591,7 +591,24 @@ ircd::m::event::event(const idx &idx,
|
|||
new (this) m::event(obj);
|
||||
}
|
||||
|
||||
ircd::string_view
|
||||
namespace ircd::m
|
||||
{
|
||||
static json::object make_hashes(const mutable_buffer &out, const sha256::buf &hash);
|
||||
}
|
||||
|
||||
ircd::json::object
|
||||
ircd::m::hashes(const mutable_buffer &out,
|
||||
const event &event)
|
||||
{
|
||||
const sha256::buf hash_
|
||||
{
|
||||
hash(event)
|
||||
};
|
||||
|
||||
return make_hashes(out, hash_);
|
||||
}
|
||||
|
||||
ircd::json::object
|
||||
ircd::m::event::hashes(const mutable_buffer &out,
|
||||
json::iov &event,
|
||||
const string_view &content)
|
||||
|
@ -601,10 +618,18 @@ ircd::m::event::hashes(const mutable_buffer &out,
|
|||
hash(event, content)
|
||||
};
|
||||
|
||||
thread_local char hashb64buf[b64encode_size(sizeof(hash_))];
|
||||
return make_hashes(out, hash_);
|
||||
}
|
||||
|
||||
ircd::json::object
|
||||
ircd::m::make_hashes(const mutable_buffer &out,
|
||||
const sha256::buf &hash)
|
||||
{
|
||||
static const auto b64bufsz(b64encode_size(sizeof(hash)));
|
||||
thread_local char hashb64buf[b64bufsz];
|
||||
const json::members hashes
|
||||
{
|
||||
{ "sha256", b64encode_unpadded(hashb64buf, hash_) }
|
||||
{ "sha256", b64encode_unpadded(hashb64buf, hash) }
|
||||
};
|
||||
|
||||
return json::stringify(mutable_buffer{out}, hashes);
|
||||
|
@ -699,7 +724,7 @@ catch(const json::not_found &)
|
|||
return false;
|
||||
}
|
||||
|
||||
ircd::string_view
|
||||
ircd::json::object
|
||||
ircd::m::event::signatures(const mutable_buffer &out,
|
||||
json::iov &event,
|
||||
const json::iov &content)
|
||||
|
|
Loading…
Reference in a new issue