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