@@ -26,33 +26,39 @@ use crate::transaction_manager::TransactionManagerConfig;
2626/// Current state of the provider, where pending means: idle, between proposal/validation cycles.
2727#[ derive( Clone , Debug , Eq , PartialEq ) ]
2828pub enum ProviderState {
29- /// Provider is not read for proposing or validating. Use start_block to transition to Propose
29+ /// Provider has not been initialized yet, needs to do bootstrapping at least once.
30+ Uninitialized ,
31+ // TODO(guyn): in a upcoming PR, bootstrap will be available not only on startup.
32+ /// Provider is catching up using sync. Only happens on startup.
33+ Bootstrap ,
34+ /// Provider is not ready for proposing or validating. Use start_block to transition to Propose
3035 /// or Validate.
3136 Pending ,
32- /// Provider is ready for proposing. Use commit_block to finish and return to Pending.
37+ /// Provider is ready for proposing. Use get_txs to get what you need for a new proposal. Use
38+ /// commit_block to finish and return to Pending.
3339 Propose ,
34- /// Provider is catching up using sync. Only happens on startup.
35- Bootstrap ,
36- /// Provider is ready for validating. Use validate to validate a transaction.
40+ /// Provider is ready for validating. Use validate to validate a transaction. Use commit_block
41+ /// to finish and return to Pending.
3742 Validate ,
3843}
3944
4045impl ProviderState {
4146 pub fn as_str ( & self ) -> & str {
4247 match self {
48+ ProviderState :: Uninitialized => "Uninitialized" ,
4349 ProviderState :: Pending => "Pending" ,
4450 ProviderState :: Propose => "Propose" ,
4551 ProviderState :: Bootstrap => "Bootstrap" ,
4652 ProviderState :: Validate => "Validate" ,
4753 }
4854 }
4955
50- pub fn is_bootstrapping ( & self ) -> bool {
51- if let ProviderState :: Bootstrap = self {
52- return true ;
53- }
56+ pub fn uninitialized ( & self ) -> bool {
57+ matches ! ( self , ProviderState :: Uninitialized )
58+ }
5459
55- false
60+ pub fn is_bootstrapping ( & self ) -> bool {
61+ matches ! ( self , ProviderState :: Bootstrap )
5662 }
5763
5864 fn transition_to_pending ( & self ) -> ProviderState {
0 commit comments