diff options
| author | Jeff Garzik <[email protected]> | 2014-08-20 15:15:16 -0400 |
|---|---|---|
| committer | Jonas Schnelli <[email protected]> | 2015-06-04 09:16:05 +0200 |
| commit | 15982a8b69ec6ab3c3a6bf71fc6a9b681d3ff541 (patch) | |
| tree | 854a48a039d4199dbc1acf33ef94d06d007f1348 /src/bitcoin-cli.cpp | |
| parent | UniValue: export NullUniValue global constant (diff) | |
| download | discoin-15982a8b69ec6ab3c3a6bf71fc6a9b681d3ff541.tar.xz discoin-15982a8b69ec6ab3c3a6bf71fc6a9b681d3ff541.zip | |
Convert tree to using univalue. Eliminate all json_spirit uses.
Diffstat (limited to 'src/bitcoin-cli.cpp')
| -rw-r--r-- | src/bitcoin-cli.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 1269d7a11..9950153a6 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -143,7 +143,7 @@ Object CallRPC(const string& strMethod, const Array& params) // Parse reply Value valReply; - if (!read_string(strReply, valReply)) + if (!valReply.read(strReply)) throw runtime_error("couldn't parse reply from server"); const Object& reply = valReply.get_obj(); if (reply.empty()) @@ -176,29 +176,27 @@ int CommandLineRPC(int argc, char *argv[]) const bool fWait = GetBoolArg("-rpcwait", false); do { try { - const Object reply = CallRPC(strMethod, params); + // Execute + Object reply = CallRPC(strMethod, params); // Parse reply const Value& result = find_value(reply, "result"); const Value& error = find_value(reply, "error"); - if (error.type() != null_type) { + if (!error.isNull()) { // Error - const int code = find_value(error.get_obj(), "code").get_int(); - if (fWait && code == RPC_IN_WARMUP) - throw CConnectionFailed("server in warmup"); - strPrint = "error: " + write_string(error, false); + strPrint = "error: " + error.write(); + int code = error["code"].get_int(); nRet = abs(code); } else { // Result - if (result.type() == null_type) + if (result.isNull()) strPrint = ""; - else if (result.type() == str_type) + else if (result.isStr()) strPrint = result.get_str(); else - strPrint = write_string(result, true); + strPrint = result.write(2); } - // Connection succeeded, no need to retry. break; } |