Circle-Block

 view release on metacpan or  search on metacpan

lib/Circle/Block.pm  view on Meta::CPAN

package Circle::Block;

use 5.006;
use strict;
use warnings;
use Exporter 'import';
use Carp;
use Try::Tiny;
use URL::Encode;
use Circle::Common qw(load_config build_url_template http_json_post http_json_get);

our $VERSION = '0.05';

our @EXPORT = qw(
  get_block_hashlist
  get_block
  get_block_header_list
  get_block_data
  get_blocktails_hashlist
  get_blocktails_po
  get_tx_by_txid
  search_tx_by_txid
  search_tx_by_address
  search_utxos
);

sub _build_url_template {
    my ($path, $params_for) = @_;
    return build_url_template( "block", $path, $params_for );
}

sub get_block_hashlist {
    my ($base_height) = @_;
    my $url = _build_url_template(
        "blockchainHashListPath",
        {
            baseHeight => $base_height
        }
    );
    carp 'url: ' . $url;
    return http_json_get($url, 0);
}

sub get_block {
    my ($hash) = @_;
    my $url = _build_url_template(
        "blockchainPath",
        {
            hash => $hash
        }
    );
    return http_json_get($url);
}

sub get_block_header_list {
    my ($base_height) = @_;
    my $url = _build_url_template(
        "blockchainHeaderListPath",
        {
            baseHeight => $base_height
        }
    );
    return http_json_get($url, 0);
}

sub get_block_data {
    my ($hash) = @_;
    my $url = _build_url_template(



( run in 0.901 second using v1.01-cache-2.11-cpan-39bf76dae61 )