AdminEth.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #pragma once
  2. #include "AdminEthFace.h"
  3. namespace dev
  4. {
  5. namespace eth
  6. {
  7. class Client;
  8. class TrivialGasPricer;
  9. class KeyManager;
  10. }
  11. namespace rpc
  12. {
  13. class SessionManager;
  14. class AdminEth: public AdminEthFace
  15. {
  16. public:
  17. AdminEth(eth::Client& _eth, eth::TrivialGasPricer& _gp, eth::KeyManager& _keyManager, SessionManager& _sm);
  18. virtual RPCModules implementedModules() const override
  19. {
  20. return RPCModules{RPCModule{"admin", "1.0"}, RPCModule{"miner", "1.0"}};
  21. }
  22. virtual bool admin_eth_setMining(bool _on, std::string const& _session) override;
  23. virtual Json::Value admin_eth_blockQueueStatus(std::string const& _session) override;
  24. virtual bool admin_eth_setAskPrice(std::string const& _wei, std::string const& _session) override;
  25. virtual bool admin_eth_setBidPrice(std::string const& _wei, std::string const& _session) override;
  26. virtual Json::Value admin_eth_findBlock(std::string const& _blockHash, std::string const& _session) override;
  27. virtual std::string admin_eth_blockQueueFirstUnknown(std::string const& _session) override;
  28. virtual bool admin_eth_blockQueueRetryUnknown(std::string const& _session) override;
  29. virtual Json::Value admin_eth_allAccounts(std::string const& _session) override;
  30. virtual Json::Value admin_eth_newAccount(const Json::Value& _info, std::string const& _session) override;
  31. virtual bool admin_eth_setMiningBenefactor(std::string const& _uuidOrAddress, std::string const& _session) override;
  32. virtual Json::Value admin_eth_inspect(std::string const& _address, std::string const& _session) override;
  33. virtual Json::Value admin_eth_reprocess(std::string const& _blockNumberOrHash, std::string const& _session) override;
  34. virtual Json::Value admin_eth_vmTrace(std::string const& _blockNumberOrHash, int _txIndex, std::string const& _session) override;
  35. virtual Json::Value admin_eth_getReceiptByHashAndIndex(std::string const& _blockNumberOrHash, int _txIndex, std::string const& _session) override;
  36. virtual bool miner_start(int _threads) override;
  37. virtual bool miner_stop() override;
  38. virtual bool miner_setEtherbase(std::string const& _uuidOrAddress) override;
  39. virtual bool miner_setExtra(std::string const& _extraData) override;
  40. virtual bool miner_setGasPrice(std::string const& _gasPrice) override;
  41. virtual std::string miner_hashrate() override;
  42. virtual void setMiningBenefactorChanger(std::function<void(Address const&)> const& _f) { m_setMiningBenefactor = _f; }
  43. private:
  44. eth::Client& m_eth;
  45. eth::TrivialGasPricer& m_gp;
  46. eth::KeyManager& m_keyManager;
  47. SessionManager& m_sm;
  48. std::function<void(Address const&)> m_setMiningBenefactor;
  49. h256 blockHash(std::string const& _blockNumberOrHash) const;
  50. };
  51. }
  52. }