Class: EPM::Query
- Inherits:
-
Object
- Object
- EPM::Query
- Defined in:
- lib/epm/query.rb
Instance Method Summary collapse
-
#initialize(address, position, settings = {}) ⇒ Query
constructor
A new instance of Query.
- #query ⇒ Object
- #setup(settings) ⇒ Object
Constructor Details
#initialize(address, position, settings = {}) ⇒ Query
Returns a new instance of Query.
5 6 7 8 9 10 |
# File 'lib/epm/query.rb', line 5 def initialize address, position, settings={} @uri = URI.parse "http://localhost:#{settings['json-port']}" setup settings @address = EPM::HexData.hex_guard address @position = EPM::HexData.query_guard position end |
Instance Method Details
#query ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/epm/query.rb', line 12 def query if @settings['preferred-client'] == 'cpp' params = { 'a' => @address, 'x' => @position } post_body = { 'method' => 'storageAt', 'params' => params, 'id' => 'epm-rpc', "jsonrpc" => "2.0" }.to_json elsif @settings['preferred-client'] == ('go' || 'ethereal') params = { 'address' => @address, 'key' => @position } post_body = { 'method' => 'EthereumApi.GetStorageAt', 'params' => params, 'id' => 'epm-rpc', "jsonrpc" => "2.0" }.to_json end return EPM::Server.http_post_request @uri, post_body end |