Class: NanoRpc::Node

Inherits:
Object
  • Object
show all
Includes:
NodeHelper, Proxy
Defined in:
lib/nano_rpc/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from NodeHelper

#account, #account_containing_block, #accounts, #create_wallet, #knano_from_raw, #knano_to_raw, #mnano_from_raw, #mnano_to_raw, #nano_from_raw, #nano_to_raw, #num_frontiers, #pending_exists?, #total_supply, #wallet, #work_valid?

Methods included from Proxy

included, #proxy_methods

Constructor Details

#initialize(host: 'localhost', port: 7076, auth: nil, headers: nil) ⇒ Node

Returns a new instance of Node.



16
17
18
19
20
21
22
23
24
# File 'lib/nano_rpc/node.rb', line 16

def initialize(host: 'localhost', port: 7076, auth: nil, headers: nil)
  @host = host
  @port = port
  @auth = auth
  @headers = headers
  @node = self

  super
end

Instance Attribute Details

#authObject (readonly)

Returns the value of attribute auth.



14
15
16
# File 'lib/nano_rpc/node.rb', line 14

def auth
  @auth
end

#headersObject (readonly)

Returns the value of attribute headers.



14
15
16
# File 'lib/nano_rpc/node.rb', line 14

def headers
  @headers
end

#hostObject (readonly)

Returns the value of attribute host.



14
15
16
# File 'lib/nano_rpc/node.rb', line 14

def host
  @host
end

#nodeObject (readonly)

Returns the value of attribute node.



14
15
16
# File 'lib/nano_rpc/node.rb', line 14

def node
  @node
end

#portObject (readonly)

Returns the value of attribute port.



14
15
16
# File 'lib/nano_rpc/node.rb', line 14

def port
  @port
end

Instance Method Details

#call(action, params = {}) ⇒ Object



31
32
33
34
35
36
# File 'lib/nano_rpc/node.rb', line 31

def call(action, params = {})
  args = { action: action }
  args.merge!(params) if params.is_a?(Hash)
  args = extract_proxy_args(args)
  rpc_post(args)
end

#inspectObject

Condense host/port on object inspection



27
28
29
# File 'lib/nano_rpc/node.rb', line 27

def inspect
  "#{inspect_prefix}, @url=\"#{@host}:#{port}\">"
end