1 | <?php |
||
13 | class BlockHeader extends Serializable implements BlockHeaderInterface |
||
14 | { |
||
15 | |||
16 | /** |
||
17 | * @var int |
||
18 | */ |
||
19 | private $version; |
||
20 | |||
21 | /** |
||
22 | * @var BufferInterface |
||
23 | */ |
||
24 | private $prevBlock; |
||
25 | |||
26 | /** |
||
27 | * @var BufferInterface |
||
28 | */ |
||
29 | private $merkleRoot; |
||
30 | |||
31 | /** |
||
32 | * @var int |
||
33 | */ |
||
34 | private $timestamp; |
||
35 | |||
36 | /** |
||
37 | * @var int |
||
38 | */ |
||
39 | private $bits; |
||
40 | |||
41 | /** |
||
42 | * @var int |
||
43 | */ |
||
44 | private $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 | */ |
||
56 | 25 | public function __construct(int $version, BufferInterface $prevBlock, BufferInterface $merkleRoot, int $timestamp, int $bits, int $nonce) |
|
73 | |||
74 | /** |
||
75 | * @return BufferInterface |
||
76 | */ |
||
77 | 191 | public function getHash(): BufferInterface |
|
81 | |||
82 | /** |
||
83 | * Get the version for this block |
||
84 | * |
||
85 | * {@inheritdoc} |
||
86 | * @see \BitWasp\Bitcoin\Block\BlockHeaderInterface::getVersion() |
||
87 | */ |
||
88 | 201 | public function getVersion(): int |
|
92 | |||
93 | /** |
||
94 | * @return bool |
||
95 | */ |
||
96 | 16 | public function hasBip9Prefix(): bool |
|
100 | |||
101 | /** |
||
102 | * {@inheritdoc} |
||
103 | * @see \BitWasp\Bitcoin\Block\BlockHeaderInterface::getPrevBlock() |
||
104 | */ |
||
105 | 201 | public function getPrevBlock(): BufferInterface |
|
109 | |||
110 | /** |
||
111 | * {@inheritdoc} |
||
112 | * @see \BitWasp\Bitcoin\Block\BlockHeaderInterface::getMerkleRoot() |
||
113 | */ |
||
114 | 204 | public function getMerkleRoot(): BufferInterface |
|
118 | |||
119 | /** |
||
120 | * {@inheritdoc} |
||
121 | * @see \BitWasp\Bitcoin\Block\BlockHeaderInterface::getBits() |
||
122 | */ |
||
123 | 200 | public function getBits(): int |
|
127 | |||
128 | /** |
||
129 | * {@inheritdoc} |
||
130 | * @see \BitWasp\Bitcoin\Block\BlockHeaderInterface::getNonce() |
||
131 | */ |
||
132 | 201 | public function getNonce(): int |
|
136 | |||
137 | /** |
||
138 | * Get the timestamp for this block |
||
139 | * |
||
140 | * {@inheritdoc} |
||
141 | * @see \BitWasp\Bitcoin\Block\BlockHeaderInterface::getTimestamp() |
||
142 | */ |
||
143 | 201 | public function getTimestamp(): int |
|
147 | |||
148 | /** |
||
149 | * @param BlockHeaderInterface $other |
||
150 | * @return bool |
||
151 | */ |
||
152 | 1 | public function equals(BlockHeaderInterface $other): bool |
|
161 | |||
162 | /** |
||
163 | * {@inheritdoc} |
||
164 | * @see \BitWasp\Buffertools\SerializableInterface::getBuffer() |
||
165 | */ |
||
166 | 192 | public function getBuffer(): BufferInterface |
|
170 | } |
||
171 |