Class: NanoRpc::Node
- Inherits:
-
Object
- Object
- NanoRpc::Node
- Includes:
- NodeHelper, Proxy
- Defined in:
- lib/nano_rpc/node.rb
Constant Summary collapse
- DEFAULT_TIMEOUT =
60
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.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Instance Method Summary collapse
- #call(action, params = {}) ⇒ Object
-
#initialize(host: 'localhost', port: 7076, auth: nil, headers: nil, timeout: DEFAULT_TIMEOUT) ⇒ 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, timeout: DEFAULT_TIMEOUT) ⇒ Node
Returns a new instance of Node.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/nano_rpc/node.rb', line 19 def initialize( host: 'localhost', port: 7076, auth: nil, headers: nil, timeout: DEFAULT_TIMEOUT ) @host = host @port = port @auth = auth @headers = headers @timeout = timeout @node = self super end |
Instance Attribute Details
#auth ⇒ Object (readonly)
Returns the value of attribute auth.
15 16 17 |
# File 'lib/nano_rpc/node.rb', line 15 def auth @auth end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
15 16 17 |
# File 'lib/nano_rpc/node.rb', line 15 def headers @headers end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
15 16 17 |
# File 'lib/nano_rpc/node.rb', line 15 def host @host end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
15 16 17 |
# File 'lib/nano_rpc/node.rb', line 15 def node @node end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
15 16 17 |
# File 'lib/nano_rpc/node.rb', line 15 def port @port end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
15 16 17 |
# File 'lib/nano_rpc/node.rb', line 15 def timeout @timeout end |
Instance Method Details
#call(action, params = {}) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/nano_rpc/node.rb', line 36 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
44 45 46 |
# File 'lib/nano_rpc/node.rb', line 44 def inspect "#{inspect_prefix}, @url=\"#{@host}:#{port}\">" end |