diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -2656,7 +2656,7 @@ // no scan in progress return NullUniValue; } - result.pushKV("progress", g_scan_progress); + result.pushKV("progress", g_scan_progress.load()); return result; } else if (request.params[0].get_str() == "abort") { CoinsViewScanReserver reserver; diff --git a/src/univalue/README.md b/src/univalue/README.md --- a/src/univalue/README.md +++ b/src/univalue/README.md @@ -18,6 +18,17 @@ and memory use, providing a straightforward RAII class compatible with link-time optimization and embedded uses. +## Status + +The current production version is available from the [stable-1.0.x branch](https://github.com/jgarzik/univalue/tree/stable-1.0.x). + +The current development series is 1.1.x, and is pushed to the `master` branch. + +The next stable version will be 1.2.0, to be released immediately +following the conclusion of the 1.1.x series, similar to [this +variant](https://en.wikipedia.org/wiki/Software_versioning#Odd-numbered_versions_for_development_releases) +of semver. + ## Installation This project is a standard GNU diff --git a/src/univalue/configure.ac b/src/univalue/configure.ac --- a/src/univalue/configure.ac +++ b/src/univalue/configure.ac @@ -14,7 +14,7 @@ m4_define([libunivalue_version], [libunivalue_major_version().libunivalue_minor_version().libunivalue_micro_version()libunivalue_extraversion()]) -AC_INIT([univalue], [1.0.5], +AC_INIT([univalue], [1.1.1], [http://github.com/jgarzik/univalue/]) dnl make the compilation flags quiet unless V=1 is used diff --git a/src/univalue/include/univalue.h b/src/univalue/include/univalue.h --- a/src/univalue/include/univalue.h +++ b/src/univalue/include/univalue.h @@ -26,11 +26,8 @@ public: enum VType { VNULL, VOBJ, VARR, VSTR, VNUM, VBOOL, }; - UniValue() { typ = VNULL; } - UniValue(UniValue::VType initialType, const std::string& initialStr = "") { - typ = initialType; - val = initialStr; - } + UniValue() : typ(VNULL) {} + UniValue(UniValue::VType type, const std::string& value = std::string()) : typ(type), val(value) {} UniValue(uint64_t val_) { setInt(val_); } @@ -53,9 +50,17 @@ std::string s(val_); setStr(s); } - ~UniValue() {} void clear(); + void reserve(size_t n) { + if (typ == VOBJ || typ == VARR) { + if (typ == VOBJ) + keys.reserve(n); + values.reserve(n); + } else if (typ != VNULL) { + val.reserve(n); + } + } bool setNull(); bool setBool(bool val); @@ -91,62 +96,10 @@ bool isObject() const { return (typ == VOBJ); } bool push_back(const UniValue& val); - bool push_back(const std::string& val_) { - UniValue tmpVal(VSTR, val_); - return push_back(tmpVal); - } - bool push_back(const char *val_) { - std::string s(val_); - return push_back(s); - } - bool push_back(uint64_t val_) { - UniValue tmpVal(val_); - return push_back(tmpVal); - } - bool push_back(int64_t val_) { - UniValue tmpVal(val_); - return push_back(tmpVal); - } - bool push_back(int val_) { - UniValue tmpVal(val_); - return push_back(tmpVal); - } - bool push_back(double val_) { - UniValue tmpVal(val_); - return push_back(tmpVal); - } bool push_backV(const std::vector& vec); void __pushKV(const std::string& key, const UniValue& val); bool pushKV(const std::string& key, const UniValue& val); - bool pushKV(const std::string& key, const std::string& val_) { - UniValue tmpVal(VSTR, val_); - return pushKV(key, tmpVal); - } - bool pushKV(const std::string& key, const char *val_) { - std::string _val(val_); - return pushKV(key, _val); - } - bool pushKV(const std::string& key, int64_t val_) { - UniValue tmpVal(val_); - return pushKV(key, tmpVal); - } - bool pushKV(const std::string& key, uint64_t val_) { - UniValue tmpVal(val_); - return pushKV(key, tmpVal); - } - bool pushKV(const std::string& key, bool val_) { - UniValue tmpVal((bool)val_); - return pushKV(key, tmpVal); - } - bool pushKV(const std::string& key, int val_) { - UniValue tmpVal((int64_t)val_); - return pushKV(key, tmpVal); - } - bool pushKV(const std::string& key, double val_) { - UniValue tmpVal(val_); - return pushKV(key, tmpVal); - } bool pushKVs(const UniValue& obj); std::string write(unsigned int prettyIndent = 0, diff --git a/src/univalue/test/object.cpp b/src/univalue/test/object.cpp --- a/src/univalue/test/object.cpp +++ b/src/univalue/test/object.cpp @@ -142,6 +142,8 @@ BOOST_CHECK(v.isArray()); BOOST_CHECK_EQUAL(v.size(), 0); + BOOST_CHECK(v.setStr("")); + v.reserve(3); BOOST_CHECK(v.setStr("zum")); BOOST_CHECK(v.isStr()); BOOST_CHECK_EQUAL(v.getValStr(), "zum"); @@ -187,6 +189,7 @@ BOOST_AUTO_TEST_CASE(univalue_array) { UniValue arr(UniValue::VARR); + arr.reserve(9); UniValue v((int64_t)1023LL); BOOST_CHECK(arr.push_back(v)); @@ -237,6 +240,8 @@ std::string strKey, strVal; UniValue v; + obj.reserve(11); + strKey = "age"; v.setInt(100); BOOST_CHECK(obj.pushKV(strKey, v));