Class: NanoRpc::Node
- Inherits:
-
Object
- Object
- NanoRpc::Node
- Includes:
- NodeHelper, Proxy
- Defined in:
- lib/nano_rpc/node.rb
Instance Attribute Summary collapse
-
#auth ⇒ Object
readonly
Returns the value of attribute auth.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
- #call(action, params = {}) ⇒ Object
-
#initialize(host: 'localhost', port: 7076, auth: nil, headers: nil) ⇒ Node
constructor
A new instance of Node.
-
#inspect ⇒ Object
Condense host/port on object inspection.
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
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
#auth ⇒ Object (readonly)
Returns the value of attribute auth.
14 15 16 |
# File 'lib/nano_rpc/node.rb', line 14 def auth @auth end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
14 15 16 |
# File 'lib/nano_rpc/node.rb', line 14 def headers @headers end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
14 15 16 |
# File 'lib/nano_rpc/node.rb', line 14 def host @host end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
14 15 16 |
# File 'lib/nano_rpc/node.rb', line 14 def node @node end |
#port ⇒ Object (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 |
#inspect ⇒ Object
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 |