Class: Ethereum::IpcClient
Constant Summary
Constants inherited from Client
Instance Attribute Summary collapse
-
#batch ⇒ Object
Returns the value of attribute batch.
-
#command ⇒ Object
Returns the value of attribute command.
-
#converted_transactions ⇒ Object
Returns the value of attribute converted_transactions.
-
#id ⇒ Object
Returns the value of attribute id.
-
#ipcpath ⇒ Object
Returns the value of attribute ipcpath.
-
#log ⇒ Object
Returns the value of attribute log.
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
-
#initialize(ipcpath = "#{ENV['HOME']}/.ethereum/geth.ipc", log = true) ⇒ IpcClient
constructor
A new instance of IpcClient.
- #send_batch ⇒ Object
Methods inherited from Client
Constructor Details
#initialize(ipcpath = "#{ENV['HOME']}/.ethereum/geth.ipc", log = true) ⇒ IpcClient
6 7 8 9 10 11 12 13 14 |
# File 'lib/ethereum/ipc_client.rb', line 6 def initialize(ipcpath = "#{ENV['HOME']}/.ethereum/geth.ipc", log = true) @ipcpath = ipcpath @id = 1 @batch = [] @log = log if @log == true @logger = Logger.new("/tmp/ethereum_ruby_ipc.log") end end |
Instance Attribute Details
#batch ⇒ Object
Returns the value of attribute batch.
4 5 6 |
# File 'lib/ethereum/ipc_client.rb', line 4 def batch @batch end |
#command ⇒ Object
Returns the value of attribute command.
4 5 6 |
# File 'lib/ethereum/ipc_client.rb', line 4 def command @command end |
#converted_transactions ⇒ Object
Returns the value of attribute converted_transactions.
4 5 6 |
# File 'lib/ethereum/ipc_client.rb', line 4 def converted_transactions @converted_transactions end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/ethereum/ipc_client.rb', line 4 def id @id end |
#ipcpath ⇒ Object
Returns the value of attribute ipcpath.
4 5 6 |
# File 'lib/ethereum/ipc_client.rb', line 4 def ipcpath @ipcpath end |
#log ⇒ Object
Returns the value of attribute log.
4 5 6 |
# File 'lib/ethereum/ipc_client.rb', line 4 def log @log end |
#logger ⇒ Object
Returns the value of attribute logger.
4 5 6 |
# File 'lib/ethereum/ipc_client.rb', line 4 def logger @logger end |
Instance Method Details
#send_batch ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/ethereum/ipc_client.rb', line 43 def send_batch socket = UNIXSocket.new(@ipcpath) socket.write(@batch.join(" ")) socket.close_write read = socket.read collection = read.chop.split("}{").collect do |output| if output[0] == "{" JSON.parse("#{output}}")["result"] else JSON.parse("{#{output}}")["result"] end end return collection end |