1
1
use {
2
2
crate :: {
3
- chain:: reader:: {
4
- BlockNumber ,
5
- BlockStatus ,
6
- EntropyReader ,
7
- } ,
3
+ chain:: reader:: { BlockNumber , BlockStatus , EntropyReader } ,
8
4
state:: HashChainState ,
9
5
} ,
10
6
anyhow:: Result ,
11
7
axum:: {
12
8
body:: Body ,
13
9
http:: StatusCode ,
14
- response:: {
15
- IntoResponse ,
16
- Response ,
17
- } ,
10
+ response:: { IntoResponse , Response } ,
18
11
routing:: get,
19
12
Router ,
20
13
} ,
21
14
ethers:: core:: types:: Address ,
22
15
prometheus_client:: {
23
16
encoding:: EncodeLabelSet ,
24
- metrics:: {
25
- counter:: Counter ,
26
- family:: Family ,
27
- } ,
17
+ metrics:: { counter:: Counter , family:: Family } ,
28
18
registry:: Registry ,
29
19
} ,
30
- std:: {
31
- collections:: HashMap ,
32
- sync:: Arc ,
33
- } ,
20
+ std:: { collections:: HashMap , sync:: Arc } ,
34
21
tokio:: sync:: RwLock ,
35
22
url:: Url ,
36
23
} ;
37
- pub use {
38
- chain_ids:: * ,
39
- index:: * ,
40
- live:: * ,
41
- metrics:: * ,
42
- ready:: * ,
43
- revelation:: * ,
44
- } ;
24
+ pub use { chain_ids:: * , index:: * , live:: * , metrics:: * , ready:: * , revelation:: * } ;
45
25
46
26
mod chain_ids;
47
27
mod index;
@@ -99,16 +79,16 @@ impl ApiState {
99
79
#[ derive( Clone ) ]
100
80
pub struct BlockchainState {
101
81
/// The chain id for this blockchain, useful for logging
102
- pub id : ChainId ,
82
+ pub id : ChainId ,
103
83
/// The hash chain(s) required to serve random numbers for this blockchain
104
- pub state : Arc < HashChainState > ,
84
+ pub state : Arc < HashChainState > ,
105
85
/// The contract that the server is fulfilling requests for.
106
- pub contract : Arc < dyn EntropyReader > ,
86
+ pub contract : Arc < dyn EntropyReader > ,
107
87
/// The address of the provider that this server is operating for.
108
- pub provider_address : Address ,
88
+ pub provider_address : Address ,
109
89
/// The server will wait for this many block confirmations of a request before revealing
110
90
/// the random number.
111
- pub reveal_delay_blocks : BlockNumber ,
91
+ pub reveal_delay_blocks : BlockNumber ,
112
92
/// The BlockStatus of the block that is considered to be confirmed on the blockchain.
113
93
/// For eg., Finalized, Safe
114
94
pub confirmed_block_status : BlockStatus ,
@@ -194,35 +174,16 @@ pub fn get_register_uri(base_uri: &str, chain_id: &str) -> Result<String> {
194
174
mod test {
195
175
use {
196
176
crate :: {
197
- api:: {
198
- self ,
199
- ApiState ,
200
- BinaryEncoding ,
201
- Blob ,
202
- BlockchainState ,
203
- GetRandomValueResponse ,
204
- } ,
205
- chain:: reader:: {
206
- mock:: MockEntropyReader ,
207
- BlockStatus ,
208
- } ,
209
- state:: {
210
- HashChainState ,
211
- PebbleHashChain ,
212
- } ,
177
+ api:: { self , ApiState , BinaryEncoding , Blob , BlockchainState , GetRandomValueResponse } ,
178
+ chain:: reader:: { mock:: MockEntropyReader , BlockStatus } ,
179
+ state:: { HashChainState , PebbleHashChain } ,
213
180
} ,
214
181
axum:: http:: StatusCode ,
215
- axum_test:: {
216
- TestResponse ,
217
- TestServer ,
218
- } ,
182
+ axum_test:: { TestResponse , TestServer } ,
219
183
ethers:: prelude:: Address ,
220
184
lazy_static:: lazy_static,
221
185
prometheus_client:: registry:: Registry ,
222
- std:: {
223
- collections:: HashMap ,
224
- sync:: Arc ,
225
- } ,
186
+ std:: { collections:: HashMap , sync:: Arc } ,
226
187
tokio:: sync:: RwLock ,
227
188
} ;
228
189
@@ -245,11 +206,11 @@ mod test {
245
206
let eth_read = Arc :: new ( MockEntropyReader :: with_requests ( 10 , & [ ] ) ) ;
246
207
247
208
let eth_state = BlockchainState {
248
- id : "ethereum" . into ( ) ,
249
- state : ETH_CHAIN . clone ( ) ,
250
- contract : eth_read. clone ( ) ,
251
- provider_address : PROVIDER ,
252
- reveal_delay_blocks : 1 ,
209
+ id : "ethereum" . into ( ) ,
210
+ state : ETH_CHAIN . clone ( ) ,
211
+ contract : eth_read. clone ( ) ,
212
+ provider_address : PROVIDER ,
213
+ reveal_delay_blocks : 1 ,
253
214
confirmed_block_status : BlockStatus :: Latest ,
254
215
} ;
255
216
@@ -258,11 +219,11 @@ mod test {
258
219
let avax_read = Arc :: new ( MockEntropyReader :: with_requests ( 10 , & [ ] ) ) ;
259
220
260
221
let avax_state = BlockchainState {
261
- id : "avalanche" . into ( ) ,
262
- state : AVAX_CHAIN . clone ( ) ,
263
- contract : avax_read. clone ( ) ,
264
- provider_address : PROVIDER ,
265
- reveal_delay_blocks : 2 ,
222
+ id : "avalanche" . into ( ) ,
223
+ state : AVAX_CHAIN . clone ( ) ,
224
+ contract : avax_read. clone ( ) ,
225
+ provider_address : PROVIDER ,
226
+ reveal_delay_blocks : 2 ,
266
227
confirmed_block_status : BlockStatus :: Latest ,
267
228
} ;
268
229
0 commit comments