1
1
//! This module contains the global state of the application.
2
2
3
3
use {
4
- self :: cache:: CacheState ,
4
+ self :: {
5
+ benchmarks:: BenchmarksState ,
6
+ cache:: CacheState ,
7
+ } ,
5
8
crate :: {
6
9
aggregate:: {
7
10
AggregateState ,
@@ -29,10 +32,12 @@ pub mod benchmarks;
29
32
pub mod cache;
30
33
31
34
pub struct State {
32
- /// Storage is a short-lived cache of the state of all the updates that have been passed to the
33
- /// store.
35
+ /// State for the `Cache` service for short-lived storage of updates.
34
36
pub cache : CacheState ,
35
37
38
+ /// State for the `Benchmarks` service for looking up historical updates.
39
+ pub benchmarks : BenchmarksState ,
40
+
36
41
/// Sequence numbers of lately observed Vaas. Store uses this set
37
42
/// to ignore the previously observed Vaas as a performance boost.
38
43
pub observed_vaa_seqs : RwLock < BTreeSet < u64 > > ,
@@ -46,9 +51,6 @@ pub struct State {
46
51
/// The aggregate module state.
47
52
pub aggregate_state : RwLock < AggregateState > ,
48
53
49
- /// Benchmarks endpoint
50
- pub benchmarks_endpoint : Option < Url > ,
51
-
52
54
/// Metrics registry
53
55
pub metrics_registry : RwLock < Registry > ,
54
56
@@ -64,13 +66,13 @@ impl State {
64
66
) -> Arc < Self > {
65
67
let mut metrics_registry = Registry :: default ( ) ;
66
68
Arc :: new ( Self {
67
- cache : CacheState :: new ( cache_size) ,
68
- observed_vaa_seqs : RwLock :: new ( Default :: default ( ) ) ,
69
- guardian_set : RwLock :: new ( Default :: default ( ) ) ,
70
- api_update_tx : update_tx ,
71
- aggregate_state : RwLock :: new ( AggregateState :: new ( & mut metrics_registry ) ) ,
72
- benchmarks_endpoint ,
73
- metrics_registry : RwLock :: new ( metrics_registry) ,
69
+ cache : CacheState :: new ( cache_size) ,
70
+ benchmarks : BenchmarksState :: new ( benchmarks_endpoint ) ,
71
+ observed_vaa_seqs : RwLock :: new ( Default :: default ( ) ) ,
72
+ guardian_set : RwLock :: new ( Default :: default ( ) ) ,
73
+ api_update_tx : update_tx ,
74
+ aggregate_state : RwLock :: new ( AggregateState :: new ( & mut metrics_registry ) ) ,
75
+ metrics_registry : RwLock :: new ( metrics_registry) ,
74
76
price_feeds_metadata : RwLock :: new ( Default :: default ( ) ) ,
75
77
} )
76
78
}
0 commit comments