1 | <?php |
||
13 | class BlockHeader extends Serializable implements BlockHeaderInterface |
||
14 | { |
||
15 | |||
16 | /** |
||
17 | * @var int |
||
18 | */ |
||
19 | protected $version; |
||
20 | |||
21 | /** |
||
22 | * @var BufferInterface |
||
23 | */ |
||
24 | protected $prevBlock; |
||
25 | |||
26 | /** |
||
27 | * @var BufferInterface |
||
28 | */ |
||
29 | protected $merkleRoot; |
||
30 | |||
31 | /** |
||
32 | * @var int |
||
33 | */ |
||
34 | protected $timestamp; |
||
35 | |||
36 | /** |
||
37 | * @var int |
||
38 | */ |
||
39 | protected $bits; |
||
40 | |||
41 | /** |
||
42 | * @var int |
||
43 | */ |
||
44 | protected $nonce; |
||
45 | |||
46 | const BIP9_PREFIX = 1 << 29; |
||
47 | |||
48 | /** |
||
49 | * @param int $version |
||
50 | * @param BufferInterface $prevBlock |
||
51 | * @param BufferInterface $merkleRoot |
||
52 | * @param int $timestamp |
||
53 | * @param int $bits |
||
54 | * @param int $nonce |
||
55 | * @throws InvalidHashLengthException |
||
56 | 25 | */ |
|
57 | public function __construct(int $version, BufferInterface $prevBlock, BufferInterface $merkleRoot, int $timestamp, int $bits, int $nonce) |
||
68 | 23 | ||
69 | 23 | /** |
|
70 | 23 | * @return BufferInterface |
|
71 | 23 | */ |
|
72 | 23 | public function getHash(): BufferInterface |
|
76 | |||
77 | 191 | /** |
|
78 | * Get the version for this block |
||
79 | 191 | * |
|
80 | * {@inheritdoc} |
||
81 | * @see \BitWasp\Bitcoin\Block\BlockHeaderInterface::getVersion() |
||
82 | */ |
||
83 | public function getVersion(): int |
||
87 | |||
88 | 201 | /** |
|
89 | * @return bool |
||
90 | 201 | */ |
|
91 | public function hasBip9Prefix(): bool |
||
95 | |||
96 | 16 | /** |
|
97 | * {@inheritdoc} |
||
98 | 16 | * @see \BitWasp\Bitcoin\Block\BlockHeaderInterface::getPrevBlock() |
|
99 | */ |
||
100 | public function getPrevBlock(): BufferInterface |
||
104 | |||
105 | 201 | /** |
|
106 | * {@inheritdoc} |
||
107 | 201 | * @see \BitWasp\Bitcoin\Block\BlockHeaderInterface::getMerkleRoot() |
|
108 | */ |
||
109 | public function getMerkleRoot(): BufferInterface |
||
113 | |||
114 | 204 | /** |
|
115 | * {@inheritdoc} |
||
116 | 204 | * @see \BitWasp\Bitcoin\Block\BlockHeaderInterface::getBits() |
|
117 | */ |
||
118 | public function getBits(): int |
||
122 | |||
123 | 200 | /** |
|
124 | * {@inheritdoc} |
||
125 | 200 | * @see \BitWasp\Bitcoin\Block\BlockHeaderInterface::getNonce() |
|
126 | */ |
||
127 | public function getNonce(): int |
||
131 | |||
132 | 201 | /** |
|
133 | * Get the timestamp for this block |
||
134 | 201 | * |
|
135 | * {@inheritdoc} |
||
136 | * @see \BitWasp\Bitcoin\Block\BlockHeaderInterface::getTimestamp() |
||
137 | */ |
||
138 | public function getTimestamp(): int |
||
142 | |||
143 | 201 | /** |
|
144 | * @param BlockHeaderInterface $other |
||
145 | 201 | * @return bool |
|
146 | */ |
||
147 | public function equals(BlockHeaderInterface $other): bool |
||
156 | 1 | ||
157 | 1 | /** |
|
158 | 1 | * {@inheritdoc} |
|
159 | 1 | * @see \BitWasp\Buffertools\SerializableInterface::getBuffer() |
|
160 | */ |
||
161 | public function getBuffer(): BufferInterface |
||
165 | |||
166 | 192 | /** |
|
167 | * @throws InvalidHashLengthException |
||
168 | 192 | */ |
|
169 | protected function validate() |
||
179 | } |
||
180 |