Adds --no-validator CLI flag (#3348)

* Implement `is_validator` for offchain-workers

* Introduce `--no-validator` flag

* Don't run babe/grandpa/im-online when `--no-validator` is given

* Fixes compilation

* Bump spec version

* Improve error handling in executor

* Add missing extern function

* Revert making error public

* Remove `--no-validator` CLI
This commit is contained in:
Bastian Köcher
2019-08-09 14:24:18 +02:00
committed by GitHub
parent b4b53cbb6e
commit c824c959d7
18 changed files with 97 additions and 28 deletions
+10
View File
@@ -432,6 +432,12 @@ pub mod ext {
// Offchain-worker Context
//================================
/// Returns if the local node is a potential validator.
///
/// - `1` == `true`
/// - `0` == `false`
fn ext_is_validator() -> u32;
/// Submit transaction.
///
/// # Returns
@@ -964,6 +970,10 @@ impl CryptoApi for () {
}
impl OffchainApi for () {
fn is_validator() -> bool {
unsafe { ext_is_validator.get()() == 1 }
}
fn submit_transaction<T: codec::Encode>(data: &T) -> Result<(), ()> {
let encoded_data = codec::Encode::encode(data);
let ret = unsafe {