|
2 | 2 | crate::{
|
3 | 3 | chain::reader::{
|
4 | 4 | BlockNumber,
|
| 5 | + BlockStatus, |
5 | 6 | EntropyReader,
|
6 | 7 | },
|
7 | 8 | state::HashChainState,
|
@@ -73,14 +74,17 @@ impl ApiState {
|
73 | 74 | #[derive(Clone)]
|
74 | 75 | pub struct BlockchainState {
|
75 | 76 | /// The hash chain(s) required to serve random numbers for this blockchain
|
76 |
| - pub state: Arc<HashChainState>, |
| 77 | + pub state: Arc<HashChainState>, |
77 | 78 | /// The contract that the server is fulfilling requests for.
|
78 |
| - pub contract: Arc<dyn EntropyReader>, |
| 79 | + pub contract: Arc<dyn EntropyReader>, |
79 | 80 | /// The address of the provider that this server is operating for.
|
80 |
| - pub provider_address: Address, |
| 81 | + pub provider_address: Address, |
81 | 82 | /// The server will wait for this many block confirmations of a request before revealing
|
82 | 83 | /// the random number.
|
83 |
| - pub reveal_delay_blocks: BlockNumber, |
| 84 | + pub reveal_delay_blocks: BlockNumber, |
| 85 | + /// The BlockStatus of the block that is considered to be confirmed on the blockchain. |
| 86 | + /// For eg., Finalized, Safe |
| 87 | + pub confirmed_block_status: BlockStatus, |
84 | 88 | }
|
85 | 89 |
|
86 | 90 | pub struct Metrics {
|
@@ -203,7 +207,10 @@ mod test {
|
203 | 207 | BlockchainState,
|
204 | 208 | GetRandomValueResponse,
|
205 | 209 | },
|
206 |
| - chain::reader::mock::MockEntropyReader, |
| 210 | + chain::reader::{ |
| 211 | + mock::MockEntropyReader, |
| 212 | + BlockStatus, |
| 213 | + }, |
207 | 214 | state::{
|
208 | 215 | HashChainState,
|
209 | 216 | PebbleHashChain,
|
@@ -238,19 +245,21 @@ mod test {
|
238 | 245 | let eth_read = Arc::new(MockEntropyReader::with_requests(10, &[]));
|
239 | 246 |
|
240 | 247 | let eth_state = BlockchainState {
|
241 |
| - state: ETH_CHAIN.clone(), |
242 |
| - contract: eth_read.clone(), |
243 |
| - provider_address: PROVIDER, |
244 |
| - reveal_delay_blocks: 1, |
| 248 | + state: ETH_CHAIN.clone(), |
| 249 | + contract: eth_read.clone(), |
| 250 | + provider_address: PROVIDER, |
| 251 | + reveal_delay_blocks: 1, |
| 252 | + confirmed_block_status: BlockStatus::Latest, |
245 | 253 | };
|
246 | 254 |
|
247 | 255 | let avax_read = Arc::new(MockEntropyReader::with_requests(10, &[]));
|
248 | 256 |
|
249 | 257 | let avax_state = BlockchainState {
|
250 |
| - state: AVAX_CHAIN.clone(), |
251 |
| - contract: avax_read.clone(), |
252 |
| - provider_address: PROVIDER, |
253 |
| - reveal_delay_blocks: 2, |
| 258 | + state: AVAX_CHAIN.clone(), |
| 259 | + contract: avax_read.clone(), |
| 260 | + provider_address: PROVIDER, |
| 261 | + reveal_delay_blocks: 2, |
| 262 | + confirmed_block_status: BlockStatus::Latest, |
254 | 263 | };
|
255 | 264 |
|
256 | 265 | let api_state = ApiState::new(&[
|
|
0 commit comments