Blockchain::getBestBlockHash()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * User: delboy1978uk
4
 * Date: 18/08/15
5
 * Time: 19:43
6
 */
7
8
namespace Del\Bitcoin\Api;
9
10
11
class Blockchain extends AbstractApi
12
{
13
14
    /**
15
     * returns the header hash of the most recent block on the best block chain.
16
     *
17
     * @return mixed
18
     */
19
    public function getBestBlockHash()
20
    {
21
        return $this->send('getbestblockhash');
22
    }
23
24
    /**
25
     * The getblock RPC gets a block with a particular header hash from
26
     * the local block database either as a JSON object
27
     * or as a serialized block.
28
     *
29
     * @param string $header_hash The hash of the header of the block to get,
30
     * encoded as hex in RPC byte order
31
     * @param bool $json Set to false to get the block in serialized block format;
32
     * set to true (the default) to get the decoded block as a JSON object
33
     * @return mixed
34
     */
35
    public function getBlock($header_hash,$json = true)
36
    {
37
        return $this->send('getblock',[$header_hash,$json]);
38
    }
39
40
    /**
41
     * The getblockchaininfo RPC provides information about
42
     * the current state of the block chain.
43
     *
44
     * @return mixed
45
     */
46
    public function getBlockChainInfo()
47
    {
48
        return $this->send('getblockchaininfo');
49
    }
50
51
    /**
52
     * The getblockcount RPC returns the number of blocks in
53
     * the local best block chain.
54
     *
55
     * @return mixed
56
     */
57
    public function getBlockCount()
58
    {
59
        return $this->send('getblockcount');
60
    }
61
62
    /**
63
     * The getblockhash RPC returns the header hash of a block
64
     * at the given height in the local best block chain.
65
     *
66
     * @param int $height The height of the block whose header hash
67
     * should be returned. The height of the hardcoded genesis block is 0
68
     * @return mixed
69
     */
70
    public function getBlockHash($height)
71
    {
72
        return $this->send('getblockhash',[$height]);
73
    }
74
75
    /**
76
     * The getchaintips RPC returns information about the
77
     * highest-height block (tip) of each local block chain.
78
     *
79
     * @return mixed
80
     */
81
    public function getChainTips()
82
    {
83
        return $this->send('getchaintips');
84
    }
85
86
    /**
87
     * The getdifficulty RPC
88
     *
89
     * @return mixed
90
     */
91
    public function getDifficulty()
92
    {
93
        return $this->send('getdifficulty');
94
    }
95
96
    /**
97
     * The getmempoolinfo RPC returns information about
98
     * the node’s current transaction memory pool.
99
     *
100
     * @return mixed
101
     */
102
    public function getMemPoolInfo()
103
    {
104
        return $this->send('getmempoolinfo');
105
    }
106
107
    /**
108
     * The getrawmempool RPC returns all transaction identifiers (TXIDs)
109
     * in the memory pool as a JSON array, or detailed information about
110
     * each transaction in the memory pool as a JSON object.
111
     *
112
     * @param bool $format Set to true to get verbose output describing
113
     * each transaction in the memory pool; set to false (the default) to
114
     * only get an array of TXIDs for transactions in the memory pool
115
     * @return mixed
116
     */
117
    public function getRawMemPool($format = false)
118
    {
119
        return $this->send('getrawmempool',[$format]);
120
    }
121
122
    /**
123
     * The gettxout RPC returns details about a transaction output.
124
     * Only unspent transaction outputs (UTXOs) are guaranteed to be
125
     * available.
126
     *
127
     * @param string $txid The TXID of the transaction containing the
128
     * output to get, encoded as hex in RPC byte order
129
     * @return mixed
130
     */
131
    public function getTxOut($txid)
132
    {
133
        return $this->send('gettxout',[$txid]);
134
    }
135
136
    /**
137
     * The gettxoutsetinfo RPC returns statistics about the confirmed
138
     * unspent transaction output (UTXO) set. Note that this call may
139
     * take some time and that it only counts outputs from confirmed
140
     * transactions—it does not count outputs from the memory pool.
141
     *
142
     * @return mixed
143
     */
144
    public function getTxOutSetInfo()
145
    {
146
        return $this->send('gettxoutsetinfo');
147
    }
148
149
    /**
150
     * The verifychain RPC verifies each entry in the local
151
     * block chain database.
152
     *
153
     * @param int $check_level How thoroughly to check each block,
154
     * from 0 to 4. Default is the level set with the -checklevel command
155
     * line argument; if that isn’t set, the default is 3. Each higher
156
     * level includes the tests from the lower levels
157
     * Levels are:
158
     * 0. Read from disk to ensure the files are accessible
159
     * 1. Ensure each block is valid
160
     * 2. Make sure undo files can be read from disk and are in a valid format
161
     * 3. Test each block undo to ensure it results in correct state
162
     * 4. After undoing blocks, reconnect them to ensure they reconnect correctly
163
     * @param int $num_blocks The number of blocks to verify. Set to 0 to check
164
     * all blocks. Defaults to the value of the -checkblocks command-line
165
     * argument; if that isn’t set, the default is 288
166
     * @return mixed
167
     */
168
    public function verifyChain($check_level, $num_blocks)
169
    {
170
        return $this->send('verifychain',[$check_level,$num_blocks]);
171
    }
172
}