Off-chain indexing is independent from workers (#8659)

* Pff-chain indexing is independent from worker.

* Remove unauthorized changes.

* 🤦
This commit is contained in:
Tomasz Drwięga
2021-04-22 23:37:03 +02:00
committed by GitHub
parent 166568b029
commit f7ed5a2481
2 changed files with 14 additions and 11 deletions
@@ -23,14 +23,13 @@
//! targeted at handling input parameter parsing providing
//! a reasonable abstraction.
use structopt::StructOpt;
use sc_service::config::OffchainWorkerConfig;
use sc_network::config::Role;
use sc_service::config::OffchainWorkerConfig;
use structopt::StructOpt;
use crate::error;
use crate::OffchainWorkerEnabled;
/// Offchain worker related parameters.
#[derive(Debug, StructOpt)]
pub struct OffchainWorkerParams {
@@ -59,11 +58,7 @@ pub struct OffchainWorkerParams {
impl OffchainWorkerParams {
/// Load spec to `Configuration` from `OffchainWorkerParams` and spec factory.
pub fn offchain_worker(
&self,
role: &Role,
) -> error::Result<OffchainWorkerConfig>
{
pub fn offchain_worker(&self, role: &Role) -> error::Result<OffchainWorkerConfig> {
let enabled = match (&self.enabled, role) {
(OffchainWorkerEnabled::WhenValidating, Role::Authority { .. }) => true,
(OffchainWorkerEnabled::Always, _) => true,
@@ -71,8 +66,10 @@ impl OffchainWorkerParams {
(OffchainWorkerEnabled::WhenValidating, _) => false,
};
let indexing_enabled = enabled && self.indexing_enabled;
Ok(OffchainWorkerConfig { enabled, indexing_enabled })
let indexing_enabled = self.indexing_enabled;
Ok(OffchainWorkerConfig {
enabled,
indexing_enabled,
})
}
}
+6
View File
@@ -699,7 +699,9 @@ pub struct BlockImportOperation<Block: BlockT> {
impl<Block: BlockT> BlockImportOperation<Block> {
fn apply_offchain(&mut self, transaction: &mut Transaction<DbHash>) {
let mut count = 0;
for ((prefix, key), value_operation) in self.offchain_storage_updates.drain(..) {
count += 1;
let key = crate::offchain::concatenate_prefix_and_key(&prefix, &key);
match value_operation {
OffchainOverlayedChange::SetValue(val) =>
@@ -708,6 +710,10 @@ impl<Block: BlockT> BlockImportOperation<Block> {
transaction.remove(columns::OFFCHAIN, &key),
}
}
if count > 0 {
log::debug!(target: "sc_offchain", "Applied {} offchain indexing changes.", count);
}
}
fn apply_aux(&mut self, transaction: &mut Transaction<DbHash>) {