class Ethereum::HttpClient
Attributes
host[RW]
port[RW]
ssl[RW]
uri[RW]
Public Class Methods
new(host, port, ssl = false, log = false)
click to toggle source
Calls superclass method
# File lib/ethereumex/http_client.rb, line 6 def initialize(host, port, ssl = false, log = false) super(log) @host = host @port = port @ssl = ssl if ssl @uri = URI("https://#{@host}:#{@port}") else @uri = URI("http://#{@host}:#{@port}") end end
Public Instance Methods
send_batch(batch)
click to toggle source
# File lib/ethereumex/http_client.rb, line 30 def send_batch(batch) raise NotImplementedError end
send_single(payload)
click to toggle source
# File lib/ethereumex/http_client.rb, line 18 def send_single(payload) http = ::Net::HTTP.new(@host, @port) if @ssl http.use_ssl = true end header = {'Content-Type' => 'application/json'} request = ::Net::HTTP::Post.new(uri, header) request.body = payload response = http.request(request) return response.body end