Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/blockchain/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl BlockChain {
let header = block.header_view();
let hash = header.hash();

ctrace!(BLOCKCHAIN, "Inserting bootstrap block #{}({}) to the blockchain.", header.number(), hash);
ctrace!(BLOCKCHAIN, "Inserting floating block #{}({}) to the blockchain.", header.number(), hash);

if self.is_known(&hash) {
cdebug!(BLOCKCHAIN, "Block #{}({}) is already known.", header.number(), hash);
Expand Down
6 changes: 3 additions & 3 deletions core/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl Client {

/// This is triggered by a message coming from a header queue when the header is ready for insertion
pub fn import_verified_headers(&self) -> usize {
self.importer.import_verified_headers(self)
self.importer.import_verified_headers_from_queue(self)
}

/// This is triggered by a message coming from a block queue when the block is ready for insertion
Expand Down Expand Up @@ -445,7 +445,7 @@ impl ImportBlock for Client {
self.importer.force_update_best_block(hash, self)
}

fn import_closed_block(&self, block: &ClosedBlock) -> ImportResult {
fn import_generated_block(&self, block: &ClosedBlock) -> ImportResult {
let h = block.header().hash();
let update_result = {
// scope for self.import_lock
Expand All @@ -455,7 +455,7 @@ impl ImportBlock for Client {
let block_data = block.rlp_bytes();
let header = block.header();

self.importer.import_headers(vec![header], self, &import_lock);
self.importer.import_verified_headers(vec![header], self, &import_lock);

let update_result = self.importer.commit_block(block, header, &block_data, self);
cinfo!(CLIENT, "Imported closed block #{} ({})", number, h);
Expand Down
8 changes: 4 additions & 4 deletions core/src/client/importer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl Importer {

{
let headers: Vec<_> = blocks.iter().map(|block| &block.header).collect();
self.import_headers(headers, client, &import_lock);
self.import_verified_headers(headers, client, &import_lock);
}

for block in blocks {
Expand Down Expand Up @@ -255,14 +255,14 @@ impl Importer {
}

/// This is triggered by a message coming from a header queue when the header is ready for insertion
pub fn import_verified_headers(&self, client: &Client) -> usize {
pub fn import_verified_headers_from_queue(&self, client: &Client) -> usize {
const MAX_HEADERS_TO_IMPORT: usize = 1_000;
let lock = self.import_lock.lock();
let headers = self.header_queue.drain(MAX_HEADERS_TO_IMPORT);
self.import_headers(&headers, client, &lock)
self.import_verified_headers(&headers, client, &lock)
}

pub fn import_headers<'a>(
pub fn import_verified_headers<'a>(
&'a self,
headers: impl IntoIterator<Item = &'a Header>,
client: &Client,
Expand Down
6 changes: 4 additions & 2 deletions core/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,19 @@ pub trait ImportBlock {

/// Import a trusted header into the blockchain
/// Trusted header doesn't go through any verifications and doesn't update the best header
/// The trusted header may not have parent.
fn import_trusted_header(&self, header: Header) -> Result<BlockHash, BlockImportError>;

/// Import a trusted block into the blockchain
/// Trusted block doesn't go through any verifications and doesn't update the best block
/// The trusted block may not have parent.
fn import_trusted_block(&self, block: &Block) -> Result<BlockHash, BlockImportError>;

/// Forcefully update the best block
fn force_update_best_block(&self, hash: &BlockHash);

/// Import closed block. Skips all verifications.
fn import_closed_block(&self, block: &ClosedBlock) -> ImportResult;
/// Import closed block. Skips all verifications. This block is generated by this instance.
fn import_generated_block(&self, block: &ClosedBlock) -> ImportResult;

/// Set reseal min timer as reseal_min_period, for creating blocks with transactions which are pending because of reseal_min_period
fn set_min_timer(&self);
Expand Down
2 changes: 1 addition & 1 deletion core/src/client/test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ impl ImportBlock for TestBlockChainClient {
unimplemented!()
}

fn import_closed_block(&self, _block: &ClosedBlock) -> ImportResult {
fn import_generated_block(&self, _block: &ClosedBlock) -> ImportResult {
Ok(H256::default().into())
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/miner/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ impl Miner {
self.engine.proposal_generated(&block);
}

chain.import_closed_block(&block).is_ok()
chain.import_generated_block(&block).is_ok()
}

/// Are we allowed to do a non-mandatory reseal?
Expand Down