|
|
|
@ -63,6 +63,43 @@ Object JSONRPCError(int code, const string& message)
@@ -63,6 +63,43 @@ Object JSONRPCError(int code, const string& message)
|
|
|
|
|
return error; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void RPCTypeCheck(const Array& params, |
|
|
|
|
const list<Value_type>& typesExpected) |
|
|
|
|
{ |
|
|
|
|
int i = 0; |
|
|
|
|
BOOST_FOREACH(Value_type t, typesExpected) |
|
|
|
|
{ |
|
|
|
|
if (params.size() <= i) |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
const Value& v = params[i]; |
|
|
|
|
if (v.type() != t) |
|
|
|
|
{ |
|
|
|
|
string err = strprintf("Expected type %s, got %s", |
|
|
|
|
Value_type_name[t], Value_type_name[v.type()]); |
|
|
|
|
throw JSONRPCError(-3, err); |
|
|
|
|
} |
|
|
|
|
i++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void RPCTypeCheck(const Object& o, |
|
|
|
|
const map<string, Value_type>& typesExpected) |
|
|
|
|
{ |
|
|
|
|
BOOST_FOREACH(const PAIRTYPE(string, Value_type)& t, typesExpected) |
|
|
|
|
{ |
|
|
|
|
const Value& v = find_value(o, t.first); |
|
|
|
|
if (v.type() == null_type) |
|
|
|
|
throw JSONRPCError(-3, strprintf("Missing %s", t.first.c_str())); |
|
|
|
|
if (v.type() != t.second) |
|
|
|
|
{ |
|
|
|
|
string err = strprintf("Expected type %s for %s, got %s", |
|
|
|
|
Value_type_name[t.second], t.first.c_str(), Value_type_name[v.type()]); |
|
|
|
|
throw JSONRPCError(-3, err); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
double GetDifficulty(const CBlockIndex* blockindex = NULL) |
|
|
|
|
{ |
|
|
|
|
// Floating point number that is a multiple of the minimum difficulty,
|
|
|
|
|