0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-23 21:33:44 +02:00

ircd:Ⓜ️:event::fetch: Move std::nothrow to leading argument for consistency.

This commit is contained in:
Jason Volk 2020-04-02 19:50:00 -07:00
parent 762a93fe30
commit c4d0ffaec9
30 changed files with 107 additions and 92 deletions

View file

@ -13,10 +13,10 @@
namespace ircd::m
{
bool seek(event::fetch &, const event::idx &, const event::id &, std::nothrow_t);
bool seek(event::fetch &, const event::idx &, std::nothrow_t);
bool seek(std::nothrow_t, event::fetch &, const event::idx &, const event::id &);
bool seek(std::nothrow_t, event::fetch &, const event::idx &);
bool seek(std::nothrow_t, event::fetch &, const event::id &);
void seek(event::fetch &, const event::idx &);
bool seek(event::fetch &, const event::id &, std::nothrow_t);
void seek(event::fetch &, const event::id &);
}
@ -62,9 +62,9 @@ struct ircd::m::event::fetch
bool assign_from_json(const string_view &key);
public:
explicit fetch(const idx &, const id &, std::nothrow_t, const opts & = default_opts);
fetch(const idx &, std::nothrow_t, const opts & = default_opts);
fetch(const id &, std::nothrow_t, const opts & = default_opts);
explicit fetch(std::nothrow_t, const idx &, const id &, const opts & = default_opts);
fetch(std::nothrow_t, const idx &, const opts & = default_opts);
fetch(std::nothrow_t, const id &, const opts & = default_opts);
fetch(const id &, const opts & = default_opts);
fetch(const idx &, const opts & = default_opts);
fetch(const opts & = default_opts);

View file

