File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change 55#include < util/skip_set.h>
66
77#include < logging.h>
8+ #include < stdexcept>
89
910bool CSkipSet::Add (uint64_t value)
1011{
11- assert (!Contains (value));
12+ if (!Contains (value)) {
13+ throw std::runtime_error (strprintf (" %s: trying to add an element that can't be added" , __func__));
14+ }
1215
1316 if (auto it = skipped.find (value); it != skipped.end ()) {
1417 skipped.erase (it);
Original file line number Diff line number Diff line change 55#include < serialize.h>
66#include < unordered_set>
77
8- // This datastructure keeps efficiently all indexes and have a strict limit for used memory
8+ // This data structure keeps efficiently all indexes and have a strict limit for used memory
99// So far as CCreditPool is built only in direction from parent block to child
1010// there's no need to remove elements from CSkipSet ever, only add them
1111class CSkipSet {
@@ -19,8 +19,12 @@ class CSkipSet {
1919 {}
2020
2121 /* *
22- * adding value that already exist in CKipSet will cause `assert`.
22+ * `Add` returns true if element has been added correctly and false if
23+ * capacity is depleted.
2324 *
25+ * `Add` should not be called if the element has been already added.
26+ * Use `Contains` to check if the element is here
27+ * Adding existing value will cause an exception
2428 */
2529 [[nodiscard]] bool Add (uint64_t value);
2630
You can’t perform that action at this time.
0 commit comments