@@ -9,7 +9,7 @@ use cuprate_types::{
9
9
Chain ,
10
10
} ;
11
11
12
- use crate :: { Database , ExtendedConsensusError } ;
12
+ use crate :: { Database , ContextCacheError } ;
13
13
14
14
/// The default amount of hard-fork votes to track to decide on activation of a hard-fork.
15
15
///
@@ -21,9 +21,9 @@ const DEFAULT_WINDOW_SIZE: usize = 10080; // supermajority window check length -
21
21
#[ derive( Debug , Clone , Copy , Eq , PartialEq ) ]
22
22
pub struct HardForkConfig {
23
23
/// The network we are on.
24
- pub ( crate ) info : HFsInfo ,
24
+ pub info : HFsInfo ,
25
25
/// The amount of votes we are taking into account to decide on a fork activation.
26
- pub ( crate ) window : usize ,
26
+ pub window : usize ,
27
27
}
28
28
29
29
impl HardForkConfig {
@@ -54,17 +54,17 @@ impl HardForkConfig {
54
54
55
55
/// A struct that keeps track of the current hard-fork and current votes.
56
56
#[ derive( Debug , Clone , Eq , PartialEq ) ]
57
- pub ( crate ) struct HardForkState {
57
+ pub struct HardForkState {
58
58
/// The current active hard-fork.
59
- pub ( crate ) current_hardfork : HardFork ,
59
+ pub current_hardfork : HardFork ,
60
60
61
61
/// The hard-fork config.
62
- pub ( crate ) config : HardForkConfig ,
62
+ pub config : HardForkConfig ,
63
63
/// The votes in the current window.
64
- pub ( crate ) votes : HFVotes ,
64
+ pub votes : HFVotes ,
65
65
66
66
/// The last block height accounted for.
67
- pub ( crate ) last_height : usize ,
67
+ pub last_height : usize ,
68
68
}
69
69
70
70
impl HardForkState {
@@ -74,7 +74,7 @@ impl HardForkState {
74
74
chain_height : usize ,
75
75
config : HardForkConfig ,
76
76
mut database : D ,
77
- ) -> Result < Self , ExtendedConsensusError > {
77
+ ) -> Result < Self , ContextCacheError > {
78
78
tracing:: info!( "Initializing hard-fork state this may take a while." ) ;
79
79
80
80
let block_start = chain_height. saturating_sub ( config. window ) ;
@@ -122,11 +122,11 @@ impl HardForkState {
122
122
/// # Invariant
123
123
///
124
124
/// This _must_ only be used on a main-chain cache.
125
- pub ( crate ) async fn pop_blocks_main_chain < D : Database + Clone > (
125
+ pub async fn pop_blocks_main_chain < D : Database + Clone > (
126
126
& mut self ,
127
127
numb_blocks : usize ,
128
128
database : D ,
129
- ) -> Result < ( ) , ExtendedConsensusError > {
129
+ ) -> Result < ( ) , ContextCacheError > {
130
130
let Some ( retained_blocks) = self . votes . total_votes ( ) . checked_sub ( self . config . window ) else {
131
131
* self = Self :: init_from_chain_height (
132
132
self . last_height + 1 - numb_blocks,
@@ -159,7 +159,7 @@ impl HardForkState {
159
159
}
160
160
161
161
/// Add a new block to the cache.
162
- pub ( crate ) fn new_block ( & mut self , vote : HardFork , height : usize ) {
162
+ pub fn new_block ( & mut self , vote : HardFork , height : usize ) {
163
163
// We don't _need_ to take in `height` but it's for safety, so we don't silently loose track
164
164
// of blocks.
165
165
assert_eq ! ( self . last_height + 1 , height) ;
@@ -194,7 +194,7 @@ impl HardForkState {
194
194
}
195
195
196
196
/// Returns the current hard-fork.
197
- pub ( crate ) const fn current_hardfork ( & self ) -> HardFork {
197
+ pub const fn current_hardfork ( & self ) -> HardFork {
198
198
self . current_hardfork
199
199
}
200
200
}
@@ -205,7 +205,7 @@ async fn get_votes_in_range<D: Database>(
205
205
database : D ,
206
206
block_heights : Range < usize > ,
207
207
window_size : usize ,
208
- ) -> Result < HFVotes , ExtendedConsensusError > {
208
+ ) -> Result < HFVotes , ContextCacheError > {
209
209
let mut votes = HFVotes :: new ( window_size) ;
210
210
211
211
let BlockchainResponse :: BlockExtendedHeaderInRange ( vote_list) = database
0 commit comments