Class: Nem::Endpoint::Node

Inherits:
Base
  • Object
show all
Defined in:
lib/nem/endpoint/node.rb

Defined Under Namespace

Classes: PeerlistAll

Instance Method Summary collapse

Methods inherited from Base

#current_node, #initialize, #next_node!, #request, #request!

Constructor Details

This class inherits a constructor from Nem::Endpoint::Base

Instance Method Details

#boot(boot_node_request) ⇒ nil

Parameters:

  • boot_node_request (Nem::Model::BootNodeRequest)

Returns:

  • (nil)

See Also:



79
80
81
# File 'lib/nem/endpoint/node.rb', line 79

def boot(boot_node_request)
  request!(:post, '/node/boot', boot_node_request)
end

#experiencesNem::Model::ExtendedNodeExperiencePair

Returns:

  • (Nem::Model::ExtendedNodeExperiencePair)

See Also:



24
25
26
27
28
29
30
# File 'lib/nem/endpoint/node.rb', line 24

def experiences
  request!(:get, '/node/experiences') do |res|
    res[:data].map do |struct|
      Nem::Model::Experience.new_from_experience(struct)
    end
  end
end

#extended_infoNem::Model::NisNodeInfo



18
19
20
# File 'lib/nem/endpoint/node.rb', line 18

def extended_info
  Nem::Model::NisNodeInfo.new_from_nis_node_info request!(:get, '/node/extended-info')
end

#infoNem::Model::Node



12
13
14
# File 'lib/nem/endpoint/node.rb', line 12

def info
  Nem::Model::Node.new_from_node request!(:get, '/node/info')
end

#max_chain_heightinteger



6
7
8
# File 'lib/nem/endpoint/node.rb', line 6

def max_chain_height
  request!(:get, '/node/active-peers/max-chain-height')[:height]
end

#peerlist(type = :all) ⇒ Array <Nem::Model::Node>

Parameters:

  • type (Symbol) (defaults to: :all)

Returns:



68
69
70
71
72
73
74
# File 'lib/nem/endpoint/node.rb', line 68

def peerlist(type = :all)
  case type.to_s
  when /\Aactive/ then peerlist_active
  when /\Areach/ then peerlist_reachable
  else peerlist_all
  end
end

#peerlist_activeArray <Nem::Model::Node>



34
35
36
37
38
39
40
# File 'lib/nem/endpoint/node.rb', line 34

def peerlist_active
  request!(:get, '/node/peer-list/active') do |res|
    res[:data].map do |n|
      Nem::Model::Node.new_from_node(n)
    end
  end
end

#peerlist_allObject



45
46
47
48
49
50
51
52
53
54
# File 'lib/nem/endpoint/node.rb', line 45

def peerlist_all
  request!(:get, '/node/peer-list/all') do |res|
    PeerlistAll.new(
      res[:inactive].map { |n| Nem::Model::Node.new_from_node(n) },
      res[:failure].map { |n| Nem::Model::Node.new_from_node(n) },
      res[:busy].map { |n| Nem::Model::Node.new_from_node(n) },
      res[:active].map { |n| Nem::Model::Node.new_from_node(n) }
    )
  end
end

#peerlist_reachableArray <Nem::Model::Node>



58
59
60
61
62
63
64
# File 'lib/nem/endpoint/node.rb', line 58

def peerlist_reachable
  request!(:get, '/node/peer-list/reachable') do |res|
    res[:data].map do |n|
      Nem::Model::Node.new_from_node(n)
    end
  end
end