Module: Filecoin::Client::Node

Included in:
Filecoin::Client
Defined in:
lib/filecoin/client/node.rb

Instance Method Summary collapse

Instance Method Details

#chain_headObject



7
8
9
# File 'lib/filecoin/client/node.rb', line 7

def chain_head
  json_rpc_call "Filecoin.ChainHead"
end

#client_get_deal_info(deal_id) ⇒ Object



11
12
13
14
15
# File 'lib/filecoin/client/node.rb', line 11

def client_get_deal_info(deal_id)
  params = Types::Cid.new(deal_id).as_json

  json_rpc_call "Filecoin.ClientGetDealInfo", params
end

#client_query_ask(peer_id, miner_id) ⇒ Object



17
18
19
# File 'lib/filecoin/client/node.rb', line 17

def client_query_ask(peer_id, miner_id)
  json_rpc_call "Filecoin.ClientQueryAsk", peer_id, miner_id
end

#client_start_deal(start_deal_params, extract_response: false) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/filecoin/client/node.rb', line 21

def client_start_deal(start_deal_params, extract_response: false)
  params = if start_deal_params.is_a?(Hash)
             start_deal_params
           else
             start_deal_params.as_json
           end

  response = json_rpc_call("Filecoin.ClientStartDeal", params)

  extract_response ? response.dig("result", "/") : response
end

#net_peersObject



33
34
35
# File 'lib/filecoin/client/node.rb', line 33

def net_peers
  json_rpc_call "Filecoin.NetPeers"
end

#state_power(extract_response: false) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'lib/filecoin/client/node.rb', line 37

def state_power(extract_response: false)
  response = json_rpc_call "Filecoin.StateMinerPower", nil, nil

  if extract_response
    Types::PowerClaim.from_as_json(response.dig("result", "TotalPower"))
  else
    response
  end
end