Class: Meeseeker::SteemEngine::Agent
- Inherits:
-
Mechanize
- Object
- Mechanize
- Meeseeker::SteemEngine::Agent
- Defined in:
- lib/meeseeker/steem_engine/agent.rb
Constant Summary collapse
- POST_HEADERS =
{ 'Content-Type' => 'application/json; charset=utf-8', 'User-Agent' => Meeseeker::AGENT_ID }
Instance Method Summary collapse
- #block(block_num) ⇒ Object
- #blockchain_http_post ⇒ Object
- #blockchain_uri ⇒ Object
-
#initialize(options = {}) ⇒ Agent
constructor
A new instance of Agent.
- #latest_block_info ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Agent
Returns a new instance of Agent.
10 11 12 13 14 15 16 17 18 |
# File 'lib/meeseeker/steem_engine/agent.rb', line 10 def initialize( = {}) super self.user_agent = Meeseeker::AGENT_ID self.max_history = 0 self.default_encoding = 'UTF-8' @node_url = [:url] || Meeseeker::steem_engine_node_url end |
Instance Method Details
#block(block_num) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/meeseeker/steem_engine/agent.rb', line 40 def block(block_num) request_body = { jsonrpc: "2.0", method: :getBlockInfo, params: { blockNumber: block_num }, id: rpc_id }.to_json response = request_with_entity :post, blockchain_uri, request_body, POST_HEADERS JSON[response.body]["result"] end |
#blockchain_http_post ⇒ Object
24 25 26 |
# File 'lib/meeseeker/steem_engine/agent.rb', line 24 def blockchain_http_post @http_post ||= Net::HTTP::Post.new(blockchain_uri.request_uri, POST_HEADERS) end |
#blockchain_uri ⇒ Object
20 21 22 |
# File 'lib/meeseeker/steem_engine/agent.rb', line 20 def blockchain_uri @blockchain_uri ||= URI.parse(@node_url + '/blockchain') end |
#latest_block_info ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/meeseeker/steem_engine/agent.rb', line 28 def latest_block_info request_body = { jsonrpc: "2.0", method: :getLatestBlockInfo, id: rpc_id }.to_json response = request_with_entity :post, blockchain_uri, request_body, POST_HEADERS JSON[response.body]["result"] end |