-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configure instant sealing for dev chains (#119)
* Add start_dev_node * Add start_dev_node to command Fix compile * Don't check relay chain for dev node * Correct chain spec Identify * Add instant finalize * Clean * Add tip * Fix CI * opt * format * Revert "Fix CI" This reverts commit 63ae56a8a4ff329a708de8ae7287b3a2133fac19. * Format Signed-off-by: Xavier Lau <[email protected]> * Remove redundant clone Signed-off-by: Xavier Lau <[email protected]> Co-authored-by: bear <[email protected]> Co-authored-by: fisher <[email protected]> Co-authored-by: Xavier Lau <[email protected]>
- Loading branch information
1 parent
1b9a5fc
commit ab8261a
Showing
6 changed files
with
324 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// This file is part of Darwinia. | ||
// | ||
// Copyright (C) 2018-2022 Darwinia Network | ||
// SPDX-License-Identifier: GPL-3.0 | ||
// | ||
// Darwinia is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Darwinia is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Darwinia. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
// substrate | ||
use sc_consensus::BlockImport; | ||
use sp_runtime::traits::Block as BlockT; | ||
|
||
pub struct InstantFinalizeBlockImport<I>(I); | ||
impl<I> InstantFinalizeBlockImport<I> { | ||
/// Create a new instance. | ||
pub fn new(inner: I) -> Self { | ||
Self(inner) | ||
} | ||
} | ||
#[async_trait::async_trait] | ||
impl<Block, I> BlockImport<Block> for InstantFinalizeBlockImport<I> | ||
where | ||
Block: BlockT, | ||
I: BlockImport<Block> + Send, | ||
{ | ||
type Error = I::Error; | ||
type Transaction = I::Transaction; | ||
|
||
async fn check_block( | ||
&mut self, | ||
block: sc_consensus::BlockCheckParams<Block>, | ||
) -> Result<sc_consensus::ImportResult, Self::Error> { | ||
self.0.check_block(block).await | ||
} | ||
|
||
async fn import_block( | ||
&mut self, | ||
mut block_import_params: sc_consensus::BlockImportParams<Block, Self::Transaction>, | ||
cache: std::collections::HashMap<sp_consensus::CacheKeyId, Vec<u8>>, | ||
) -> Result<sc_consensus::ImportResult, Self::Error> { | ||
block_import_params.finalized = true; | ||
self.0.import_block(block_import_params, cache).await | ||
} | ||
} |
Oops, something went wrong.