mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 10:01:17 +00:00
Off-chain indexing is independent from workers (#8659)
* Pff-chain indexing is independent from worker.
* Remove unauthorized changes.
* 🤦
This commit is contained in:
@@ -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,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>) {
|
||||
|
||||
Reference in New Issue
Block a user