|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace BitWasp\Bitcoin\Networking\Structure; |
|
6
|
|
|
|
|
7
|
|
|
use BitWasp\Bitcoin\Networking\Serializer\Structure\AlertDetailSerializer; |
|
8
|
|
|
use BitWasp\Bitcoin\Serializable; |
|
9
|
|
|
use BitWasp\Buffertools\BufferInterface; |
|
10
|
|
|
|
|
11
|
|
|
class AlertDetail extends Serializable |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* Alert format version |
|
15
|
|
|
* @var int |
|
16
|
|
|
*/ |
|
17
|
|
|
private $version; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Timestamp beyond which nodes should stop relaying this alert |
|
21
|
|
|
* @var int |
|
22
|
|
|
*/ |
|
23
|
|
|
private $relayUntil; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Timestamp beyond which this alert can be ignored |
|
27
|
|
|
* @var int |
|
28
|
|
|
*/ |
|
29
|
|
|
private $expiration; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* A unique ID number for this alert |
|
33
|
|
|
* @var int |
|
34
|
|
|
*/ |
|
35
|
|
|
private $id; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* All alerts with an ID number less than or equal to this number |
|
39
|
|
|
* should be cancelled, deleted, not accepted in the future. |
|
40
|
|
|
* |
|
41
|
|
|
* @var int |
|
42
|
|
|
*/ |
|
43
|
|
|
private $cancel; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* All alert IDs contained in this set should be cancelled |
|
47
|
|
|
* @var integer[] |
|
48
|
|
|
*/ |
|
49
|
|
|
private $setCancel; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* This alert only applies to versions greater than or equal |
|
53
|
|
|
* to this version. Other versions should still relay it. |
|
54
|
|
|
* @var int |
|
55
|
|
|
*/ |
|
56
|
|
|
private $minVer; |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* This alert only applies to versions less than or equal to |
|
60
|
|
|
* this version. Other versions should still relay it. |
|
61
|
|
|
* @var int |
|
62
|
|
|
*/ |
|
63
|
|
|
private $maxVer; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* If this set contains any elements, then only nodes that |
|
67
|
|
|
* have their subVer contained in this set are affected by |
|
68
|
|
|
* the alert. Other versions should still relay it. |
|
69
|
|
|
* @var integer[] |
|
70
|
|
|
*/ |
|
71
|
|
|
private $setSubVer; |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Relative priority compared to other alerts |
|
75
|
|
|
* @var int |
|
76
|
|
|
*/ |
|
77
|
|
|
private $priority; |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* A comment on the alert that is not displayed |
|
81
|
|
|
* @var BufferInterface |
|
82
|
|
|
* @todo: make string |
|
83
|
|
|
*/ |
|
84
|
|
|
private $comment; |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* The alert message that is displayed to the user |
|
88
|
6 |
|
* @var BufferInterface |
|
89
|
|
|
* @todo: make string |
|
90
|
|
|
*/ |
|
91
|
|
|
private $statusBar; |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* @param int $version |
|
95
|
|
|
* @param int $relayUntil |
|
96
|
|
|
* @param int $expiration |
|
97
|
|
|
* @param int $id |
|
98
|
|
|
* @param int $cancel |
|
99
|
|
|
* @param int[] $setCancel |
|
100
|
|
|
* @param int $minVer |
|
101
|
|
|
* @param int $maxVer |
|
102
|
6 |
|
* @param int[] $setSubVer |
|
103
|
6 |
|
* @param int $priority |
|
104
|
6 |
|
* @param BufferInterface $comment |
|
105
|
6 |
|
* @param BufferInterface $statusBar |
|
106
|
6 |
|
*/ |
|
107
|
6 |
|
public function __construct( |
|
108
|
6 |
|
int $version, |
|
109
|
6 |
|
int $relayUntil, |
|
110
|
6 |
|
int $expiration, |
|
111
|
6 |
|
int $id, |
|
112
|
6 |
|
int $cancel, |
|
113
|
6 |
|
array $setCancel, |
|
114
|
6 |
|
int $minVer, |
|
115
|
|
|
int $maxVer, |
|
116
|
|
|
array $setSubVer, |
|
117
|
|
|
int $priority, |
|
118
|
|
|
BufferInterface $comment, |
|
119
|
6 |
|
BufferInterface $statusBar |
|
120
|
|
|
) { |
|
121
|
6 |
|
$this->version = $version; |
|
122
|
|
|
$this->relayUntil = $relayUntil; |
|
123
|
|
|
$this->expiration = $expiration; |
|
124
|
|
|
$this->id = $id; |
|
125
|
|
|
$this->cancel = $cancel; |
|
126
|
|
|
$this->setCancel = $setCancel; |
|
127
|
6 |
|
$this->minVer = $minVer; |
|
128
|
|
|
$this->maxVer = $maxVer; |
|
129
|
6 |
|
$this->setSubVer = $setSubVer; |
|
130
|
|
|
$this->priority = $priority; |
|
131
|
|
|
$this->comment = $comment; |
|
132
|
|
|
$this->statusBar = $statusBar; |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
6 |
|
/** |
|
136
|
|
|
* @return int |
|
137
|
6 |
|
*/ |
|
138
|
|
|
public function getVersion(): int |
|
139
|
|
|
{ |
|
140
|
|
|
return $this->version; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
6 |
|
/** |
|
144
|
|
|
* @return int |
|
145
|
6 |
|
*/ |
|
146
|
|
|
public function getRelayUntil(): int |
|
147
|
|
|
{ |
|
148
|
|
|
return $this->relayUntil; |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
6 |
|
/** |
|
152
|
|
|
* @return int |
|
153
|
6 |
|
*/ |
|
154
|
|
|
public function getExpiration(): int |
|
155
|
|
|
{ |
|
156
|
|
|
return $this->expiration; |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
6 |
|
/** |
|
160
|
|
|
* @return int |
|
161
|
6 |
|
*/ |
|
162
|
|
|
public function getId(): int |
|
163
|
|
|
{ |
|
164
|
|
|
return $this->id; |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
6 |
|
/** |
|
168
|
|
|
* @return int |
|
169
|
6 |
|
*/ |
|
170
|
|
|
public function getCancel(): int |
|
171
|
|
|
{ |
|
172
|
|
|
return $this->cancel; |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
6 |
|
/** |
|
176
|
|
|
* @return integer[] |
|
177
|
6 |
|
*/ |
|
178
|
|
|
public function getSetCancel(): array |
|
179
|
|
|
{ |
|
180
|
|
|
return $this->setCancel; |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
6 |
|
/** |
|
184
|
|
|
* @return int |
|
185
|
6 |
|
*/ |
|
186
|
|
|
public function getMinVer(): int |
|
187
|
|
|
{ |
|
188
|
|
|
return $this->minVer; |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
6 |
|
/** |
|
192
|
|
|
* @return int |
|
193
|
6 |
|
*/ |
|
194
|
|
|
public function getMaxVer(): int |
|
195
|
|
|
{ |
|
196
|
|
|
return $this->maxVer; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
6 |
|
/** |
|
200
|
|
|
* @return integer[] |
|
201
|
6 |
|
*/ |
|
202
|
|
|
public function getSetSubVer(): array |
|
203
|
|
|
{ |
|
204
|
|
|
return $this->setSubVer; |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
6 |
|
/** |
|
208
|
|
|
* @return int |
|
209
|
6 |
|
*/ |
|
210
|
|
|
public function getPriority(): int |
|
211
|
|
|
{ |
|
212
|
|
|
return $this->priority; |
|
213
|
|
|
} |
|
214
|
|
|
|
|
215
|
6 |
|
/** |
|
216
|
|
|
* @return BufferInterface |
|
217
|
6 |
|
*/ |
|
218
|
|
|
public function getComment(): BufferInterface |
|
219
|
|
|
{ |
|
220
|
|
|
return $this->comment; |
|
221
|
|
|
} |
|
222
|
|
|
|
|
223
|
|
|
/** |
|
224
|
|
|
* @return BufferInterface |
|
225
|
|
|
*/ |
|
226
|
|
|
public function getStatusBar(): BufferInterface |
|
227
|
|
|
{ |
|
228
|
|
|
return $this->statusBar; |
|
229
|
|
|
} |
|
230
|
|
|
|
|
231
|
|
|
/** |
|
232
|
|
|
* @see \BitWasp\Bitcoin\SerializableInterface::getBuffer() |
|
233
|
|
|
* @return BufferInterface |
|
234
|
|
|
*/ |
|
235
|
|
|
public function getBuffer(): BufferInterface |
|
236
|
|
|
{ |
|
237
|
|
|
return (new AlertDetailSerializer())->serialize($this); |
|
238
|
|
|
} |
|
239
|
|
|
} |
|
240
|
|
|
|