コード例 #1
0
ファイル: Api.php プロジェクト: ligerzero459/block-explorer
 public function getLatestBlocks()
 {
     $height = $this->bootstrap->httpRequest->get('height');
     $limit = $this->getLimit(10, 100);
     $paycoin = new PaycoinDb();
     $blocks = $paycoin->getLatestBlocks($limit, $height);
     foreach ($blocks as &$block) {
         $block['raw'] = unserialize($block['raw']);
     }
     $this->outputJsonResponse($blocks);
 }
コード例 #2
0
ファイル: Chart.php プロジェクト: ligerzero459/block-explorer
    public function transactionsPerBlock()
    {
        $this->setData('activeTab', 'Charts');
        $this->setData('activePulldown', 'Transactions Per Block');
        $this->addJs('/js/market_info.js');
        $this->addJs('/js/update_outstanding.js');
        $this->addJs('/highstock/js/highstock.js');
        $this->addJs('/highstock/js/modules/exporting.js');
        $this->addJs('/js/charts/theme.js');
        $this->setData('pageTitle', 'Charts - Value Per Transaction');
        $limit = $this->getLimit(50);
        $options = array(array('value' => '100', 'name' => 'Last 100 Blocks'), array('value' => '1000', 'name' => 'Last 1000 Blocks'), array('value' => '2500', 'name' => 'Last 2500 Blocks'));
        $limitSelector = '<li class="pull-right"><form method="post">
			<div class="form-group col-sm-10" style="margin-bottom: 0px">
			<select name="limit" class="form-control">';
        foreach ($options as $option) {
            $limitSelector .= '<option value="' . $option['value'] . '" ';
            if ($this->getData('limit') == $option['value']) {
                $limitSelector .= 'selected';
            }
            $limitSelector .= '>' . $option['name'] . '</option>';
        }
        $limitSelector .= '</select></div>
				<div class="col-sm-2 form-group" style="margin-bottom: 0px">
					<input type="submit" value="Go" class="btn btn-default">
				</div>
			</form>
			</li>';
        $this->setData('limitSelector', $limitSelector);
        $paycoinDb = new PaycoinDb();
        $blocks = $paycoinDb->getLatestBlocks($limit, 0, 600);
        $blocks = array_reverse($blocks);
        $blocks = array_column($blocks, null, 'height');
        $categories = json_encode(array_keys($blocks));
        $dataPoints = array_column($blocks, 'transactions');
        array_walk($dataPoints, function (&$val) {
            $val = (int) $val;
        });
        $dataPoints = json_encode($dataPoints);
        $this->setData('categories', $categories);
        $this->setData('dataPoints', $dataPoints);
        $this->render('header');
        $this->render('charts/transaction-per-block');
        $this->render('footer');
    }