lib/nanook/block.rb in nanook-0.6.3 vs lib/nanook/block.rb in nanook-0.7.0

- old
+ new

@@ -6,27 +6,28 @@ @rpc = rpc block_required! # All methods expect a block end def account - rpc(:block_account, :hash) + rpc(:block_account, :hash)[:account] end def cancel_work - rpc(:work_cancel, :hash) + rpc(:work_cancel, :hash).empty? end def chain(limit: 1000) - rpc(:chain, :block, count: limit) + response = rpc(:chain, :block, count: limit)[:blocks] + Nanook::Util.coerce_empty_string_to_type(response, Array) end def generate_work - rpc(:work_generate, :hash) + rpc(:work_generate, :hash)[:work] end def history(limit: 1000) - rpc(:history, :hash, count: limit) + rpc(:history, :hash, count: limit)[:history] end def info(allow_unchecked: false) if allow_unchecked # TODO not actually sure what this response looks like when it's not an unchecked block, assuming its blank @@ -55,24 +56,25 @@ params = {} params[:destinations] = destinations unless destinations.nil? params[:sources] = sources unless sources.nil? params[:count] = 1 unless params.empty? - rpc(:republish, :hash, params) + rpc(:republish, :hash, params)[:blocks] end def pending? response = rpc(:pending_exists, :hash) !response.empty? && response[:exists] == 1 end def process - rpc(:process, :block) + rpc(:process, :block)[:hash] end def successors(limit: 1000) - rpc(:successors, :block, count: limit) + response = rpc(:successors, :block, count: limit)[:blocks] + Nanook::Util.coerce_empty_string_to_type(response, Array) end private # Some RPC calls expect the param that represents the block to be named @@ -90,11 +92,12 @@ end def _parse_info_response(response) # The contents is a stringified JSON if response[:contents] - response[:contents] = JSON.parse(response[:contents]) + return JSON.parse(response[:contents]).to_symbolized_hash end + response end end end