Class: CasperClient
- Inherits:
-
Object
- Object
- CasperClient
- Defined in:
- lib/casper_sdk.rb
Overview
Class for interacting with the network via RPC
Instance Attribute Summary collapse
-
#ip_address ⇒ Object
Returns the value of attribute ip_address.
-
#port ⇒ Object
Returns the value of attribute port.
-
#state_root_hash ⇒ Object
Returns the value of attribute state_root_hash.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#chain_get_block(block_hash) ⇒ Object
-
@return block_info.
-
-
#chain_get_block_transfers ⇒ Object
-
@return block_transfers.
-
-
#chain_get_eraInfo_by_SwitchBlock ⇒ Object
-
@param block_hash * @return era_summary.
-
-
#chain_get_StateRootHash ⇒ Object
-
@return state_root_hash value.
-
-
#info_get_deploy(deploy_Hash) ⇒ Object
Get information about a single deploy by hash.
-
#info_get_peers ⇒ Object
-
@return peers array.
-
-
#info_get_status ⇒ Object
-
Receive node status information * @return node_status.
-
-
#initialize(ip_address, port = 7777) ⇒ CasperClient
constructor
Constructor * @param ip_address * @param port.
-
#state_get_AuctionInfo ⇒ Object
Returns current auction system contract information.
- #state_get_dictionary_item ⇒ Object
-
#state_get_item(stateRootHash, key, path) ⇒ Object
-
@param state_root_hash * @param key * @param path.
-
Constructor Details
#initialize(ip_address, port = 7777) ⇒ CasperClient
Constructor
-
@param ip_address
-
@param port
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/casper_sdk.rb', line 12 def initialize(ip_address, port = 7777) @ip_address = ip_address @port = port @url = "http://" + self.ip_address + ":" + self.port.to_s + "/rpc" @state_root_hash = "" @peer_array = [] @deploy_hash = "" @deploy_hashes = [] @auction_state_array = [] @auction_state = {} @node_status = {} @block_transfers = [] @block_info = {} end |
Instance Attribute Details
#ip_address ⇒ Object
Returns the value of attribute ip_address.
7 8 9 |
# File 'lib/casper_sdk.rb', line 7 def ip_address @ip_address end |
#port ⇒ Object
Returns the value of attribute port.
7 8 9 |
# File 'lib/casper_sdk.rb', line 7 def port @port end |
#state_root_hash ⇒ Object
Returns the value of attribute state_root_hash.
7 8 9 |
# File 'lib/casper_sdk.rb', line 7 def state_root_hash @state_root_hash end |
#url ⇒ Object
Returns the value of attribute url.
7 8 9 |
# File 'lib/casper_sdk.rb', line 7 def url @url end |
Instance Method Details
#chain_get_block(block_hash) ⇒ Object
-
@return block_info
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/casper_sdk.rb', line 74 def chain_get_block(block_hash) client = Jimson::Client.new(self.url) result = client.chain_get_block({"block_identifier" => {"Hash" => block_hash}}) @block_info = result["block"] if (!@block_info.empty?() && @block_info["hash"] != block_hash) raise("Returned block does not have a matching hash.") else @block_info end end |
#chain_get_block_transfers ⇒ Object
-
@return block_transfers
68 69 70 71 |
# File 'lib/casper_sdk.rb', line 68 def chain_get_block_transfers client = Jimson::Client.new(self.url) @block_transfers = client.chain_get_block_transfers["transfers"] end |
#chain_get_eraInfo_by_SwitchBlock ⇒ Object
-
@param block_hash
-
@return era_summary
87 88 89 90 91 |
# File 'lib/casper_sdk.rb', line 87 def chain_get_eraInfo_by_SwitchBlock client = Jimson::Client.new(self.url) result = client.chain_get_era_info_by_switch_block("block_identifier" => {"Hash" => block_hash}) result["era_summary"] end |
#chain_get_StateRootHash ⇒ Object
-
@return state_root_hash value
35 36 37 38 39 |
# File 'lib/casper_sdk.rb', line 35 def chain_get_StateRootHash client = Jimson::Client.new(self.url) result = client.chain_get_state_root_hash @state_root_hash = result["state_root_hash"] end |
#info_get_deploy(deploy_Hash) ⇒ Object
Get information about a single deploy by hash.
-
@param deploy_hash
-
@return Deploy
44 45 46 47 48 49 50 |
# File 'lib/casper_sdk.rb', line 44 def info_get_deploy(deploy_Hash) @h = {'deploy_hash' => deploy_Hash } client = Jimson::Client.new(self.url) result = client.info_get_deploy(@h) hash1 = result["deploy"] @deploy_hash = result["deploy"] end |
#info_get_peers ⇒ Object
-
@return peers array
28 29 30 31 32 |
# File 'lib/casper_sdk.rb', line 28 def info_get_peers client = Jimson::Client.new(self.url) result = client.info_get_peers @peer_array = result["peers"] end |
#info_get_status ⇒ Object
-
Receive node status information
-
@return node_status
62 63 64 65 |
# File 'lib/casper_sdk.rb', line 62 def info_get_status client = Jimson::Client.new(self.url) @node_status = client.info_get_status end |
#state_get_AuctionInfo ⇒ Object
Returns current auction system contract information.
-
@return auction_state
54 55 56 57 58 |
# File 'lib/casper_sdk.rb', line 54 def state_get_AuctionInfo client = Jimson::Client.new(self.url) result = client.state_get_auction_info @auction_state = result['auction_state'] end |
#state_get_dictionary_item ⇒ Object
106 107 |
# File 'lib/casper_sdk.rb', line 106 def state_get_dictionary_item end |
#state_get_item(stateRootHash, key, path) ⇒ Object
-
@param state_root_hash
-
@param key
-
@param path
96 97 98 99 100 101 102 103 104 |
# File 'lib/casper_sdk.rb', line 96 def state_get_item(stateRootHash, key, path) client = Jimson::Client.new(self.url) response = client.state_get_item({ "state_root_hash" => stateRootHash, "key" => key, "path" => path }) response["stored_value"] end |