1 | <?php |
||
14 | class ConnectionParams |
||
15 | { |
||
16 | protected $defaultUserAgent = 'bitcoin-php'; |
||
17 | protected $defaultProtocolVersion = '70000'; |
||
18 | protected $defaultTxRelay = false; |
||
19 | protected $defaultBlockHeight = '0'; |
||
20 | protected $defaultLocalIp = '0.0.0.0'; |
||
21 | protected $defaultLocalPort = '0'; |
||
22 | |||
23 | /** |
||
24 | * @var int |
||
25 | */ |
||
26 | private $protocolVersion; |
||
27 | |||
28 | /** |
||
29 | * @var int |
||
30 | */ |
||
31 | private $timestamp; |
||
32 | |||
33 | /** |
||
34 | * @var bool |
||
35 | */ |
||
36 | private $txRelay; |
||
37 | |||
38 | /** |
||
39 | * @var callable |
||
40 | */ |
||
41 | private $bestBlockHeightCallback; |
||
42 | |||
43 | /** |
||
44 | * @var int |
||
45 | */ |
||
46 | private $bestBlockHeight; |
||
47 | |||
48 | /** |
||
49 | * @var string |
||
50 | */ |
||
51 | private $localIp; |
||
52 | |||
53 | /** |
||
54 | * @var int |
||
55 | */ |
||
56 | private $localPort; |
||
57 | |||
58 | /** |
||
59 | * @var int |
||
60 | */ |
||
61 | private $localServices; |
||
62 | |||
63 | /** |
||
64 | * @var string |
||
65 | */ |
||
66 | private $userAgent; |
||
67 | |||
68 | /** |
||
69 | * @var int |
||
70 | */ |
||
71 | private $requiredServices = 0; |
||
72 | |||
73 | /** |
||
74 | * @param bool $optRelay |
||
75 | * @return $this |
||
76 | */ |
||
77 | 6 | public function requestTxRelay($optRelay = true) |
|
78 | { |
||
79 | 6 | if (!is_bool($optRelay)) { |
|
80 | 3 | throw new \InvalidArgumentException('Invalid txrelay setting, must be a boolean'); |
|
81 | } |
||
82 | |||
83 | 3 | $this->txRelay = $optRelay; |
|
84 | 3 | return $this; |
|
85 | } |
||
86 | |||
87 | /** |
||
88 | * @param int $blockHeight |
||
89 | * @return $this |
||
90 | */ |
||
91 | 6 | public function setBestBlockHeight($blockHeight) |
|
92 | { |
||
93 | 6 | $this->bestBlockHeight = $blockHeight; |
|
94 | 6 | return $this; |
|
95 | } |
||
96 | |||
97 | /** |
||
98 | * @param callable $callable |
||
99 | * @return $this |
||
100 | */ |
||
101 | 3 | public function setBestBlockHeightCallback(callable $callable) |
|
102 | { |
||
103 | 3 | $this->bestBlockHeightCallback = $callable; |
|
104 | 3 | return $this; |
|
105 | } |
||
106 | |||
107 | /** |
||
108 | * @param int $version |
||
109 | * @return $this |
||
110 | */ |
||
111 | 3 | public function setProtocolVersion($version) |
|
112 | { |
||
113 | 3 | $this->protocolVersion = $version; |
|
114 | 3 | return $this; |
|
115 | } |
||
116 | |||
117 | /** |
||
118 | * @param IpInterface $ip |
||
119 | * @return $this |
||
120 | */ |
||
121 | 9 | public function setLocalIp(IpInterface $ip) |
|
122 | { |
||
123 | 9 | $this->localIp = $ip; |
|
|
|||
124 | 9 | return $this; |
|
125 | } |
||
126 | |||
127 | /** |
||
128 | * @param int $port |
||
129 | * @return $this |
||
130 | */ |
||
131 | 6 | public function setLocalPort($port) |
|
132 | { |
||
133 | 6 | $this->localPort = $port; |
|
134 | 6 | return $this; |
|
135 | } |
||
136 | |||
137 | /** |
||
138 | * @param int $services |
||
139 | * @return $this |
||
140 | */ |
||
141 | 6 | public function setLocalServices($services) |
|
142 | { |
||
143 | 6 | $this->localServices = $services; |
|
144 | 6 | return $this; |
|
145 | } |
||
146 | |||
147 | /** |
||
148 | * @param NetworkAddressInterface $networkAddress |
||
149 | * @return $this |
||
150 | */ |
||
151 | 3 | public function setLocalNetAddr(NetworkAddressInterface $networkAddress) |
|
152 | { |
||
153 | 2 | return $this |
|
154 | 3 | ->setLocalIp($networkAddress->getIp()) |
|
155 | 3 | ->setLocalPort($networkAddress->getPort()) |
|
156 | 3 | ->setLocalServices($networkAddress->getServices()); |
|
157 | } |
||
158 | |||
159 | /** |
||
160 | * @param int $timestamp |
||
161 | * @return $this |
||
162 | */ |
||
163 | 3 | public function setTimestamp($timestamp) |
|
164 | { |
||
165 | 3 | $this->timestamp = $timestamp; |
|
166 | 3 | return $this; |
|
167 | } |
||
168 | |||
169 | /** |
||
170 | * @param int $services |
||
171 | * @return $this |
||
172 | */ |
||
173 | public function setRequiredServices($services) |
||
174 | { |
||
175 | $this->requiredServices = $services; |
||
176 | return $this; |
||
177 | } |
||
178 | |||
179 | /** |
||
180 | * @return int |
||
181 | */ |
||
182 | 9 | public function getRequiredServices() |
|
186 | |||
187 | /** |
||
188 | * @param string $string |
||
189 | * @return $this |
||
190 | */ |
||
191 | 6 | public function setUserAgent($string) |
|
192 | { |
||
193 | 6 | if (!is_string($string)) { |
|
194 | 3 | throw new \InvalidArgumentException('User agent must be a string'); |
|
195 | } |
||
196 | |||
200 | |||
201 | /** |
||
202 | * @param MsgFactory $messageFactory |
||
203 | * @param NetworkAddressInterface $remoteAddress |
||
204 | * @return Version |
||
205 | */ |
||
206 | 45 | public function produceVersion(MsgFactory $messageFactory, NetworkAddressInterface $remoteAddress) |
|
232 | } |
||
233 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..