class EvmClient::IpcClient
Constants
- IPC_PATHS
Attributes
ipcpath[RW]
Public Class Methods
default_path(paths = IPC_PATHS)
click to toggle source
# File lib/evm_client/ipc_client.rb, line 29 def self.default_path(paths = IPC_PATHS) path = paths.find { |path| File.exist?(path) } path || raise("Ipc file not found. Please pass in the file path explicitly to IpcClient initializer") end
new(ipcpath = nil, log = true)
click to toggle source
Calls superclass method
EvmClient::Client::new
# File lib/evm_client/ipc_client.rb, line 23 def initialize(ipcpath = nil, log = true) super(log) ipcpath ||= IpcClient.default_path @ipcpath = ipcpath end
Public Instance Methods
send_batch(batch)
click to toggle source
Note: Guarantees the results are in the same order as defined in batch call. client.batch do
client.eth_block_number client.eth_mining
end
> [{“jsonrpc”=>“2.0”, “id”=>1, “result”=>“0x26”}, {“jsonrpc”=>“2.0”, “id”=>2, “result”=>false}] ¶ ↑
# File lib/evm_client/ipc_client.rb, line 48 def send_batch(batch) result = send_single(batch.to_json) result = JSON.parse(result) # Make sure the order is the same as it was when batching calls # See 6 Batch here http://www.jsonrpc.org/specification return result.sort_by! { |c| c['id'] } end
send_single(payload)
click to toggle source
# File lib/evm_client/ipc_client.rb, line 34 def send_single(payload) socket = UNIXSocket.new(@ipcpath) socket.puts(payload) read = socket.recvmsg(nil)[0] socket.close return read end