Skip to content

Commit

Permalink
Initial pruning logic (#46)
Browse files Browse the repository at this point in the history
* next_pruning_point_and_candidate_by_block_hash

* expected_header_pruning_point

* Fix tests

* block level

* calc_block_parents

* fix off by one

* Add devnet params

* Replace cache

* Fix lint errors

* fmt

* Optimize cache

* Remove unused import

* Use parking lot rwlock

* Remove moka

* Add pruning point info

* Add check to number of levels in check_indirect_parents

* Remove redundant static lifetime specifier

* Fix the pruning point check

* typos

* get pruning info with one call from store

* Build payload with iterators

* Test iterator edge case, remove comment, add test todos

* Fix a parenthesis location bug...

* use ..= syntax to be more explicit about the inclusiveness of the range

* once

* Pass PruningPointInfo struct to expected_header_pruning_point to avoid flipping current and candidate argument order

Co-authored-by: msutton <mikisiton2@gmail.com>
  • Loading branch information
someone235 and michaelsutton authored Oct 13, 2022
1 parent 365f2f3 commit bca138c
Show file tree
Hide file tree
Showing 26 changed files with 1,080 additions and 408 deletions.
207 changes: 3 additions & 204 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ rand_chacha = "0.3"
rayon = "1"
tempfile = "3.3"
serde = { version = "1", features = ["derive", "rc"] }
futures-util = { version = "0.3", default-features = false, features = ["alloc"] }
futures-util = { version = "0.3", default-features = false, features = [
"alloc",
] }
bincode = { version = "1", default-features = false }
tokio = { version = "1", features = ["sync"] }
wasm-bindgen = { version = "0.2", features = ["serde-serialize"] }
criterion = { version = "0.4", default-features = false }
indexmap = "1.9.1"
3 changes: 2 additions & 1 deletion consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ tokio.workspace = true
bincode.workspace = true
tempfile.workspace = true
rayon.workspace = true
rand.workspace = true
indexmap.workspace = true

rocksdb = "0.19"
moka = "0.9"
parking_lot = "0.12"
crossbeam-channel = "0.5"

Expand Down
4 changes: 2 additions & 2 deletions consensus/pow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ impl State {

#[inline]
#[must_use]
pub fn check_pow(&self, nonce: u64) -> bool {
pub fn check_pow(&self, nonce: u64) -> (bool, Uint256) {
let pow = self.calculate_pow(nonce);
// The pow hash must be less or equal than the claimed target.
pow <= self.target
(pow <= self.target, pow)
}
}
Loading

0 comments on commit bca138c

Please sign in to comment.