Class: Bytom::Peer

Inherits:
Object
  • Object
show all
Defined in:
lib/bytom/api/peer.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Peer

Returns a new instance of Peer.



6
7
8
# File 'lib/bytom/api/peer.rb', line 6

def initialize(client)
  @client = client
end

Instance Method Details

#connect_peer(ip:, port:) ⇒ Object

Connect to specified peer.

Parameters:

  • ip (String)

    peer IP address.

  • port (Fixnum)

    peer port.



32
33
34
35
36
37
38
# File 'lib/bytom/api/peer.rb', line 32

def connect_peer(ip:, port:)
  params = {
      ip: ip,
      port: port
  }
  client.make_request('/connect-peer', 'post', params: params)
end

#disconnect_peer(peer_id:) ⇒ Object

Disconnect to specified peer.

Parameters:

  • peer_id (String)


22
23
24
# File 'lib/bytom/api/peer.rb', line 22

def disconnect_peer(peer_id:)
  client.make_request('/disconnect-peer', 'post', params: {peer_id: peer_id})
end

#list_peersObject

Returns the list of connected peers.



13
14
15
# File 'lib/bytom/api/peer.rb', line 13

def list_peers
  client.make_request('/list-peers', 'post', params: {})
end