Skip to content

Commit ca6f4a7

Browse files
author
Seulgi Kim
committed
Remove PoW consensus
1 parent 73c452c commit ca6f4a7

File tree

37 files changed

+57
-1144
lines changed

37 files changed

+57
-1144
lines changed

Cargo.lock

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ codechain-types = { path = "../types" }
1919
codechain-stratum = { path = "../stratum" }
2020
codechain-vm = { path = "../vm" }
2121
crossbeam-channel = "0.3"
22-
cuckoo = { git = "https://github.com/CodeChain-io/rust-cuckoo.git", rev = "280cab9c" }
2322
hashdb = { path = "../util/hashdb" }
2423
hyper = { git = "https://github.com/paritytech/hyper", default-features = false }
2524
journaldb = { path = "../util/journaldb" }

core/res/blake_pow.json

Lines changed: 0 additions & 66 deletions
This file was deleted.

core/res/cuckoo.json

Lines changed: 0 additions & 69 deletions
This file was deleted.

core/res/husky.json

Lines changed: 0 additions & 61 deletions
This file was deleted.

core/src/block.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -375,19 +375,11 @@ impl LockedBlock {
375375
/// Provide a valid seal in order to turn this into a `SealedBlock`.
376376
/// This does check the validity of `seal` with the engine.
377377
/// Returns the `ClosedBlock` back again if the seal is no good.
378-
pub fn try_seal(
379-
mut self,
380-
engine: &dyn CodeChainEngine,
381-
seal: Vec<Bytes>,
382-
) -> Result<SealedBlock, (Error, LockedBlock)> {
378+
pub fn seal_block(mut self, seal: Vec<Bytes>) -> SealedBlock {
383379
self.block.header.set_seal(seal);
384380

385-
// TODO: passing state context to avoid engines owning it?
386-
match engine.verify_local_seal(&self.block.header) {
387-
Err(e) => Err((e, self)),
388-
_ => Ok(SealedBlock {
389-
block: self.block,
390-
}),
381+
SealedBlock {
382+
block: self.block,
391383
}
392384
}
393385

core/src/client/client.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -316,21 +316,13 @@ impl Client {
316316
}
317317
}
318318

319-
/// When RESEAL_MAX_TIMER invoked, a block is created although the block is empty.
320-
const RESEAL_MAX_TIMER_TOKEN: TimerToken = 0;
321319
/// The minimum time between blocks, the miner creates a block when RESEAL_MIN_TIMER is invoked.
322320
/// Do not create a block before RESEAL_MIN_TIMER event.
323321
const RESEAL_MIN_TIMER_TOKEN: TimerToken = 1;
324322

325323
impl TimeoutHandler for Client {
326324
fn on_timeout(&self, token: TimerToken) {
327325
match token {
328-
RESEAL_MAX_TIMER_TOKEN => {
329-
// Working in PoW only
330-
if self.engine().seals_internally().is_none() && !self.importer.miner.prepare_work_sealing(self) {
331-
self.update_sealing(BlockId::Latest, true);
332-
}
333-
}
334326
RESEAL_MIN_TIMER_TOKEN => {
335327
// Checking self.ready_transactions() for efficiency
336328
if !self.engine().engine_type().ignore_reseal_min_period() && !self.is_pending_queue_empty() {
@@ -691,20 +683,6 @@ impl ImportBlock for Client {
691683
Err(err) => unreachable!("Reseal min timer should not fail but failed with {:?}", err),
692684
}
693685
}
694-
695-
fn set_max_timer(&self) {
696-
self.reseal_timer.cancel(RESEAL_MAX_TIMER_TOKEN).expect("Reseal max timer clear succeeds");
697-
match self
698-
.reseal_timer
699-
.schedule_once(self.importer.miner.get_options().reseal_max_period, RESEAL_MAX_TIMER_TOKEN)
700-
{
701-
Ok(_) => {}
702-
Err(TimerScheduleError::TokenAlreadyScheduled) => {
703-
// Since set_max_timer could be called in multi thread, ignore the TokenAlreadyScheduled error
704-
}
705-
Err(err) => unreachable!("Reseal max timer should not fail but failed with {:?}", err),
706-
}
707-
}
708686
}
709687

710688

core/src/client/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,6 @@ pub trait ImportBlock {
206206

207207
/// Set reseal min timer as reseal_min_period, for creating blocks with transactions which are pending because of reseal_min_period
208208
fn set_min_timer(&self);
209-
/// Set reseal max timer as reseal_max_period, for creating empty blocks every reseal_max_period
210-
fn set_max_timer(&self);
211209
}
212210

213211
/// Blockchain database client. Owns and manages a blockchain and a block queue.

core/src/client/test_client.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,6 @@ impl ImportBlock for TestBlockChainClient {
514514
}
515515

516516
fn set_min_timer(&self) {}
517-
518-
fn set_max_timer(&self) {}
519517
}
520518

521519

0 commit comments

Comments
 (0)