Fixups from review.
Reduce size of default extra-data. Introduce find_uncle_headers.
This commit is contained in:
parent
f2eae8bc50
commit
140711dd8a
@ -404,7 +404,7 @@ mod tests {
|
||||
let mut db_result = get_temp_journal_db();
|
||||
let mut db = db_result.take();
|
||||
engine.spec().ensure_db_good(&mut db);
|
||||
let b = OpenBlock::new(engine.deref(), db, &genesis_header, vec![genesis_header.hash()], Address::zero(), vec![]).close().seal(vec![]).unwrap();
|
||||
let b = OpenBlock::new(engine.deref(), db, &genesis_header, vec![genesis_header.hash()], Address::zero(), vec![]).close().seal(&engine, vec![]).unwrap();
|
||||
let orig_bytes = b.rlp_bytes();
|
||||
let orig_db = b.drain();
|
||||
|
||||
|
@ -455,7 +455,7 @@ mod tests {
|
||||
match duplicate_import {
|
||||
Err(e) => {
|
||||
match e {
|
||||
ImportError::AlreadyQueued => {},
|
||||
Error::Import(ImportError::AlreadyQueued) => {},
|
||||
_ => { panic!("must return AlreadyQueued error"); }
|
||||
}
|
||||
}
|
||||
|
@ -473,6 +473,12 @@ impl BlockChain {
|
||||
self.extras_db.write(batch).unwrap();
|
||||
}
|
||||
|
||||
/// Given a block's `parent`, find every block header which represents a valid uncle.
|
||||
pub fn find_uncle_headers(&self, _parent: &H256) -> Vec<Header> {
|
||||
// TODO
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
/// Get inserted block info which is critical to preapre extras updates.
|
||||
fn block_info(&self, block_bytes: &[u8]) -> BlockInfo {
|
||||
let block = BlockView::new(block_bytes);
|
||||
|
@ -418,7 +418,7 @@ impl Client {
|
||||
}
|
||||
}
|
||||
|
||||
/// Set the author that we will seal blocks as.
|
||||
/// Get the author that we will seal blocks as.
|
||||
pub fn author(&self) -> Address {
|
||||
self.author.read().unwrap().clone()
|
||||
}
|
||||
@ -428,7 +428,7 @@ impl Client {
|
||||
*self.author.write().unwrap() = author;
|
||||
}
|
||||
|
||||
/// Set the extra_data that we will seal blocks wuth.
|
||||
/// Get the extra_data that we will seal blocks wuth.
|
||||
pub fn extra_data(&self) -> Bytes {
|
||||
self.extra_data.read().unwrap().clone()
|
||||
}
|
||||
@ -441,16 +441,19 @@ impl Client {
|
||||
/// New chain head event. Restart mining operation.
|
||||
pub fn prepare_sealing(&self) {
|
||||
let h = self.chain.read().unwrap().best_block_hash();
|
||||
let b = OpenBlock::new(
|
||||
let mut b = OpenBlock::new(
|
||||
self.engine.deref().deref(),
|
||||
self.state_db.lock().unwrap().clone(),
|
||||
match self.chain.read().unwrap().block_header(&h) { Some(ref x) => x, None => {return;} },
|
||||
self.build_last_hashes(h),
|
||||
self.build_last_hashes(h.clone()),
|
||||
self.author(),
|
||||
self.extra_data()
|
||||
);
|
||||
// TODO: push uncles.
|
||||
|
||||
self.chain.read().unwrap().find_uncle_headers(&h).into_iter().foreach(|h| { b.push_uncle(h).unwrap(); });
|
||||
|
||||
// TODO: push transactions.
|
||||
|
||||
let b = b.close();
|
||||
trace!("Sealing: number={}, hash={}, diff={}", b.hash(), b.block().header().difficulty(), b.block().header().number());
|
||||
*self.sealing_block.lock().unwrap() = Some(b);
|
||||
|
@ -82,7 +82,7 @@ pub fn version_data() -> Bytes {
|
||||
u32::from_str(env!("CARGO_PKG_VERSION_PATCH")).unwrap();
|
||||
s.append(&v);
|
||||
s.append(&"Parity");
|
||||
s.append(&format!("rustc{}", rustc_version::version()));
|
||||
s.append(&Target::os());
|
||||
s.append(&format!("{}", rustc_version::version()));
|
||||
s.append(&&Target::os()[0..2]);
|
||||
s.out()
|
||||
}
|
Loading…
Reference in New Issue
Block a user