0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-25 23:14:13 +01:00

modules/federation/get_missing_events: Improve limit value clamp; conf items; defaults.

This commit is contained in:
Jason Volk 2020-10-23 19:43:16 -07:00
parent 1874400bdd
commit e79c619ece

View file

@ -49,8 +49,15 @@ method_post
conf::item<ssize_t>
max_limit
{
{ "name", "ircd.federation.missing_events.max_limit" },
{ "default", 128L }
{ "name", "ircd.federation.missing_events.limit.max" },
{ "default", 256L },
};
conf::item<ssize_t>
min_limit
{
{ "name", "ircd.federation.missing_events.limit.min" },
{ "default", 1L },
};
conf::item<size_t>
@ -83,9 +90,12 @@ get__missing_events(client &client,
ssize_t limit
{
request["limit"]?
std::min(lex_cast<ssize_t>(request["limit"]), ssize_t(max_limit)):
ssize_t(10) // default limit (protocol spec)
std::clamp
(
request.get("limit", 10L), // protocol spec default
ssize_t(min_limit),
ssize_t(max_limit)
)
};
const auto min_depth