Skip to content

Commit e2eb816

Browse files
authored
Allow disable FrontierBlockImport (#127)
* allow to disable index * allow disable ethereum indexing
1 parent 34ed45f commit e2eb816

2 files changed

Lines changed: 25 additions & 18 deletions

File tree

consensus/src/lib.rs

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ impl std::convert::From<Error> for ConsensusError {
6060
pub struct FrontierBlockImport<B: BlockT, I, C> {
6161
inner: I,
6262
client: Arc<C>,
63+
enabled: bool,
6364
_marker: PhantomData<B>,
6465
}
6566

@@ -68,6 +69,7 @@ impl<Block: BlockT, I: Clone + BlockImport<Block>, C> Clone for FrontierBlockImp
6869
FrontierBlockImport {
6970
inner: self.inner.clone(),
7071
client: self.client.clone(),
72+
enabled: self.enabled,
7173
_marker: PhantomData,
7274
}
7375
}
@@ -83,10 +85,12 @@ impl<B, I, C> FrontierBlockImport<B, I, C> where
8385
pub fn new(
8486
inner: I,
8587
client: Arc<C>,
88+
enabled: bool,
8689
) -> Self {
8790
Self {
8891
inner,
8992
client,
93+
enabled,
9094
_marker: PhantomData,
9195
}
9296
}
@@ -122,23 +126,25 @@ impl<B, I, C> BlockImport<B> for FrontierBlockImport<B, I, C> where
122126
)
123127
}
124128

125-
let log = find_frontier_log::<B>(&block.header)?;
126-
let hash = block.post_hash();
127-
128-
match log {
129-
ConsensusLog::EndBlock {
130-
block_hash, transaction_hashes,
131-
} => {
132-
aux_schema::write_block_hash(block_hash, hash, insert_closure!());
133-
134-
for (index, transaction_hash) in transaction_hashes.into_iter().enumerate() {
135-
aux_schema::write_transaction_metadata(
136-
transaction_hash,
137-
(block_hash, index as u32),
138-
insert_closure!(),
139-
);
140-
}
141-
},
129+
if self.enabled {
130+
let log = find_frontier_log::<B>(&block.header)?;
131+
let hash = block.post_hash();
132+
133+
match log {
134+
ConsensusLog::EndBlock {
135+
block_hash, transaction_hashes,
136+
} => {
137+
aux_schema::write_block_hash(block_hash, hash, insert_closure!());
138+
139+
for (index, transaction_hash) in transaction_hashes.into_iter().enumerate() {
140+
aux_schema::write_transaction_metadata(
141+
transaction_hash,
142+
(block_hash, index as u32),
143+
insert_closure!(),
144+
);
145+
}
146+
},
147+
}
142148
}
143149

144150
self.inner.import_block(block, new_cache).map_err(Into::into)

template/node/src/service.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ pub fn new_partial(config: &Configuration, manual_seal: bool) -> Result<
9090

9191
let frontier_block_import = FrontierBlockImport::new(
9292
grandpa_block_import.clone(),
93-
client.clone()
93+
client.clone(),
94+
true
9495
);
9596

9697
let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(

0 commit comments

Comments
 (0)