CJentzsch
10 years ago
103 changed files with 1741 additions and 145 deletions
@ -0,0 +1,31 @@ |
|||
cmake_policy(SET CMP0015 NEW) |
|||
|
|||
file(GLOB HEADERS "*.h") |
|||
include_directories(BEFORE ${JSONCPP_INCLUDE_DIRS}) |
|||
include_directories(BEFORE ..) |
|||
include_directories(BEFORE ../..) |
|||
include_directories(${Boost_INCLUDE_DIRS}) |
|||
include_directories(${CRYPTOPP_INCLUDE_DIRS}) |
|||
include_directories(${JSON_RPC_CPP_INCLUDE_DIRS}) |
|||
|
|||
add_executable(createRandomVMTest createRandomVMTest.cpp ../libevm/vm.cpp ../TestHelper.cpp ../Stats.cpp) |
|||
add_executable(createRandomStateTest createRandomStateTest.cpp ../TestHelper.cpp ../Stats.cpp) |
|||
add_executable(checkRandomVMTest checkRandomVMTest.cpp ../libevm/vm.cpp ../TestHelper.cpp ../Stats.cpp) |
|||
add_executable(checkRandomStateTest checkRandomStateTest.cpp ../TestHelper.cpp ../Stats.cpp) |
|||
|
|||
target_link_libraries(createRandomVMTest ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) |
|||
target_link_libraries(createRandomVMTest ethereum) |
|||
target_link_libraries(createRandomVMTest ethcore) |
|||
target_link_libraries(createRandomVMTest testutils) |
|||
target_link_libraries(createRandomStateTest ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) |
|||
target_link_libraries(createRandomStateTest ethereum) |
|||
target_link_libraries(createRandomStateTest ethcore) |
|||
target_link_libraries(createRandomStateTest testutils) |
|||
target_link_libraries(checkRandomVMTest ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) |
|||
target_link_libraries(checkRandomVMTest ethereum) |
|||
target_link_libraries(checkRandomVMTest ethcore) |
|||
target_link_libraries(checkRandomVMTest testutils) |
|||
target_link_libraries(checkRandomStateTest ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) |
|||
target_link_libraries(checkRandomStateTest ethereum) |
|||
target_link_libraries(checkRandomStateTest ethcore) |
|||
target_link_libraries(checkRandomStateTest testutils) |
@ -0,0 +1,5 @@ |
|||
cmake_policy(SET CMP0015 NEW) |
|||
|
|||
aux_source_directory(. SRCS) |
|||
|
|||
add_sources(${SRCS}) |
@ -0,0 +1,5 @@ |
|||
cmake_policy(SET CMP0015 NEW) |
|||
|
|||
aux_source_directory(. SRCS) |
|||
|
|||
add_sources(${SRCS}) |
@ -0,0 +1,553 @@ |
|||
/*
|
|||
This file is part of cpp-ethereum. |
|||
|
|||
cpp-ethereum is free software: you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation, either version 3 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
cpp-ethereum is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License |
|||
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
/** @file trie.cpp
|
|||
* @author Gav Wood <i@gavwood.com> |
|||
* @date 2014 |
|||
* Trie test functions. |
|||
*/ |
|||
|
|||
#include <fstream> |
|||
#include <random> |
|||
|
|||
#include <boost/test/unit_test.hpp> |
|||
|
|||
#include "../JsonSpiritHeaders.h" |
|||
#include <libdevcore/CommonIO.h> |
|||
#include <libdevcrypto/TrieDB.h> |
|||
#include "TrieHash.h" |
|||
#include "MemTrie.h" |
|||
#include "../TestHelper.h" |
|||
|
|||
using namespace std; |
|||
using namespace dev; |
|||
|
|||
namespace js = json_spirit; |
|||
|
|||
namespace dev |
|||
{ |
|||
namespace test |
|||
{ |
|||
|
|||
static unsigned fac(unsigned _i) |
|||
{ |
|||
return _i > 2 ? _i * fac(_i - 1) : _i; |
|||
} |
|||
|
|||
} |
|||
} |
|||
|
|||
using dev::operator <<; |
|||
|
|||
BOOST_AUTO_TEST_SUITE(TrieTests) |
|||
|
|||
BOOST_AUTO_TEST_CASE(fat_trie) |
|||
{ |
|||
h256 r; |
|||
MemoryDB fm; |
|||
{ |
|||
FatGenericTrieDB<MemoryDB> ft(&fm); |
|||
ft.init(); |
|||
ft.insert(h256("69", h256::FromHex, h256::AlignRight).ref(), h256("414243", h256::FromHex, h256::AlignRight).ref()); |
|||
for (auto i: ft) |
|||
cnote << i.first << i.second; |
|||
r = ft.root(); |
|||
} |
|||
{ |
|||
FatGenericTrieDB<MemoryDB> ft(&fm); |
|||
ft.setRoot(r); |
|||
for (auto i: ft) |
|||
cnote << i.first << i.second; |
|||
} |
|||
} |
|||
|
|||
BOOST_AUTO_TEST_CASE(hex_encoded_securetrie_test) |
|||
{ |
|||
string testPath = test::getTestPath(); |
|||
|
|||
testPath += "/TrieTests"; |
|||
|
|||
cnote << "Testing Secure Trie..."; |
|||
js::mValue v; |
|||
string s = asString(contents(testPath + "/hex_encoded_securetrie_test.json")); |
|||
BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'hex_encoded_securetrie_test.json' is empty. Have you cloned the 'tests' repo branch develop?"); |
|||
js::read_string(s, v); |
|||
for (auto& i: v.get_obj()) |
|||
{ |
|||
cnote << i.first; |
|||
js::mObject& o = i.second.get_obj(); |
|||
vector<pair<string, string>> ss; |
|||
for (auto i: o["in"].get_obj()) |
|||
{ |
|||
ss.push_back(make_pair(i.first, i.second.get_str())); |
|||
if (!ss.back().first.find("0x")) |
|||
ss.back().first = asString(fromHex(ss.back().first.substr(2))); |
|||
if (!ss.back().second.find("0x")) |
|||
ss.back().second = asString(fromHex(ss.back().second.substr(2))); |
|||
} |
|||
for (unsigned j = 0; j < min(1000000000u, dev::test::fac((unsigned)ss.size())); ++j) |
|||
{ |
|||
next_permutation(ss.begin(), ss.end()); |
|||
MemoryDB m; |
|||
GenericTrieDB<MemoryDB> t(&m); |
|||
MemoryDB hm; |
|||
HashedGenericTrieDB<MemoryDB> ht(&hm); |
|||
MemoryDB fm; |
|||
FatGenericTrieDB<MemoryDB> ft(&fm); |
|||
t.init(); |
|||
ht.init(); |
|||
ft.init(); |
|||
BOOST_REQUIRE(t.check(true)); |
|||
BOOST_REQUIRE(ht.check(true)); |
|||
BOOST_REQUIRE(ft.check(true)); |
|||
for (auto const& k: ss) |
|||
{ |
|||
t.insert(k.first, k.second); |
|||
ht.insert(k.first, k.second); |
|||
ft.insert(k.first, k.second); |
|||
BOOST_REQUIRE(t.check(true)); |
|||
BOOST_REQUIRE(ht.check(true)); |
|||
BOOST_REQUIRE(ft.check(true)); |
|||
for (auto i = ft.begin(), j = t.begin(); i != ft.end() && j != t.end(); ++i, ++j) |
|||
{ |
|||
BOOST_CHECK_EQUAL(i == ft.end(), j == t.end()); |
|||
BOOST_REQUIRE((*i).first.toBytes() == (*j).first.toBytes()); |
|||
BOOST_REQUIRE((*i).second.toBytes() == (*j).second.toBytes()); |
|||
} |
|||
BOOST_CHECK_EQUAL(ht.root(), ft.root()); |
|||
} |
|||
BOOST_REQUIRE(!o["root"].is_null()); |
|||
BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ht.root().asArray())); |
|||
BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ft.root().asArray())); |
|||
} |
|||
} |
|||
} |
|||
|
|||
BOOST_AUTO_TEST_CASE(trie_test_anyorder) |
|||
{ |
|||
string testPath = test::getTestPath(); |
|||
|
|||
testPath += "/TrieTests"; |
|||
|
|||
cnote << "Testing Trie..."; |
|||
js::mValue v; |
|||
string s = asString(contents(testPath + "/trieanyorder.json")); |
|||
BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'trieanyorder.json' is empty. Have you cloned the 'tests' repo branch develop?"); |
|||
js::read_string(s, v); |
|||
for (auto& i: v.get_obj()) |
|||
{ |
|||
cnote << i.first; |
|||
js::mObject& o = i.second.get_obj(); |
|||
vector<pair<string, string>> ss; |
|||
for (auto i: o["in"].get_obj()) |
|||
{ |
|||
ss.push_back(make_pair(i.first, i.second.get_str())); |
|||
if (!ss.back().first.find("0x")) |
|||
ss.back().first = asString(fromHex(ss.back().first.substr(2))); |
|||
if (!ss.back().second.find("0x")) |
|||
ss.back().second = asString(fromHex(ss.back().second.substr(2))); |
|||
} |
|||
for (unsigned j = 0; j < min(1000u, dev::test::fac((unsigned)ss.size())); ++j) |
|||
{ |
|||
next_permutation(ss.begin(), ss.end()); |
|||
MemoryDB m; |
|||
GenericTrieDB<MemoryDB> t(&m); |
|||
MemoryDB hm; |
|||
HashedGenericTrieDB<MemoryDB> ht(&hm); |
|||
MemoryDB fm; |
|||
FatGenericTrieDB<MemoryDB> ft(&fm); |
|||
t.init(); |
|||
ht.init(); |
|||
ft.init(); |
|||
BOOST_REQUIRE(t.check(true)); |
|||
BOOST_REQUIRE(ht.check(true)); |
|||
BOOST_REQUIRE(ft.check(true)); |
|||
for (auto const& k: ss) |
|||
{ |
|||
t.insert(k.first, k.second); |
|||
ht.insert(k.first, k.second); |
|||
ft.insert(k.first, k.second); |
|||
BOOST_REQUIRE(t.check(true)); |
|||
BOOST_REQUIRE(ht.check(true)); |
|||
BOOST_REQUIRE(ft.check(true)); |
|||
for (auto i = ft.begin(), j = t.begin(); i != ft.end() && j != t.end(); ++i, ++j) |
|||
{ |
|||
BOOST_CHECK_EQUAL(i == ft.end(), j == t.end()); |
|||
BOOST_REQUIRE((*i).first.toBytes() == (*j).first.toBytes()); |
|||
BOOST_REQUIRE((*i).second.toBytes() == (*j).second.toBytes()); |
|||
} |
|||
BOOST_CHECK_EQUAL(ht.root(), ft.root()); |
|||
} |
|||
BOOST_REQUIRE(!o["root"].is_null()); |
|||
BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(t.root().asArray())); |
|||
BOOST_CHECK_EQUAL(ht.root(), ft.root()); |
|||
} |
|||
} |
|||
} |
|||
|
|||
BOOST_AUTO_TEST_CASE(trie_tests_ordered) |
|||
{ |
|||
string testPath = test::getTestPath(); |
|||
|
|||
testPath += "/TrieTests"; |
|||
|
|||
cnote << "Testing Trie..."; |
|||
js::mValue v; |
|||
string s = asString(contents(testPath + "/trietest.json")); |
|||
BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'trietest.json' is empty. Have you cloned the 'tests' repo branch develop?"); |
|||
js::read_string(s, v); |
|||
|
|||
for (auto& i: v.get_obj()) |
|||
{ |
|||
cnote << i.first; |
|||
js::mObject& o = i.second.get_obj(); |
|||
vector<pair<string, string>> ss; |
|||
vector<string> keysToBeDeleted; |
|||
for (auto& i: o["in"].get_array()) |
|||
{ |
|||
vector<string> values; |
|||
for (auto& s: i.get_array()) |
|||
{ |
|||
if (s.type() == json_spirit::str_type) |
|||
values.push_back(s.get_str()); |
|||
else if (s.type() == json_spirit::null_type) |
|||
{ |
|||
// mark entry for deletion
|
|||
values.push_back(""); |
|||
if (!values[0].find("0x")) |
|||
values[0] = asString(fromHex(values[0].substr(2))); |
|||
keysToBeDeleted.push_back(values[0]); |
|||
} |
|||
else |
|||
BOOST_FAIL("Bad type (expected string)"); |
|||
} |
|||
|
|||
BOOST_REQUIRE(values.size() == 2); |
|||
ss.push_back(make_pair(values[0], values[1])); |
|||
if (!ss.back().first.find("0x")) |
|||
ss.back().first = asString(fromHex(ss.back().first.substr(2))); |
|||
if (!ss.back().second.find("0x")) |
|||
ss.back().second = asString(fromHex(ss.back().second.substr(2))); |
|||
} |
|||
|
|||
MemoryDB m; |
|||
GenericTrieDB<MemoryDB> t(&m); |
|||
MemoryDB hm; |
|||
HashedGenericTrieDB<MemoryDB> ht(&hm); |
|||
MemoryDB fm; |
|||
FatGenericTrieDB<MemoryDB> ft(&fm); |
|||
t.init(); |
|||
ht.init(); |
|||
ft.init(); |
|||
BOOST_REQUIRE(t.check(true)); |
|||
BOOST_REQUIRE(ht.check(true)); |
|||
BOOST_REQUIRE(ft.check(true)); |
|||
|
|||
for (auto const& k: ss) |
|||
{ |
|||
if (find(keysToBeDeleted.begin(), keysToBeDeleted.end(), k.first) != keysToBeDeleted.end() && k.second.empty()) |
|||
t.remove(k.first), ht.remove(k.first), ft.remove(k.first); |
|||
else |
|||
t.insert(k.first, k.second), ht.insert(k.first, k.second), ft.insert(k.first, k.second); |
|||
BOOST_REQUIRE(t.check(true)); |
|||
BOOST_REQUIRE(ht.check(true)); |
|||
BOOST_REQUIRE(ft.check(true)); |
|||
for (auto i = ft.begin(), j = t.begin(); i != ft.end() && j != t.end(); ++i, ++j) |
|||
{ |
|||
BOOST_CHECK_EQUAL(i == ft.end(), j == t.end()); |
|||
BOOST_REQUIRE((*i).first.toBytes() == (*j).first.toBytes()); |
|||
BOOST_REQUIRE((*i).second.toBytes() == (*j).second.toBytes()); |
|||
} |
|||
BOOST_CHECK_EQUAL(ht.root(), ft.root()); |
|||
} |
|||
|
|||
BOOST_REQUIRE(!o["root"].is_null()); |
|||
BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(t.root().asArray())); |
|||
} |
|||
} |
|||
|
|||
inline h256 stringMapHash256(StringMap const& _s) |
|||
{ |
|||
return hash256(_s); |
|||
} |
|||
|
|||
BOOST_AUTO_TEST_CASE(moreTrieTests) |
|||
{ |
|||
cnote << "Testing Trie more..."; |
|||
#if 0 |
|||
// More tests...
|
|||
{ |
|||
MemoryDB m; |
|||
GenericTrieDB<MemoryDB> t(&m); |
|||
t.init(); // initialise as empty tree.
|
|||
cout << t; |
|||
cout << m; |
|||
cout << t.root() << endl; |
|||
cout << hash256(StringMap()) << endl; |
|||
|
|||
t.insert(string("tesz"), string("test")); |
|||
cout << t; |
|||
cout << m; |
|||
cout << t.root() << endl; |
|||
cout << stringMapHash256({{"test", "test"}}) << endl; |
|||
|
|||
t.insert(string("tesa"), string("testy")); |
|||
cout << t; |
|||
cout << m; |
|||
cout << t.root() << endl; |
|||
cout << stringMapHash256({{"test", "test"}, {"te", "testy"}}) << endl; |
|||
cout << t.at(string("test")) << endl; |
|||
cout << t.at(string("te")) << endl; |
|||
cout << t.at(string("t")) << endl; |
|||
|
|||
t.remove(string("te")); |
|||
cout << m; |
|||
cout << t.root() << endl; |
|||
cout << stringMapHash256({{"test", "test"}}) << endl; |
|||
|
|||
t.remove(string("test")); |
|||
cout << m; |
|||
cout << t.root() << endl; |
|||
cout << hash256(StringMap()) << endl; |
|||
} |
|||
{ |
|||
MemoryDB m; |
|||
GenericTrieDB<MemoryDB> t(&m); |
|||
t.init(); // initialise as empty tree.
|
|||
t.insert(string("a"), string("A")); |
|||
t.insert(string("b"), string("B")); |
|||
cout << t; |
|||
cout << m; |
|||
cout << t.root() << endl; |
|||
cout << stringMapHash256({{"b", "B"}, {"a", "A"}}) << endl; |
|||
cout << RLP(rlp256({{"b", "B"}, {"a", "A"}})) << endl; |
|||
} |
|||
{ |
|||
MemTrie t; |
|||
t.insert("dog", "puppy"); |
|||
cout << hex << t.hash256() << endl; |
|||
cout << RLP(t.rlp()) << endl; |
|||
} |
|||
{ |
|||
MemTrie t; |
|||
t.insert("bed", "d"); |
|||
t.insert("be", "e"); |
|||
cout << hex << t.hash256() << endl; |
|||
cout << RLP(t.rlp()) << endl; |
|||
} |
|||
{ |
|||
cout << hex << stringMapHash256({{"dog", "puppy"}, {"doe", "reindeer"}}) << endl; |
|||
MemTrie t; |
|||
t.insert("dog", "puppy"); |
|||
t.insert("doe", "reindeer"); |
|||
cout << hex << t.hash256() << endl; |
|||
cout << RLP(t.rlp()) << endl; |
|||
cout << toHex(t.rlp()) << endl; |
|||
} |
|||
#endif |
|||
{ |
|||
MemoryDB m; |
|||
GenericTrieDB<MemoryDB> d(&m); |
|||
d.init(); // initialise as empty tree.
|
|||
MemTrie t; |
|||
StringMap s; |
|||
|
|||
auto add = [&](char const* a, char const* b) |
|||
{ |
|||
d.insert(string(a), string(b)); |
|||
t.insert(a, b); |
|||
s[a] = b; |
|||
|
|||
/*cout << endl << "-------------------------------" << endl;
|
|||
cout << a << " -> " << b << endl; |
|||
cout << d; |
|||
cout << m; |
|||
cout << d.root() << endl; |
|||
cout << hash256(s) << endl;*/ |
|||
|
|||
BOOST_REQUIRE(d.check(true)); |
|||
BOOST_REQUIRE_EQUAL(t.hash256(), hash256(s)); |
|||
BOOST_REQUIRE_EQUAL(d.root(), hash256(s)); |
|||
for (auto const& i: s) |
|||
{ |
|||
(void)i; |
|||
BOOST_REQUIRE_EQUAL(t.at(i.first), i.second); |
|||
BOOST_REQUIRE_EQUAL(d.at(i.first), i.second); |
|||
} |
|||
}; |
|||
|
|||
auto remove = [&](char const* a) |
|||
{ |
|||
s.erase(a); |
|||
t.remove(a); |
|||
d.remove(string(a)); |
|||
|
|||
/*cout << endl << "-------------------------------" << endl;
|
|||
cout << "X " << a << endl; |
|||
cout << d; |
|||
cout << m; |
|||
cout << d.root() << endl; |
|||
cout << hash256(s) << endl;*/ |
|||
|
|||
BOOST_REQUIRE(d.check(true)); |
|||
BOOST_REQUIRE(t.at(a).empty()); |
|||
BOOST_REQUIRE(d.at(string(a)).empty()); |
|||
BOOST_REQUIRE_EQUAL(t.hash256(), hash256(s)); |
|||
BOOST_REQUIRE_EQUAL(d.root(), hash256(s)); |
|||
for (auto const& i: s) |
|||
{ |
|||
(void)i; |
|||
BOOST_REQUIRE_EQUAL(t.at(i.first), i.second); |
|||
BOOST_REQUIRE_EQUAL(d.at(i.first), i.second); |
|||
} |
|||
}; |
|||
|
|||
add("dogglesworth", "cat"); |
|||
add("doe", "reindeer"); |
|||
remove("dogglesworth"); |
|||
add("horse", "stallion"); |
|||
add("do", "verb"); |
|||
add("doge", "coin"); |
|||
remove("horse"); |
|||
remove("do"); |
|||
remove("doge"); |
|||
remove("doe"); |
|||
} |
|||
} |
|||
|
|||
BOOST_AUTO_TEST_CASE(trieLowerBound) |
|||
{ |
|||
cnote << "Stress-testing Trie.lower_bound..."; |
|||
if (0) |
|||
{ |
|||
MemoryDB dm; |
|||
EnforceRefs e(dm, true); |
|||
GenericTrieDB<MemoryDB> d(&dm); |
|||
d.init(); // initialise as empty tree.
|
|||
for (int a = 0; a < 20; ++a) |
|||
{ |
|||
StringMap m; |
|||
for (int i = 0; i < 50; ++i) |
|||
{ |
|||
auto k = randomWord(); |
|||
auto v = toString(i); |
|||
m[k] = v; |
|||
d.insert(k, v); |
|||
} |
|||
|
|||
for (auto i: d) |
|||
{ |
|||
auto it = d.lower_bound(i.first); |
|||
for (auto iit = d.begin(); iit != d.end(); ++iit) |
|||
if ((*iit).first.toString() >= i.first.toString()) |
|||
{ |
|||
BOOST_REQUIRE(it == iit); |
|||
break; |
|||
} |
|||
} |
|||
for (unsigned i = 0; i < 100; ++i) |
|||
{ |
|||
auto k = randomWord(); |
|||
auto it = d.lower_bound(k); |
|||
for (auto iit = d.begin(); iit != d.end(); ++iit) |
|||
if ((*iit).first.toString() >= k) |
|||
{ |
|||
BOOST_REQUIRE(it == iit); |
|||
break; |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
|
|||
BOOST_AUTO_TEST_CASE(trieStess) |
|||
{ |
|||
cnote << "Stress-testing Trie..."; |
|||
if (0) |
|||
{ |
|||
MemoryDB m; |
|||
MemoryDB dm; |
|||
EnforceRefs e(dm, true); |
|||
GenericTrieDB<MemoryDB> d(&dm); |
|||
d.init(); // initialise as empty tree.
|
|||
MemTrie t; |
|||
BOOST_REQUIRE(d.check(true)); |
|||
for (int a = 0; a < 20; ++a) |
|||
{ |
|||
StringMap m; |
|||
for (int i = 0; i < 50; ++i) |
|||
{ |
|||
auto k = randomWord(); |
|||
auto v = toString(i); |
|||
m[k] = v; |
|||
t.insert(k, v); |
|||
d.insert(k, v); |
|||
BOOST_REQUIRE_EQUAL(hash256(m), t.hash256()); |
|||
BOOST_REQUIRE_EQUAL(hash256(m), d.root()); |
|||
BOOST_REQUIRE(d.check(true)); |
|||
} |
|||
while (!m.empty()) |
|||
{ |
|||
auto k = m.begin()->first; |
|||
auto v = m.begin()->second; |
|||
d.remove(k); |
|||
t.remove(k); |
|||
m.erase(k); |
|||
if (!d.check(true)) |
|||
{ |
|||
// cwarn << m;
|
|||
for (auto i: d) |
|||
cwarn << i.first.toString() << i.second.toString(); |
|||
|
|||
MemoryDB dm2; |
|||
EnforceRefs e2(dm2, true); |
|||
GenericTrieDB<MemoryDB> d2(&dm2); |
|||
d2.init(); // initialise as empty tree.
|
|||
for (auto i: d) |
|||
d2.insert(i.first, i.second); |
|||
|
|||
cwarn << "Good:" << d2.root(); |
|||
// for (auto i: dm2.get())
|
|||
// cwarn << i.first.abridged() << ": " << RLP(i.second);
|
|||
d2.debugStructure(cerr); |
|||
cwarn << "Broken:" << d.root(); // Leaves an extension -> extension (3c1... -> 742...)
|
|||
// for (auto i: dm.get())
|
|||
// cwarn << i.first.abridged() << ": " << RLP(i.second);
|
|||
d.debugStructure(cerr); |
|||
|
|||
d2.insert(k, v); |
|||
cwarn << "Pres:" << d2.root(); |
|||
// for (auto i: dm2.get())
|
|||
// cwarn << i.first.abridged() << ": " << RLP(i.second);
|
|||
d2.debugStructure(cerr); |
|||
g_logVerbosity = 99; |
|||
d2.remove(k); |
|||
g_logVerbosity = 4; |
|||
|
|||
cwarn << "Good?" << d2.root(); |
|||
} |
|||
BOOST_REQUIRE(d.check(true)); |
|||
BOOST_REQUIRE_EQUAL(hash256(m), t.hash256()); |
|||
BOOST_REQUIRE_EQUAL(hash256(m), d.root()); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
BOOST_AUTO_TEST_SUITE_END() |
|||
|
|||
|
@ -0,0 +1,5 @@ |
|||
cmake_policy(SET CMP0015 NEW) |
|||
|
|||
aux_source_directory(. SRCS) |
|||
|
|||
add_sources(${SRCS}) |
@ -0,0 +1,5 @@ |
|||
cmake_policy(SET CMP0015 NEW) |
|||
|
|||
aux_source_directory(. SRCS) |
|||
|
|||
add_sources(${SRCS}) |
@ -0,0 +1,5 @@ |
|||
cmake_policy(SET CMP0015 NEW) |
|||
|
|||
aux_source_directory(. SRCS) |
|||
|
|||
add_sources(${SRCS}) |
@ -0,0 +1,5 @@ |
|||
cmake_policy(SET CMP0015 NEW) |
|||
|
|||
aux_source_directory(. SRCS) |
|||
|
|||
add_sources(${SRCS}) |
@ -0,0 +1,5 @@ |
|||
cmake_policy(SET CMP0015 NEW) |
|||
|
|||
aux_source_directory(. SRCS) |
|||
|
|||
add_sources(${SRCS}) |
@ -0,0 +1,5 @@ |
|||
cmake_policy(SET CMP0015 NEW) |
|||
|
|||
aux_source_directory(. SRCS) |
|||
|
|||
add_sources(${SRCS}) |
@ -0,0 +1,372 @@ |
|||
/*
|
|||
This file is part of cpp-ethereum. |
|||
|
|||
cpp-ethereum is free software: you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation, either version 3 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
cpp-ethereum is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License |
|||
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
/** @file net.cpp
|
|||
* @author Alex Leverington <nessence@gmail.com> |
|||
* @date 2014 |
|||
*/ |
|||
|
|||
#include <boost/test/unit_test.hpp> |
|||
|
|||
#include <libdevcore/Worker.h> |
|||
#include <libdevcore/Assertions.h> |
|||
#include <libdevcrypto/Common.h> |
|||
#include <libp2p/UDP.h> |
|||
#include <libp2p/NodeTable.h> |
|||
using namespace std; |
|||
using namespace dev; |
|||
using namespace dev::p2p; |
|||
namespace ba = boost::asio; |
|||
namespace bi = ba::ip; |
|||
|
|||
struct NetFixture |
|||
{ |
|||
NetFixture() { dev::p2p::NodeIPEndpoint::test_allowLocal = true; } |
|||
~NetFixture() { dev::p2p::NodeIPEndpoint::test_allowLocal = false; } |
|||
}; |
|||
|
|||
BOOST_FIXTURE_TEST_SUITE(net, NetFixture) |
|||
|
|||
/**
|
|||
* Only used for testing. Not useful beyond tests. |
|||
*/ |
|||
class TestHost: public Worker |
|||
{ |
|||
public: |
|||
TestHost(): Worker("test",0), m_io() {}; |
|||
virtual ~TestHost() { m_io.stop(); stopWorking(); } |
|||
void start() { startWorking(); } |
|||
void doWork() { m_io.run(); } |
|||
void doneWorking() { m_io.reset(); m_io.poll(); m_io.reset(); } |
|||
|
|||
protected: |
|||
ba::io_service m_io; |
|||
}; |
|||
|
|||
struct TestNodeTable: public NodeTable |
|||
{ |
|||
/// Constructor
|
|||
TestNodeTable(ba::io_service& _io, KeyPair _alias, bi::address const& _addr, uint16_t _port = 30300): NodeTable(_io, _alias, NodeIPEndpoint(_addr, _port, _port)) {} |
|||
|
|||
static std::vector<std::pair<KeyPair,unsigned>> createTestNodes(unsigned _count) |
|||
{ |
|||
std::vector<std::pair<KeyPair,unsigned>> ret; |
|||
asserts(_count < 1000); |
|||
static uint16_t s_basePort = 30500; |
|||
|
|||
ret.clear(); |
|||
for (unsigned i = 0; i < _count; i++) |
|||
{ |
|||
KeyPair k = KeyPair::create(); |
|||
ret.push_back(make_pair(k,s_basePort+i)); |
|||
} |
|||
|
|||
return std::move(ret); |
|||
} |
|||
|
|||
void pingTestNodes(std::vector<std::pair<KeyPair,unsigned>> const& _testNodes) |
|||
{ |
|||
bi::address ourIp = bi::address::from_string("127.0.0.1"); |
|||
for (auto& n: _testNodes) |
|||
{ |
|||
ping(bi::udp::endpoint(ourIp, n.second)); |
|||
this_thread::sleep_for(chrono::milliseconds(2)); |
|||
} |
|||
} |
|||
|
|||
void populateTestNodes(std::vector<std::pair<KeyPair,unsigned>> const& _testNodes, size_t _count = 0) |
|||
{ |
|||
if (!_count) |
|||
_count = _testNodes.size(); |
|||
|
|||
bi::address ourIp = bi::address::from_string("127.0.0.1"); |
|||
for (auto& n: _testNodes) |
|||
if (_count--) |
|||
{ |
|||
// manually add node for test
|
|||
{ |
|||
Guard ln(x_nodes); |
|||
shared_ptr<NodeEntry> node(new NodeEntry(m_node, n.first.pub(), NodeIPEndpoint(ourIp, n.second, n.second))); |
|||
node->pending = false; |
|||
m_nodes[node->id] = node; |
|||
} |
|||
noteActiveNode(n.first.pub(), bi::udp::endpoint(ourIp, n.second)); |
|||
} |
|||
else |
|||
break; |
|||
} |
|||
|
|||
void reset() |
|||
{ |
|||
Guard l(x_state); |
|||
for (auto& n: m_state) n.nodes.clear(); |
|||
} |
|||
}; |
|||
|
|||
/**
|
|||
* Only used for testing. Not useful beyond tests. |
|||
*/ |
|||
struct TestNodeTableHost: public TestHost |
|||
{ |
|||
TestNodeTableHost(unsigned _count = 8): m_alias(KeyPair::create()), nodeTable(new TestNodeTable(m_io, m_alias, bi::address::from_string("127.0.0.1"))), testNodes(TestNodeTable::createTestNodes(_count)) {}; |
|||
~TestNodeTableHost() { m_io.stop(); stopWorking(); } |
|||
|
|||
void setup() { for (auto n: testNodes) nodeTables.push_back(make_shared<TestNodeTable>(m_io,n.first, bi::address::from_string("127.0.0.1"),n.second)); } |
|||
|
|||
void pingAll() { for (auto& t: nodeTables) t->pingTestNodes(testNodes); } |
|||
|
|||
void populateAll(size_t _count = 0) { for (auto& t: nodeTables) t->populateTestNodes(testNodes, _count); } |
|||
|
|||
void populate(size_t _count = 0) { nodeTable->populateTestNodes(testNodes, _count); } |
|||
|
|||
KeyPair m_alias; |
|||
shared_ptr<TestNodeTable> nodeTable; |
|||
std::vector<std::pair<KeyPair,unsigned>> testNodes; // keypair and port
|
|||
std::vector<shared_ptr<TestNodeTable>> nodeTables; |
|||
}; |
|||
|
|||
class TestUDPSocket: UDPSocketEvents, public TestHost |
|||
{ |
|||
public: |
|||
TestUDPSocket(): m_socket(new UDPSocket<TestUDPSocket, 1024>(m_io, *this, 30300)) {} |
|||
|
|||
void onDisconnected(UDPSocketFace*) {}; |
|||
void onReceived(UDPSocketFace*, bi::udp::endpoint const&, bytesConstRef _packet) { if (_packet.toString() == "AAAA") success = true; } |
|||
|
|||
shared_ptr<UDPSocket<TestUDPSocket, 1024>> m_socket; |
|||
|
|||
bool success = false; |
|||
}; |
|||
|
|||
BOOST_AUTO_TEST_CASE(requestTimeout) |
|||
{ |
|||
using TimePoint = std::chrono::steady_clock::time_point; |
|||
using RequestTimeout = std::pair<NodeId, TimePoint>; |
|||
|
|||
std::chrono::milliseconds timeout(300); |
|||
std::list<RequestTimeout> timeouts; |
|||
|
|||
NodeId nodeA(sha3("a")); |
|||
NodeId nodeB(sha3("b")); |
|||
timeouts.push_back(make_pair(nodeA, chrono::steady_clock::now())); |
|||
this_thread::sleep_for(std::chrono::milliseconds(100)); |
|||
timeouts.push_back(make_pair(nodeB, chrono::steady_clock::now())); |
|||
this_thread::sleep_for(std::chrono::milliseconds(210)); |
|||
|
|||
bool nodeAtriggered = false; |
|||
bool nodeBtriggered = false; |
|||
timeouts.remove_if([&](RequestTimeout const& t) |
|||
{ |
|||
auto now = chrono::steady_clock::now(); |
|||
auto diff = now - t.second; |
|||
if (t.first == nodeA && diff < timeout) |
|||
nodeAtriggered = true; |
|||
if (t.first == nodeB && diff < timeout) |
|||
nodeBtriggered = true; |
|||
return (t.first == nodeA || t.first == nodeB); |
|||
}); |
|||
|
|||
BOOST_REQUIRE(nodeAtriggered == false); |
|||
BOOST_REQUIRE(nodeBtriggered == true); |
|||
BOOST_REQUIRE(timeouts.size() == 0); |
|||
} |
|||
|
|||
BOOST_AUTO_TEST_CASE(isIPAddressType) |
|||
{ |
|||
string wildcard = "0.0.0.0"; |
|||
BOOST_REQUIRE(bi::address::from_string(wildcard).is_unspecified()); |
|||
|
|||
string empty = ""; |
|||
BOOST_REQUIRE_THROW(bi::address::from_string(empty).is_unspecified(), std::exception); |
|||
|
|||
string publicAddress192 = "192.169.0.0"; |
|||
BOOST_REQUIRE(isPublicAddress(publicAddress192)); |
|||
BOOST_REQUIRE(!isPrivateAddress(publicAddress192)); |
|||
BOOST_REQUIRE(!isLocalHostAddress(publicAddress192)); |
|||
|
|||
string publicAddress172 = "172.32.0.0"; |
|||
BOOST_REQUIRE(isPublicAddress(publicAddress172)); |
|||
BOOST_REQUIRE(!isPrivateAddress(publicAddress172)); |
|||
BOOST_REQUIRE(!isLocalHostAddress(publicAddress172)); |
|||
|
|||
string privateAddress192 = "192.168.1.0"; |
|||
BOOST_REQUIRE(isPrivateAddress(privateAddress192)); |
|||
BOOST_REQUIRE(!isPublicAddress(privateAddress192)); |
|||
BOOST_REQUIRE(!isLocalHostAddress(privateAddress192)); |
|||
|
|||
string privateAddress172 = "172.16.0.0"; |
|||
BOOST_REQUIRE(isPrivateAddress(privateAddress172)); |
|||
BOOST_REQUIRE(!isPublicAddress(privateAddress172)); |
|||
BOOST_REQUIRE(!isLocalHostAddress(privateAddress172)); |
|||
|
|||
string privateAddress10 = "10.0.0.0"; |
|||
BOOST_REQUIRE(isPrivateAddress(privateAddress10)); |
|||
BOOST_REQUIRE(!isPublicAddress(privateAddress10)); |
|||
BOOST_REQUIRE(!isLocalHostAddress(privateAddress10)); |
|||
} |
|||
|
|||
BOOST_AUTO_TEST_CASE(v2PingNodePacket) |
|||
{ |
|||
// test old versino of pingNode packet w/new
|
|||
RLPStream s; |
|||
s.appendList(3); s << "1.1.1.1" << 30303 << std::chrono::duration_cast<std::chrono::seconds>((std::chrono::system_clock::now() + chrono::seconds(60)).time_since_epoch()).count(); |
|||
|
|||
PingNode p((bi::udp::endpoint())); |
|||
BOOST_REQUIRE_NO_THROW(p = PingNode::fromBytesConstRef(bi::udp::endpoint(), bytesConstRef(&s.out()))); |
|||
BOOST_REQUIRE(p.version == 2); |
|||
} |
|||
|
|||
BOOST_AUTO_TEST_CASE(neighboursPacketLength) |
|||
{ |
|||
KeyPair k = KeyPair::create(); |
|||
std::vector<std::pair<KeyPair,unsigned>> testNodes(TestNodeTable::createTestNodes(16)); |
|||
bi::udp::endpoint to(boost::asio::ip::address::from_string("127.0.0.1"), 30000); |
|||
|
|||
// hash(32), signature(65), overhead: packet(2), type(1), nodeList(2), ts(9),
|
|||
static unsigned const nlimit = (1280 - 111) / 87; |
|||
for (unsigned offset = 0; offset < testNodes.size(); offset += nlimit) |
|||
{ |
|||
Neighbours out(to); |
|||
|
|||
auto limit = nlimit ? std::min(testNodes.size(), (size_t)(offset + nlimit)) : testNodes.size(); |
|||
for (auto i = offset; i < limit; i++) |
|||
{ |
|||
Neighbours::Node node; |
|||
node.ipAddress = boost::asio::ip::address::from_string("200.200.200.200").to_string(); |
|||
node.udpPort = testNodes[i].second; |
|||
node.node = testNodes[i].first.pub(); |
|||
out.nodes.push_back(node); |
|||
} |
|||
|
|||
out.sign(k.sec()); |
|||
BOOST_REQUIRE_LE(out.data.size(), 1280); |
|||
} |
|||
} |
|||
|
|||
BOOST_AUTO_TEST_CASE(test_neighbours_packet) |
|||
{ |
|||
KeyPair k = KeyPair::create(); |
|||
std::vector<std::pair<KeyPair,unsigned>> testNodes(TestNodeTable::createTestNodes(16)); |
|||
bi::udp::endpoint to(boost::asio::ip::address::from_string("127.0.0.1"), 30000); |
|||
|
|||
Neighbours out(to); |
|||
for (auto n: testNodes) |
|||
{ |
|||
Neighbours::Node node; |
|||
node.ipAddress = boost::asio::ip::address::from_string("127.0.0.1").to_string(); |
|||
node.udpPort = n.second; |
|||
node.node = n.first.pub(); |
|||
out.nodes.push_back(node); |
|||
} |
|||
out.sign(k.sec()); |
|||
|
|||
bytesConstRef packet(out.data.data(), out.data.size()); |
|||
bytesConstRef rlpBytes(packet.cropped(h256::size + Signature::size + 1)); |
|||
Neighbours in = Neighbours::fromBytesConstRef(to, rlpBytes); |
|||
int count = 0; |
|||
for (auto n: in.nodes) |
|||
{ |
|||
BOOST_REQUIRE_EQUAL(testNodes[count].second, n.udpPort); |
|||
BOOST_REQUIRE_EQUAL(testNodes[count].first.pub(), n.node); |
|||
BOOST_REQUIRE_EQUAL(sha3(testNodes[count].first.pub()), sha3(n.node)); |
|||
count++; |
|||
} |
|||
} |
|||
|
|||
BOOST_AUTO_TEST_CASE(test_findnode_neighbours) |
|||
{ |
|||
// Executing findNode should result in a list which is serialized
|
|||
// into Neighbours packet. Neighbours packet should then be deserialized
|
|||
// into the same list of nearest nodes.
|
|||
} |
|||
|
|||
BOOST_AUTO_TEST_CASE(test_windows_template) |
|||
{ |
|||
bi::udp::endpoint ep; |
|||
PingNode p(ep); |
|||
} |
|||
|
|||
BOOST_AUTO_TEST_CASE(kademlia) |
|||
{ |
|||
// Not yet a 'real' test.
|
|||
TestNodeTableHost node(8); |
|||
node.start(); |
|||
node.nodeTable->discover(); // ideally, joining with empty node table logs warning we can check for
|
|||
node.setup(); |
|||
node.populate(); |
|||
clog << "NodeTable:\n" << *node.nodeTable.get() << endl; |
|||
|
|||
node.populateAll(); |
|||
clog << "NodeTable:\n" << *node.nodeTable.get() << endl; |
|||
|
|||
auto nodes = node.nodeTable->nodes(); |
|||
nodes.sort(); |
|||
|
|||
node.nodeTable->reset(); |
|||
clog << "NodeTable:\n" << *node.nodeTable.get() << endl; |
|||
|
|||
node.populate(1); |
|||
clog << "NodeTable:\n" << *node.nodeTable.get() << endl; |
|||
|
|||
node.nodeTable->discover(); |
|||
this_thread::sleep_for(chrono::milliseconds(2000)); |
|||
clog << "NodeTable:\n" << *node.nodeTable.get() << endl; |
|||
|
|||
BOOST_REQUIRE_EQUAL(node.nodeTable->count(), 8); |
|||
|
|||
auto netNodes = node.nodeTable->nodes(); |
|||
netNodes.sort(); |
|||
|
|||
} |
|||
|
|||
BOOST_AUTO_TEST_CASE(test_udp_once) |
|||
{ |
|||
UDPDatagram d(bi::udp::endpoint(boost::asio::ip::address::from_string("127.0.0.1"), 30300), bytes({65,65,65,65})); |
|||
TestUDPSocket a; a.m_socket->connect(); a.start(); |
|||
a.m_socket->send(d); |
|||
this_thread::sleep_for(chrono::seconds(1)); |
|||
BOOST_REQUIRE_EQUAL(true, a.success); |
|||
} |
|||
|
|||
BOOST_AUTO_TEST_SUITE_END() |
|||
|
|||
BOOST_AUTO_TEST_SUITE(netTypes) |
|||
|
|||
BOOST_AUTO_TEST_CASE(unspecifiedNode) |
|||
{ |
|||
Node n = UnspecifiedNode; |
|||
BOOST_REQUIRE(!n); |
|||
|
|||
Node node(Public(sha3("0")), NodeIPEndpoint(bi::address(), 0, 0)); |
|||
BOOST_REQUIRE(node); |
|||
BOOST_REQUIRE(n != node); |
|||
|
|||
Node nodeEq(Public(sha3("0")), NodeIPEndpoint(bi::address(), 0, 0)); |
|||
BOOST_REQUIRE_EQUAL(node, nodeEq); |
|||
} |
|||
|
|||
BOOST_AUTO_TEST_CASE(nodeTableReturnsUnspecifiedNode) |
|||
{ |
|||
ba::io_service io; |
|||
NodeTable t(io, KeyPair::create(), NodeIPEndpoint(bi::address::from_string("127.0.0.1"), 30303, 30303)); |
|||
if (Node n = t.node(NodeId())) |
|||
BOOST_REQUIRE(false); |
|||
else |
|||
BOOST_REQUIRE(n == UnspecifiedNode); |
|||
} |
|||
|
|||
BOOST_AUTO_TEST_SUITE_END() |
|||
|
@ -0,0 +1,5 @@ |
|||
cmake_policy(SET CMP0015 NEW) |
|||
|
|||
aux_source_directory(. SRCS) |
|||
|
|||
add_sources(${SRCS}) |
@ -0,0 +1,5 @@ |
|||
cmake_policy(SET CMP0015 NEW) |
|||
|
|||
aux_source_directory(. SRCS) |
|||
|
|||
add_sources(${SRCS}) |
@ -0,0 +1,596 @@ |
|||
/**
|
|||
* This file is generated by jsonrpcstub, DO NOT CHANGE IT MANUALLY! |
|||
*/ |
|||
|
|||
#ifndef JSONRPC_CPP_STUB_WEBTHREESTUBCLIENT_H_ |
|||
#define JSONRPC_CPP_STUB_WEBTHREESTUBCLIENT_H_ |
|||
|
|||
#include <jsonrpccpp/client.h> |
|||
|
|||
class WebThreeStubClient : public jsonrpc::Client |
|||
{ |
|||
public: |
|||
WebThreeStubClient(jsonrpc::IClientConnector &conn, jsonrpc::clientVersion_t type = jsonrpc::JSONRPC_CLIENT_V2) : jsonrpc::Client(conn, type) {} |
|||
|
|||
std::string web3_sha3(const std::string& param1) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
Json::Value result = this->CallMethod("web3_sha3",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string web3_clientVersion() throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p = Json::nullValue; |
|||
Json::Value result = this->CallMethod("web3_clientVersion",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string net_version() throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p = Json::nullValue; |
|||
Json::Value result = this->CallMethod("net_version",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string net_peerCount() throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p = Json::nullValue; |
|||
Json::Value result = this->CallMethod("net_peerCount",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
bool net_listening() throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p = Json::nullValue; |
|||
Json::Value result = this->CallMethod("net_listening",p); |
|||
if (result.isBool()) |
|||
return result.asBool(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string eth_protocolVersion() throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p = Json::nullValue; |
|||
Json::Value result = this->CallMethod("eth_protocolVersion",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string eth_hashrate() throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p = Json::nullValue; |
|||
Json::Value result = this->CallMethod("eth_hashrate",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string eth_coinbase() throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p = Json::nullValue; |
|||
Json::Value result = this->CallMethod("eth_coinbase",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
bool eth_mining() throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p = Json::nullValue; |
|||
Json::Value result = this->CallMethod("eth_mining",p); |
|||
if (result.isBool()) |
|||
return result.asBool(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string eth_gasPrice() throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p = Json::nullValue; |
|||
Json::Value result = this->CallMethod("eth_gasPrice",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
Json::Value eth_accounts() throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p = Json::nullValue; |
|||
Json::Value result = this->CallMethod("eth_accounts",p); |
|||
if (result.isArray()) |
|||
return result; |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string eth_blockNumber() throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p = Json::nullValue; |
|||
Json::Value result = this->CallMethod("eth_blockNumber",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string eth_getBalance(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
p.append(param2); |
|||
Json::Value result = this->CallMethod("eth_getBalance",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string eth_getStorageAt(const std::string& param1, const std::string& param2, const std::string& param3) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
p.append(param2); |
|||
p.append(param3); |
|||
Json::Value result = this->CallMethod("eth_getStorageAt",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string eth_getTransactionCount(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
p.append(param2); |
|||
Json::Value result = this->CallMethod("eth_getTransactionCount",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string eth_getBlockTransactionCountByHash(const std::string& param1) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
Json::Value result = this->CallMethod("eth_getBlockTransactionCountByHash",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string eth_getBlockTransactionCountByNumber(const std::string& param1) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
Json::Value result = this->CallMethod("eth_getBlockTransactionCountByNumber",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string eth_getUncleCountByBlockHash(const std::string& param1) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
Json::Value result = this->CallMethod("eth_getUncleCountByBlockHash",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string eth_getUncleCountByBlockNumber(const std::string& param1) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
Json::Value result = this->CallMethod("eth_getUncleCountByBlockNumber",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string eth_getCode(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
p.append(param2); |
|||
Json::Value result = this->CallMethod("eth_getCode",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string eth_sendTransaction(const Json::Value& param1) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
Json::Value result = this->CallMethod("eth_sendTransaction",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string eth_call(const Json::Value& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
p.append(param2); |
|||
Json::Value result = this->CallMethod("eth_call",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
bool eth_flush() throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p = Json::nullValue; |
|||
Json::Value result = this->CallMethod("eth_flush",p); |
|||
if (result.isBool()) |
|||
return result.asBool(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
Json::Value eth_getBlockByHash(const std::string& param1, bool param2) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
p.append(param2); |
|||
Json::Value result = this->CallMethod("eth_getBlockByHash",p); |
|||
if (result.isObject()) |
|||
return result; |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
Json::Value eth_getBlockByNumber(const std::string& param1, bool param2) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
p.append(param2); |
|||
Json::Value result = this->CallMethod("eth_getBlockByNumber",p); |
|||
if (result.isObject()) |
|||
return result; |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
Json::Value eth_getTransactionByHash(const std::string& param1) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
Json::Value result = this->CallMethod("eth_getTransactionByHash",p); |
|||
if (result.isObject()) |
|||
return result; |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
Json::Value eth_getTransactionByBlockHashAndIndex(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
p.append(param2); |
|||
Json::Value result = this->CallMethod("eth_getTransactionByBlockHashAndIndex",p); |
|||
if (result.isObject()) |
|||
return result; |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
Json::Value eth_getTransactionByBlockNumberAndIndex(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
p.append(param2); |
|||
Json::Value result = this->CallMethod("eth_getTransactionByBlockNumberAndIndex",p); |
|||
if (result.isObject()) |
|||
return result; |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
Json::Value eth_getUncleByBlockHashAndIndex(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
p.append(param2); |
|||
Json::Value result = this->CallMethod("eth_getUncleByBlockHashAndIndex",p); |
|||
if (result.isObject()) |
|||
return result; |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
Json::Value eth_getUncleByBlockNumberAndIndex(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
p.append(param2); |
|||
Json::Value result = this->CallMethod("eth_getUncleByBlockNumberAndIndex",p); |
|||
if (result.isObject()) |
|||
return result; |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
Json::Value eth_getCompilers() throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p = Json::nullValue; |
|||
Json::Value result = this->CallMethod("eth_getCompilers",p); |
|||
if (result.isArray()) |
|||
return result; |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string eth_compileLLL(const std::string& param1) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
Json::Value result = this->CallMethod("eth_compileLLL",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string eth_compileSerpent(const std::string& param1) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
Json::Value result = this->CallMethod("eth_compileSerpent",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string eth_compileSolidity(const std::string& param1) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
Json::Value result = this->CallMethod("eth_compileSolidity",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string eth_newFilter(const Json::Value& param1) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
Json::Value result = this->CallMethod("eth_newFilter",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string eth_newBlockFilter(const std::string& param1) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
Json::Value result = this->CallMethod("eth_newBlockFilter",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
bool eth_uninstallFilter(const std::string& param1) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
Json::Value result = this->CallMethod("eth_uninstallFilter",p); |
|||
if (result.isBool()) |
|||
return result.asBool(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
Json::Value eth_getFilterChanges(const std::string& param1) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
Json::Value result = this->CallMethod("eth_getFilterChanges",p); |
|||
if (result.isArray()) |
|||
return result; |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
Json::Value eth_getFilterLogs(const std::string& param1) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
Json::Value result = this->CallMethod("eth_getFilterLogs",p); |
|||
if (result.isArray()) |
|||
return result; |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
Json::Value eth_getLogs(const Json::Value& param1) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
Json::Value result = this->CallMethod("eth_getLogs",p); |
|||
if (result.isArray()) |
|||
return result; |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
Json::Value eth_getWork() throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p = Json::nullValue; |
|||
Json::Value result = this->CallMethod("eth_getWork",p); |
|||
if (result.isArray()) |
|||
return result; |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
bool eth_submitWork(const std::string& param1, const std::string& param2, const std::string& param3) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
p.append(param2); |
|||
p.append(param3); |
|||
Json::Value result = this->CallMethod("eth_submitWork",p); |
|||
if (result.isBool()) |
|||
return result.asBool(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string eth_register(const std::string& param1) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
Json::Value result = this->CallMethod("eth_register",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
bool eth_unregister(const std::string& param1) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
Json::Value result = this->CallMethod("eth_unregister",p); |
|||
if (result.isBool()) |
|||
return result.asBool(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
Json::Value eth_fetchQueuedTransactions(const std::string& param1) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
Json::Value result = this->CallMethod("eth_fetchQueuedTransactions",p); |
|||
if (result.isArray()) |
|||
return result; |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
bool db_put(const std::string& param1, const std::string& param2, const std::string& param3) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
p.append(param2); |
|||
p.append(param3); |
|||
Json::Value result = this->CallMethod("db_put",p); |
|||
if (result.isBool()) |
|||
return result.asBool(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string db_get(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
p.append(param2); |
|||
Json::Value result = this->CallMethod("db_get",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
bool shh_post(const Json::Value& param1) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
Json::Value result = this->CallMethod("shh_post",p); |
|||
if (result.isBool()) |
|||
return result.asBool(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string shh_newIdentity() throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p = Json::nullValue; |
|||
Json::Value result = this->CallMethod("shh_newIdentity",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
bool shh_hasIdentity(const std::string& param1) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
Json::Value result = this->CallMethod("shh_hasIdentity",p); |
|||
if (result.isBool()) |
|||
return result.asBool(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string shh_newGroup(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
p.append(param2); |
|||
Json::Value result = this->CallMethod("shh_newGroup",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string shh_addToGroup(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
p.append(param2); |
|||
Json::Value result = this->CallMethod("shh_addToGroup",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
std::string shh_newFilter(const Json::Value& param1) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
Json::Value result = this->CallMethod("shh_newFilter",p); |
|||
if (result.isString()) |
|||
return result.asString(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
bool shh_uninstallFilter(const std::string& param1) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
Json::Value result = this->CallMethod("shh_uninstallFilter",p); |
|||
if (result.isBool()) |
|||
return result.asBool(); |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
Json::Value shh_getFilterChanges(const std::string& param1) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
Json::Value result = this->CallMethod("shh_getFilterChanges",p); |
|||
if (result.isArray()) |
|||
return result; |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
Json::Value shh_getMessages(const std::string& param1) throw (jsonrpc::JsonRpcException) |
|||
{ |
|||
Json::Value p; |
|||
p.append(param1); |
|||
Json::Value result = this->CallMethod("shh_getMessages",p); |
|||
if (result.isArray()) |
|||
return result; |
|||
else |
|||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); |
|||
} |
|||
}; |
|||
|
|||
#endif //JSONRPC_CPP_STUB_WEBTHREESTUBCLIENT_H_
|
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue