diff options
author | Brandon Dahler <brandon.dahler@gmail.com> | 2013-04-13 00:13:08 -0500 |
---|---|---|
committer | Brandon Dahler <brandon.dahler@gmail.com> | 2013-11-10 09:36:28 -0600 |
commit | 51ed9ec971614aebdbfbd9527aba365dd0afd437 (patch) | |
tree | d2f910390e55aef857023812fbdaefdd66cd99ff /src/rpcdump.cpp | |
parent | 7c4c207be8420d394a5abc4368d1bb69ad4f8067 (diff) |
Cleanup code using forward declarations.
Use misc methods of avoiding unnecesary header includes.
Replace int typedefs with int##_t from stdint.h.
Replace PRI64[xdu] with PRI[xdu]64 from inttypes.h.
Normalize QT_VERSION ifs where possible.
Resolve some indirect dependencies as direct ones.
Remove extern declarations from .cpp files.
Diffstat (limited to 'src/rpcdump.cpp')
-rw-r--r-- | src/rpcdump.cpp | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/src/rpcdump.cpp b/src/rpcdump.cpp index f24e6b8a9c..68d412490b 100644 --- a/src/rpcdump.cpp +++ b/src/rpcdump.cpp @@ -2,30 +2,33 @@ // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include <iostream> -#include <fstream> -#include "init.h" // for pwalletMain -#include "wallet.h" -#include "bitcoinrpc.h" -#include "ui_interface.h" + #include "base58.h" +#include "bitcoinrpc.h" +#include "init.h" +#include "main.h" +#include "sync.h" +#include "wallet.h" +#include <fstream> +#include <stdint.h> + +#include <boost/algorithm/string.hpp> #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/lexical_cast.hpp> -#include <boost/variant/get.hpp> -#include <boost/algorithm/string.hpp> +#include "json/json_spirit_value.h" using namespace json_spirit; using namespace std; void EnsureWalletIsUnlocked(); -std::string static EncodeDumpTime(int64 nTime) { - return DateTimeStrFormat("%Y-%m-%dT%H:%M:%SZ", nTime); +std::string static EncodeDumpTime(int64_t nTime) { + return DateTimeStrFormat("%Y-%m-%"PRId64"T%H:%M:%SZ", nTime); } -int64 static DecodeDumpTime(const std::string &str) { +int64_t static DecodeDumpTime(const std::string &str) { static boost::posix_time::time_input_facet facet("%Y-%m-%dT%H:%M:%SZ"); static const boost::posix_time::ptime epoch = boost::posix_time::from_time_t(0); const std::locale loc(std::locale::classic(), &facet); @@ -125,7 +128,8 @@ Value importwallet(const Array& params, bool fHelp) if (!file.is_open()) throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file"); - int64 nTimeBegin = chainActive.Tip()->nTime; + int64_t nTimeBegin = chainActive.Tip()->nTime; + bool fGood = true; @@ -149,7 +153,7 @@ Value importwallet(const Array& params, bool fHelp) LogPrintf("Skipping import of %s (key already present)\n", CBitcoinAddress(keyid).ToString().c_str()); continue; } - int64 nTime = DecodeDumpTime(vstr[1]); + int64_t nTime = DecodeDumpTime(vstr[1]); std::string strLabel; bool fLabel = true; for (unsigned int nStr = 2; nStr < vstr.size(); nStr++) { @@ -228,14 +232,14 @@ Value dumpwallet(const Array& params, bool fHelp) if (!file.is_open()) throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file"); - std::map<CKeyID, int64> mapKeyBirth; + std::map<CKeyID, int64_t> mapKeyBirth; std::set<CKeyID> setKeyPool; pwalletMain->GetKeyBirthTimes(mapKeyBirth); pwalletMain->GetAllReserveKeys(setKeyPool); // sort time/key pairs - std::vector<std::pair<int64, CKeyID> > vKeyBirth; - for (std::map<CKeyID, int64>::const_iterator it = mapKeyBirth.begin(); it != mapKeyBirth.end(); it++) { + std::vector<std::pair<int64_t, CKeyID> > vKeyBirth; + for (std::map<CKeyID, int64_t>::const_iterator it = mapKeyBirth.begin(); it != mapKeyBirth.end(); it++) { vKeyBirth.push_back(std::make_pair(it->second, it->first)); } mapKeyBirth.clear(); @@ -247,7 +251,7 @@ Value dumpwallet(const Array& params, bool fHelp) file << strprintf("# * Best block at time of backup was %i (%s),\n", chainActive.Height(), chainActive.Tip()->GetBlockHash().ToString().c_str()); file << strprintf("# mined on %s\n", EncodeDumpTime(chainActive.Tip()->nTime).c_str()); file << "\n"; - for (std::vector<std::pair<int64, CKeyID> >::const_iterator it = vKeyBirth.begin(); it != vKeyBirth.end(); it++) { + for (std::vector<std::pair<int64_t, CKeyID> >::const_iterator it = vKeyBirth.begin(); it != vKeyBirth.end(); it++) { const CKeyID &keyid = it->second; std::string strTime = EncodeDumpTime(it->first); std::string strAddr = CBitcoinAddress(keyid).ToString(); |