mirror of
https://github.com/matrix-construct/construct
synced 2024-11-15 22:41:12 +01:00
ircd:Ⓜ️:state: Add get_node(nothrow) overload.
This commit is contained in:
parent
f9ad2523a2
commit
b16aa7f55c
2 changed files with 16 additions and 1 deletions
|
@ -55,6 +55,7 @@ namespace ircd::m::state
|
|||
json::array make_key(const mutable_buffer &out, const string_view &type);
|
||||
|
||||
id set_node(db::txn &txn, const mutable_buffer &id, const json::object &node);
|
||||
bool get_node(const std::nothrow_t, const string_view &id, const node_closure &);
|
||||
void get_node(const string_view &id, const node_closure &);
|
||||
|
||||
id remove(db::txn &, const mutable_buffer &rootout, const id &rootin, const json::array &key);
|
||||
|
|
|
@ -783,10 +783,24 @@ ircd::m::state::_getbuffer(const uint8_t &height)
|
|||
void
|
||||
ircd::m::state::get_node(const string_view &node_id,
|
||||
const node_closure &closure)
|
||||
{
|
||||
if(!get_node(std::nothrow, node_id, closure))
|
||||
throw m::NOT_FOUND
|
||||
{
|
||||
"node_id %s not found",
|
||||
string_view{node_id}
|
||||
};
|
||||
}
|
||||
|
||||
/// View a node by ID. This makes a DB query and may yield ircd::ctx.
|
||||
bool
|
||||
ircd::m::state::get_node(const std::nothrow_t,
|
||||
const string_view &node_id,
|
||||
const node_closure &closure)
|
||||
{
|
||||
assert(bool(dbs::state_node));
|
||||
auto &column{dbs::state_node};
|
||||
column(node_id, closure);
|
||||
return column(node_id, std::nothrow, closure);
|
||||
}
|
||||
|
||||
/// Writes a node to the db::txn and returns the id of this node (a hash) into
|
||||
|
|
Loading…
Reference in a new issue