@ -179,7 +179,7 @@ ircd::m::dbs::_index_event_horizon_resolve(db::txn &txn,
assert(event_idx != opts.event_idx);
const event::fetch _event
{
event_idx, std::nothrow
std::nothrow, event_idx
};
if(!_event.valid)

View file

@ -16,50 +16,52 @@ void
ircd::m::seek(event::fetch &fetch,
const event::id &event_id)
{
if(!seek(fetch, event_id, std::nothrow))
if(!seek(std::nothrow, fetch, event_id))
throw m::NOT_FOUND
{
"%s not found in database", event_id
"%s not found in database",
event_id
};
}
bool
ircd::m::seek(event::fetch &fetch,
const event::id &event_id,
std::nothrow_t)
ircd::m::seek(std::nothrow_t,
event::fetch &fetch,
const event::id &event_id)
{
const auto &event_idx
{
index(std::nothrow, event_id)
};
return seek(fetch, event_idx, event_id, std::nothrow);
return seek(std::nothrow, fetch, event_idx, event_id);
}
void
ircd::m::seek(event::fetch &fetch,
const event::idx &event_idx)
{
if(!seek(fetch, event_idx, std::nothrow))
if(!seek(std::nothrow, fetch, event_idx))
throw m::NOT_FOUND
{
"%lu not found in database", event_idx
"%lu not found in database",
event_idx
};
}
bool
ircd::m::seek(event::fetch &fetch,
const event::idx &event_idx,
std::nothrow_t)
ircd::m::seek(std::nothrow_t,
event::fetch &fetch,
const event::idx &event_idx)
{
return seek(fetch, event_idx, m::event::id{}, std::nothrow);
return seek(std::nothrow, fetch, event_idx, m::event::id{});
}
bool
ircd::m::seek(event::fetch &fetch,
ircd::m::seek(std::nothrow_t,
event::fetch &fetch,
const event::idx &event_idx,
const event::id &event_id,
std::nothrow_t)
const event::id &event_id)
{
fetch.event_idx = event_idx;
fetch.event_id_buf = event_id?
@ -113,24 +115,31 @@ ircd::m::event::fetch::fetch(const event::id &event_id,
const opts &opts)
:fetch
{
index(event_id), event_id, std::nothrow, opts
std::nothrow,
index(event_id),
event_id,
opts,
}
{
if(!valid)
throw m::NOT_FOUND
{
"%s not found in database", string_view{event_id}
"%s not found in database",
string_view{event_id}
};
}
/// Seek to event_id and populate this event from database.
/// Event is not populated if not found in database.
ircd::m::event::fetch::fetch(const event::id &event_id,
std::nothrow_t,
ircd::m::event::fetch::fetch(std::nothrow_t,
const event::id &event_id,
const opts &opts)
:fetch
{
index(std::nothrow, event_id), event_id, std::nothrow, opts
std::nothrow,
index(std::nothrow, event_id),
event_id,
opts,
}
{
}
@ -141,31 +150,37 @@ ircd::m::event::fetch::fetch(const event::idx &event_idx,
const opts &opts)
:fetch
{
event_idx, std::nothrow, opts
std::nothrow,
event_idx,
opts,
}
{
if(!valid)
throw m::NOT_FOUND
{
"idx %zu not found in database", event_idx
"idx %zu not found in database",
event_idx
};
}
ircd::m::event::fetch::fetch(const event::idx &event_idx,
std::nothrow_t,
ircd::m::event::fetch::fetch(std::nothrow_t,
const event::idx &event_idx,
const opts &opts)
:fetch
{
event_idx, m::event::id{}, std::nothrow, opts
std::nothrow,
event_idx,
m::event::id{},
opts,
}
{
}
/// Seek to event_idx and populate this event from database.
/// Event is not populated if not found in database.
ircd::m::event::fetch::fetch(const event::idx &event_idx,
ircd::m::event::fetch::fetch(std::nothrow_t,
const event::idx &event_idx,
const event::id &event_id,
std::nothrow_t,
const opts &opts)
:fopts
{

View file

@ -248,7 +248,7 @@ ircd::m::events::for_each(const range &range,
};
for(; start != stop; ascending? ++start : --start)
if(seek(event, start, std::nothrow))
if(seek(std::nothrow, event, start))
if(!closure(start, event))
return false;
@ -273,7 +273,7 @@ ircd::m::events::for_each(const range &range,
{
const m::event::fetch event
{
event_idx, std::nothrow, range.fopts? *range.fopts : event::fetch::default_opts
std::nothrow, event_idx, range.fopts? *range.fopts : event::fetch::default_opts
};
if(!event.valid)

View file

@ -711,7 +711,7 @@ ircd::m::load_conf_item(const m::event::idx &event_idx)
const m::event::fetch event
{
event_idx, std::nothrow, fopts
std::nothrow, event_idx, fopts
};
return event.valid && load_conf_item(event);

View file

@ -650,7 +650,7 @@ ircd::m::init::backfill::gossip(const room::id &room_id,
m::event::fetch event;
for(assert(ret == 0); ret < i; ++ret)
if(seek(event, next_idx.at(ret), std::nothrow))
if(seek(std::nothrow, event, next_idx.at(ret)))
pdus.append(event.source);
}

View file

@ -122,7 +122,7 @@ ircd::m::presence::get(const std::nothrow_t,
const m::event::fetch event
{
event_idx, std::nothrow, fopts
std::nothrow, event_idx, fopts
};
if(event.valid)

View file

@ -542,7 +542,7 @@ ircd::m::push::rule::for_each(const path &path,
const m::event::fetch event
{
event_idx, std::nothrow, fopts
std::nothrow, event_idx, fopts
};
if(!event.valid)

View file

@ -1254,7 +1254,7 @@ const
return for_each(type, event::closure_idx_bool{[&closure, &event]
(const event::idx &event_idx)
{
if(!seek(event, event_idx, std::nothrow))
if(!seek(std::nothrow, event, event_idx))
return true;
return closure(event);

View file

@ -342,7 +342,7 @@ ircd::m::room::auth::check(const event &event,
std::array<m::event::fetch, 5> auth;
for(size_t i(0), j(0); i < idx.size(); ++i)
if(idx.at(i))
m::seek(auth.at(j++), idx.at(i), std::nothrow);
m::seek(std::nothrow, auth.at(j++), idx.at(i));
size_t j(0);
std::array<const m::event *, 5> authv;
@ -819,7 +819,7 @@ const
{
const auto idx(aq.front());
aq.pop_front();
if(!seek(e, idx, std::nothrow))
if(!seek(std::nothrow, e, idx))
continue;
const m::event::prev prev{e};
@ -841,7 +841,7 @@ const
auto it(ae.lower_bound(auth_event_idx));
if(it == end(ae) || *it != auth_event_idx)
{
seek(a, auth_event_idx, std::nothrow);
seek(std::nothrow, a, auth_event_idx);
ae.emplace_hint(it, auth_event_idx);
if(a.valid)
aq.emplace_back(auth_event_idx);

View file

@ -330,7 +330,7 @@ ircd::m::room::events::fetch()
const ircd::m::event &
ircd::m::room::events::fetch(std::nothrow_t)
{
m::seek(_event, event_idx(), std::nothrow);
m::seek(std::nothrow, _event, event_idx());
return _event;
}

View file

@ -312,7 +312,7 @@ ircd::m::room::head::reset(const head &head)
{
const m::event::fetch event
{
event_idx, std::nothrow
std::nothrow, event_idx
};
if(!event.valid)

View file

@ -197,7 +197,7 @@ const
{
const event::fetch event
{
event_idx, std::nothrow, fopts? *fopts : event::fetch::default_opts
std::nothrow, event_idx, fopts? *fopts : event::fetch::default_opts
};
closure(event);
@ -265,7 +265,7 @@ const
const m::event::fetch event
{
event_idx, std::nothrow, fopts
std::nothrow, event_idx, fopts
};
if(!event.valid)
@ -377,7 +377,7 @@ const
return for_each(event::closure_idx_bool{[&event, &closure]
(const event::idx &event_idx)
{
if(seek(event, event_idx, std::nothrow))
if(seek(std::nothrow, event, event_idx))
if(!closure(event))
return false;
@ -589,7 +589,7 @@ const
return for_each(type, state_key_lb, event::closure_idx_bool{[&event, &closure]
(const event::idx &event_idx)
{
if(seek(event, event_idx, std::nothrow))
if(seek(std::nothrow, event, event_idx))
if(!closure(event))
return false;
@ -926,7 +926,7 @@ ircd::m::room::state::rebuild::rebuild(const room::id &room_id)
{
const m::event::fetch &event
{
event_idx, std::nothrow
std::nothrow, event_idx
};
if(!event.valid)
@ -946,7 +946,7 @@ ircd::m::room::state::rebuild::rebuild(const room::id &room_id)
{
const m::event::fetch &event
{
event_idx, std::nothrow
std::nothrow, event_idx
};
if(!event.valid)

View file

@ -30,7 +30,7 @@ const
return for_each([&closure, &event]
(const event::idx &event_idx)
{
if(!seek(event, event_idx, std::nothrow))
if(!seek(std::nothrow, event, event_idx))
return true;
return closure(event);

View file

@ -156,7 +156,7 @@ ircd::m::user::filter::for_each(const m::user &user,
const event::fetch event
{
event_idx, std::nothrow, fopts
std::nothrow, event_idx, fopts
};
if(!event.valid)

View file

@ -143,7 +143,7 @@ ircd::m::get_notifications(client &client,
const m::event::fetch event
{
event_idx, std::nothrow
std::nothrow, event_idx
};
if(unlikely(!event.valid))

View file

@ -267,7 +267,7 @@ get__context(client &client,
if(lazy_loaded)
return true;
if(!seek(event, event_idx, std::nothrow))
if(!seek(std::nothrow, event, event_idx))
return true;
if(!visible(event, request.user_id))

View file

@ -194,7 +194,7 @@ get__initialsync_local(client &client,
{
const m::event::fetch event
{
event_id, std::nothrow
std::nothrow, event_id
};
if(!event.valid)

View file

@ -171,7 +171,7 @@ get__members(client &client,
if(!membership && !membership_match(member, event_idx))
return true;
if(!seek(event, event_idx, std::nothrow))
if(!seek(std::nothrow, event, event_idx))
return true;
chunk.append(event);

View file

@ -134,13 +134,13 @@ try
m::event::fetch event
{
event_idx, std::nothrow
std::nothrow, event_idx
};
const auto each_ref{[&event, &append, &rel_type, &request]
(const m::event::idx &event_idx, const m::dbs::ref &)
{
if(!seek(event, event_idx, std::nothrow))
if(!seek(std::nothrow, event, event_idx))
return true;
const json::object &m_relates_to

View file

@ -930,7 +930,7 @@ ircd::m::sync::longpoll::polled(data &data,
{
const m::event::fetch event
{
data.range.second, std::nothrow
std::nothrow, data.range.second
};
if(!event.valid)

View file

@ -95,7 +95,7 @@ ircd::m::sync::account_data_polylog(data &data)
const m::event::fetch event
{
event_idx, std::nothrow, fopts
std::nothrow, event_idx, fopts
};
if(!event.valid)

View file

@ -234,7 +234,7 @@ ircd::m::sync::room_account_data_polylog_events(data &data)
m::event::fetch event
{
event_idx, std::nothrow, fopts
std::nothrow, event_idx, fopts
};
if(!event.valid)
@ -315,7 +315,7 @@ ircd::m::sync::room_account_data_polylog_tags(data &data)
const m::event::fetch event
{
event_idx, std::nothrow, fopts
std::nothrow, event_idx, fopts
};
if(!event.valid)

View file

@ -184,7 +184,7 @@ ircd::m::sync::_handle_message(data &data,
assert(type == dbs::ref::M_RECEIPT__M_READ);
const m::event::fetch event
{
idx, std::nothrow, receipt_fopts
std::nothrow, idx, receipt_fopts
};
if(event.valid)

View file

@ -167,7 +167,7 @@ ircd::m::sync::room_state_linear_events(data &data)
{
const event::fetch event
{
event_idx, std::nothrow
std::nothrow, event_idx
};
if(event.valid)
@ -283,7 +283,7 @@ ircd::m::sync::room_state_polylog_events(data &data)
assert(i < events.size());
auto &event(events.at(i));
if(!m::seek(event, event_idx, std::nothrow))
if(!m::seek(std::nothrow, event, event_idx))
{
log::error
{
@ -483,7 +483,7 @@ ircd::m::sync::room_state_phased_member_events(data &data,
std::for_each(begin(event_idx), end, [&data, &array, &ret, &event]
(const event::idx &sender_idx)
{
if(!seek(event, sender_idx, std::nothrow))
if(!seek(std::nothrow, event, sender_idx))
return;
ret |= room_state_append(data, array, event, sender_idx, false);

View file

@ -6823,7 +6823,7 @@ console_cmd__events__in__sender(opt &out, const string_view &line)
{
const m::event::fetch event
{
event_idx, std::nothrow
std::nothrow, event_idx
};
if(!event.valid)
@ -6863,7 +6863,7 @@ console_cmd__events__in__origin(opt &out, const string_view &line)
{
const m::event::fetch event
{
event_idx, std::nothrow
std::nothrow, event_idx
};
if(!event.valid)
@ -6897,7 +6897,7 @@ console_cmd__events__in__type(opt &out, const string_view &line)
{
const m::event::fetch event
{
event_idx, std::nothrow
std::nothrow, event_idx
};
if(!event.valid)
@ -7234,7 +7234,7 @@ console_cmd__event(opt &out, const string_view &line)
for(size_t i(0); i < prev.auth_events_count(); ++i)
{
const m::event::id &id{prev.auth_event(i)};
const m::event::fetch event{id, std::nothrow};
const m::event::fetch event{std::nothrow, id};
if(!event.valid)
{
out << "x-> AUTH "
@ -7252,7 +7252,7 @@ console_cmd__event(opt &out, const string_view &line)
for(size_t i(0); i < prev.prev_events_count(); ++i)
{
const m::event::id &id{prev.prev_event(i)};
const m::event::fetch event{id, std::nothrow};
const m::event::fetch event{std::nothrow, id};
if(!event.valid)
{
out << "x-> PREV " << id << std::endl;
@ -7817,7 +7817,7 @@ console_cmd__event__refs(opt &out, const string_view &line)
{
const m::event::fetch event
{
idx, std::nothrow
std::nothrow, idx
};
if(!event.valid)
@ -7857,7 +7857,7 @@ console_cmd__event__refs__next(opt &out, const string_view &line)
{
const m::event::fetch event
{
idx, std::nothrow
std::nothrow, idx
};
if(!event.valid)
@ -7902,7 +7902,7 @@ console_cmd__event__refs__auth(opt &out, const string_view &line)
{
const m::event::fetch event
{
idx, std::nothrow
std::nothrow, idx
};
if(!event.valid)
@ -8372,7 +8372,7 @@ console_cmd__room__top(opt &out, const string_view &line)
const m::event::fetch event
{
event_idx, std::nothrow
std::nothrow, event_idx
};
if(!event.valid)
@ -8406,7 +8406,7 @@ console_cmd__room__top(opt &out, const string_view &line)
const m::event::fetch event
{
event_idx, std::nothrow
std::nothrow, event_idx
};
if(event.valid)
@ -8533,7 +8533,7 @@ console_cmd__room__head(opt &out, const string_view &line)
{
const m::event::fetch event
{
event_idx, std::nothrow
std::nothrow, event_idx
};
out << pretty_oneline(event) << std::endl;
@ -9196,7 +9196,7 @@ console_cmd__room__members__events(opt &out, const string_view &line)
{
const m::event::fetch event
{
event_idx, std::nothrow
std::nothrow, event_idx
};
if(!event.valid)
@ -9292,7 +9292,7 @@ console_cmd__room__members__origin(opt &out, const string_view &line)
const m::event::fetch event
{
event_idx, std::nothrow
std::nothrow, event_idx
};
if(!event.valid)
@ -9507,7 +9507,7 @@ console_cmd__room__state(opt &out, const string_view &line)
{
const m::event::fetch event
{
event_idx, std::nothrow
std::nothrow, event_idx
};
if(!event.valid)
@ -9767,7 +9767,7 @@ console_cmd__room__state__history(opt &out, const string_view &line)
{
const m::event::fetch event
{
event_idx, std::nothrow
std::nothrow, event_idx
};
if(!event.valid)
@ -9825,7 +9825,7 @@ console_cmd__room__state__space(opt &out, const string_view &line)
{
const m::event::fetch event
{
event_idx, std::nothrow
std::nothrow, event_idx
};
if(!event.valid)
@ -10406,7 +10406,7 @@ console_cmd__room__type(opt &out, const string_view &line)
events.for_each([&out, &event]
(const string_view &type, const uint64_t &depth, const m::event::idx &event_idx)
{
if(!seek(event, event_idx, std::nothrow))
if(!seek(std::nothrow, event, event_idx))
return true;
out
@ -10813,7 +10813,7 @@ console_cmd__room__auth(opt &out, const string_view &line)
{
const m::event::fetch event
{
idx, std::nothrow
std::nothrow, idx
};
out << idx;
@ -12589,7 +12589,7 @@ console_cmd__feds__head(opt &out, const string_view &line)
const m::event::fetch prev_event
{
prev_event_id, std::nothrow
std::nothrow, prev_event_id
};
out << std::setw(8) << std::right << event["depth"] << " ";
@ -13960,7 +13960,7 @@ console_cmd__fed__query_auth(opt &out, const string_view &line)
chain.for_each([&auth_chain, &event]
(const m::event::idx &event_idx)
{
if(seek(event, event_idx, std::nothrow))
if(seek(std::nothrow, event, event_idx))
auth_chain.append(event);
return true;

View file

@ -122,7 +122,7 @@ get__event_auth(client &client,
chain.for_each([&auth_chain, &event]
(const m::event::idx &event_idx)
{
if(seek(event, event_idx, std::nothrow))
if(seek(std::nothrow, event, event_idx))
auth_chain.append(event);
return true;

View file

@ -159,7 +159,7 @@ get__missing_events(client &client,
queue.pop_front();
}};
if(!seek(event, event_id, std::nothrow))
if(!seek(std::nothrow, event, event_id))
continue;
if(!visible(event, request.node_id))

View file

@ -236,7 +236,7 @@ send_join__response(client &client,
{
const m::event::fetch event
{
event_idx, std::nothrow
std::nothrow, event_idx
};
if(event.valid)

View file

@ -120,7 +120,7 @@ get__state(client &client,
ac.for_each([&auth_chain, &event]
(const m::event::idx &event_idx)
{
if(seek(event, event_idx, std::nothrow))
if(seek(std::nothrow, event, event_idx))
auth_chain.append(event);
return true;