forked from bcosorg/bcos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Eth.h
139 lines (119 loc) · 6.05 KB
/
Eth.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
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 Eth.h
* @authors:
* Gav Wood <i@gavwood.com>
* Marek Kotewicz <marek@ethdev.com>
* @date 2014
*/
#pragma once
#include <memory>
#include <iostream>
#include <jsonrpccpp/server.h>
#include <jsonrpccpp/common/exception.h>
#include <libdevcrypto/Common.h>
#include "SessionManager.h"
#include "EthFace.h"
namespace dev
{
class NetworkFace;
class KeyPair;
namespace eth
{
class AccountHolder;
struct TransactionSkeleton;
class Interface;
}
namespace shh
{
class Interface;
}
extern const unsigned SensibleHttpThreads;
extern const unsigned SensibleHttpPort;
}
namespace dev
{
namespace rpc
{
/**
* @brief JSON-RPC api implementation
*/
class Eth: public dev::rpc::EthFace
{
public:
Eth(eth::Interface& _eth, eth::AccountHolder& _ethAccounts);
virtual RPCModules implementedModules() const override
{
return RPCModules{RPCModule{"eth", "1.0"}};
}
eth::AccountHolder const& ethAccounts() const { return m_ethAccounts; }
virtual std::string eth_protocolVersion() override;
virtual std::string eth_hashrate() override;
virtual std::string eth_coinbase() override;
virtual bool eth_mining() override;
virtual std::string eth_gasPrice() override;
virtual Json::Value eth_accounts() override;
virtual std::string eth_blockNumber()override;
virtual std::string eth_getBalance(std::string const& _address, std::string const& _blockNumber) override;
virtual std::string eth_getStorageAt(std::string const& _address, std::string const& _position, std::string const& _blockNumber) override;
virtual std::string eth_getStorageRoot(std::string const& _address, std::string const& _blockNumber) override;
virtual std::string eth_getTransactionCount(std::string const& _address, std::string const& _blockNumber) override;
virtual std::string eth_pendingTransactions() override;
virtual Json::Value eth_getBlockTransactionCountByHash(std::string const& _blockHash) override;
virtual Json::Value eth_getBlockTransactionCountByNumber(std::string const& _blockNumber) override;
virtual Json::Value eth_getUncleCountByBlockHash(std::string const& _blockHash) override;
virtual Json::Value eth_getUncleCountByBlockNumber(std::string const& _blockNumber) override;
virtual std::string eth_getCode(std::string const& _address, std::string const& _blockNumber) override;
virtual std::string eth_sendTransaction(Json::Value const& _json) override;
virtual std::string eth_call(Json::Value const& _json, std::string const& _blockNumber) override;
virtual std::string eth_estimateGas(Json::Value const& _json) override;
virtual bool eth_flush() override;
virtual Json::Value eth_getBlockByHash(std::string const& _blockHash, bool _includeTransactions) override;
virtual Json::Value eth_getBlockByNumber(std::string const& _blockNumber, bool _includeTransactions) override;
virtual Json::Value eth_getTransactionByHash(std::string const& _transactionHash) override;
virtual Json::Value eth_getTransactionByBlockHashAndIndex(std::string const& _blockHash, std::string const& _transactionIndex) override;
virtual Json::Value eth_getTransactionByBlockNumberAndIndex(std::string const& _blockNumber, std::string const& _transactionIndex) override;
virtual Json::Value eth_getTransactionReceipt(std::string const& _transactionHash) override;
virtual Json::Value eth_getUncleByBlockHashAndIndex(std::string const& _blockHash, std::string const& _uncleIndex) override;
virtual Json::Value eth_getUncleByBlockNumberAndIndex(std::string const& _blockNumber, std::string const& _uncleIndex) override;
virtual std::string eth_newFilter(Json::Value const& _json) override;
virtual std::string eth_newFilterEx(Json::Value const& _json) override;
virtual std::string eth_newBlockFilter() override;
virtual std::string eth_newPendingTransactionFilter() override;
virtual bool eth_uninstallFilter(std::string const& _filterId) override;
virtual Json::Value eth_getFilterChanges(std::string const& _filterId) override;
virtual Json::Value eth_getFilterChangesEx(std::string const& _filterId) override;
virtual Json::Value eth_getFilterLogs(std::string const& _filterId) override;
virtual Json::Value eth_getFilterLogsEx(std::string const& _filterId) override;
virtual Json::Value eth_getLogs(Json::Value const& _json) override;
virtual Json::Value eth_getLogsEx(Json::Value const& _json) override;
virtual Json::Value eth_getWork() override;
virtual bool eth_submitWork(std::string const& _nonce, std::string const&, std::string const& _mixHash) override;
virtual bool eth_submitHashrate(std::string const& _hashes, std::string const& _id) override;
virtual std::string eth_register(std::string const& _address) override;
virtual bool eth_unregister(std::string const& _accountId) override;
virtual Json::Value eth_fetchQueuedTransactions(std::string const& _accountId) override;
virtual std::string eth_signTransaction(Json::Value const& _transaction) override;
virtual Json::Value eth_inspectTransaction(std::string const& _rlp) override;
virtual std::string eth_sendRawTransaction(std::string const& _rlp) override;
virtual bool eth_notePassword(std::string const&) override { return false; }
virtual Json::Value eth_syncing() override;
void setTransactionDefaults(eth::TransactionSkeleton& _t);
protected:
eth::Interface* client() { return &m_eth; }
eth::Interface& m_eth;
eth::AccountHolder& m_ethAccounts;
};
}
} //namespace dev