@@ -137,7 +137,12 @@ impl<T> SyncOracle for Arc<T> where T: ?Sized, for<'r> &'r T: SyncOracle {
137137/// at the given block.
138138pub trait CanAuthorWith < Block : BlockT > {
139139 /// See trait docs for more information.
140- fn can_author_with ( & self , at : & BlockId < Block > ) -> bool ;
140+ ///
141+ /// # Return
142+ ///
143+ /// - Returns `Ok(())` when authoring is supported.
144+ /// - Returns `Err(_)` when authoring is not supported.
145+ fn can_author_with ( & self , at : & BlockId < Block > ) -> Result < ( ) , String > ;
141146}
142147
143148/// Checks if the node can author blocks by using
@@ -154,18 +159,15 @@ impl<T> CanAuthorWithNativeVersion<T> {
154159impl < T : runtime_version:: GetRuntimeVersion < Block > , Block : BlockT > CanAuthorWith < Block >
155160 for CanAuthorWithNativeVersion < T >
156161{
157- fn can_author_with ( & self , at : & BlockId < Block > ) -> bool {
162+ fn can_author_with ( & self , at : & BlockId < Block > ) -> Result < ( ) , String > {
158163 match self . 0 . runtime_version ( at) {
159164 Ok ( version) => self . 0 . native_version ( ) . can_author_with ( & version) ,
160165 Err ( e) => {
161- error ! (
162- target: "CanAuthorWithNativeVersion" ,
166+ Err ( format ! (
163167 "Failed to get runtime version at `{}` and will disable authoring. Error: {}" ,
164168 at,
165169 e,
166- ) ;
167-
168- false
170+ ) )
169171 }
170172 }
171173 }
@@ -175,7 +177,7 @@ impl<T: runtime_version::GetRuntimeVersion<Block>, Block: BlockT> CanAuthorWith<
175177pub struct AlwaysCanAuthor ;
176178
177179impl < Block : BlockT > CanAuthorWith < Block > for AlwaysCanAuthor {
178- fn can_author_with ( & self , _: & BlockId < Block > ) -> bool {
179- true
180+ fn can_author_with ( & self , _: & BlockId < Block > ) -> Result < ( ) , String > {
181+ Ok ( ( ) )
180182 }
181183}
0 commit comments