diff options
| author | Dan Engelbrecht <[email protected]> | 2024-09-23 19:19:40 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-09-23 19:19:40 +0200 |
| commit | bc9e590727211d803cce7be84c1cbc026179b841 (patch) | |
| tree | 96d89b59cdced94ce1d795cd941d35d26f6c5e88 /src/zen/cmds/admin_cmd.cpp | |
| parent | made fmt formatter format function const (#162) (diff) | |
| download | archived-zen-bc9e590727211d803cce7be84c1cbc026179b841.tar.xz archived-zen-bc9e590727211d803cce7be84c1cbc026179b841.zip | |
gc unused refactor (#165)
* optimize IoHash and OId comparisions
* refactor filtering of unused references
* add attachment filtering to gc
Diffstat (limited to 'src/zen/cmds/admin_cmd.cpp')
| -rw-r--r-- | src/zen/cmds/admin_cmd.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/zen/cmds/admin_cmd.cpp b/src/zen/cmds/admin_cmd.cpp index f5bd15ea2..dd0bf83de 100644 --- a/src/zen/cmds/admin_cmd.cpp +++ b/src/zen/cmds/admin_cmd.cpp @@ -119,6 +119,18 @@ GcCommand::GcCommand() "Force GC to run single threaded", cxxopts::value(m_SingleThreaded)->default_value("false"), "<single-threaded>"); + m_Options.add_option("", + "", + "reference-low", + "Reference filter lower limit - defaults to no limit", + cxxopts::value(m_ReferenceHashLow), + "<reflowlimit>"); + m_Options.add_option("", + "", + "reference-high", + "Reference filter higher limit - defaults to no limit", + cxxopts::value(m_ReferenceHashHigh), + "<refhighlimit>"); } GcCommand::~GcCommand() @@ -170,6 +182,38 @@ GcCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) { Params.Add({"compactblockthreshold", fmt::format("{}", m_CompactBlockThreshold)}); } + IoHash LowRef = IoHash::Zero; + if (!m_ReferenceHashLow.empty()) + { + if (m_ReferenceHashLow.length() != IoHash::StringLength) + { + throw OptionParseException(fmt::format("reference-low must be a {} character hex string", IoHash::StringLength)); + } + LowRef = IoHash::FromHexString(m_ReferenceHashLow); + } + IoHash HighRef = IoHash::Max; + if (!m_ReferenceHashHigh.empty()) + { + if (m_ReferenceHashHigh.length() != IoHash::StringLength) + { + throw OptionParseException(fmt::format("reference-high must be a {} character hex string", IoHash::StringLength)); + } + HighRef = IoHash::FromHexString(m_ReferenceHashHigh); + } + + if (HighRef < LowRef) + { + throw OptionParseException(fmt::format("invalid reference range, reference-high must be higher value than reference-low")); + } + if (LowRef != IoHash::Zero) + { + Params.Add({"referencehashlow", LowRef.ToHexString()}); + } + if (HighRef != IoHash::Max) + { + Params.Add({"referencehashhigh", HighRef.ToHexString()}); + } + Params.Add({"verbose", m_Verbose ? "true" : "false"}); Params.Add({"singlethreaded", m_SingleThreaded ? "true" : "false"}); |