11use {
22 crate :: {
3- chain:: reader:: {
4- BlockNumber ,
5- BlockStatus ,
6- EntropyReader ,
7- } ,
3+ chain:: reader:: { BlockNumber , BlockStatus , EntropyReader } ,
84 state:: HashChainState ,
95 } ,
106 anyhow:: Result ,
117 axum:: {
128 body:: Body ,
139 http:: StatusCode ,
14- response:: {
15- IntoResponse ,
16- Response ,
17- } ,
10+ response:: { IntoResponse , Response } ,
1811 routing:: get,
1912 Router ,
2013 } ,
2114 ethers:: core:: types:: Address ,
2215 prometheus_client:: {
2316 encoding:: EncodeLabelSet ,
24- metrics:: {
25- counter:: Counter ,
26- family:: Family ,
27- } ,
17+ metrics:: { counter:: Counter , family:: Family } ,
2818 registry:: Registry ,
2919 } ,
30- std:: {
31- collections:: HashMap ,
32- sync:: Arc ,
33- } ,
20+ std:: { collections:: HashMap , sync:: Arc } ,
3421 tokio:: sync:: RwLock ,
3522 url:: Url ,
3623} ;
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:: * } ;
4525
4626mod chain_ids;
4727mod index;
@@ -99,16 +79,16 @@ impl ApiState {
9979#[ derive( Clone ) ]
10080pub struct BlockchainState {
10181 /// The chain id for this blockchain, useful for logging
102- pub id : ChainId ,
82+ pub id : ChainId ,
10383 /// The hash chain(s) required to serve random numbers for this blockchain
104- pub state : Arc < HashChainState > ,
84+ pub state : Arc < HashChainState > ,
10585 /// The contract that the server is fulfilling requests for.
106- pub contract : Arc < dyn EntropyReader > ,
86+ pub contract : Arc < dyn EntropyReader > ,
10787 /// The address of the provider that this server is operating for.
108- pub provider_address : Address ,
88+ pub provider_address : Address ,
10989 /// The server will wait for this many block confirmations of a request before revealing
11090 /// the random number.
111- pub reveal_delay_blocks : BlockNumber ,
91+ pub reveal_delay_blocks : BlockNumber ,
11292 /// The BlockStatus of the block that is considered to be confirmed on the blockchain.
11393 /// For eg., Finalized, Safe
11494 pub confirmed_block_status : BlockStatus ,
@@ -194,35 +174,16 @@ pub fn get_register_uri(base_uri: &str, chain_id: &str) -> Result<String> {
194174mod test {
195175 use {
196176 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 } ,
213180 } ,
214181 axum:: http:: StatusCode ,
215- axum_test:: {
216- TestResponse ,
217- TestServer ,
218- } ,
182+ axum_test:: { TestResponse , TestServer } ,
219183 ethers:: prelude:: Address ,
220184 lazy_static:: lazy_static,
221185 prometheus_client:: registry:: Registry ,
222- std:: {
223- collections:: HashMap ,
224- sync:: Arc ,
225- } ,
186+ std:: { collections:: HashMap , sync:: Arc } ,
226187 tokio:: sync:: RwLock ,
227188 } ;
228189
@@ -245,11 +206,11 @@ mod test {
245206 let eth_read = Arc :: new ( MockEntropyReader :: with_requests ( 10 , & [ ] ) ) ;
246207
247208 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 ,
253214 confirmed_block_status : BlockStatus :: Latest ,
254215 } ;
255216
@@ -258,11 +219,11 @@ mod test {
258219 let avax_read = Arc :: new ( MockEntropyReader :: with_requests ( 10 , & [ ] ) ) ;
259220
260221 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 ,
266227 confirmed_block_status : BlockStatus :: Latest ,
267228 } ;
268229
0 commit comments