lib/universa/client.rb in universa-0.3.3 vs lib/universa/client.rb in universa-3.9.14
- old
+ new
@@ -119,9 +119,27 @@
# Do not create it direcly, use {Client#random_connection}, {Client#random_connections} or {Client#[]} instead
def initialize umi_client
@client = umi_client
end
+ def umi_client
+ @client
+ end
+
+ def node_number
+ @node_number ||= @client.getNodeNumber()
+ end
+
+ # ping another node from this one
+ #
+ # @param [Numeric] node_number to ping
+ # @param [Numeric] timeout
+ #
+ # @return [Hash] hashie with TCP and UDP fields holding ping time in millis, -1 if not available
+ def ping_node(node_number, timeout: 5000)
+ Hashie::Mash.new(@client.pingNode(node_number, timeout).to_h)
+ end
+
# Check the connected node is alive. It is adivesd to call {restart} on nodes that return false on pings
# to reestablish connection.
#
# @return true if it is ok
def ping